Summary
When parsing comma-separated annotation values in the APISIX Ingress Controller, the implementation performs a simple strings.Split(value, ",") without trimming whitespace from the resulting elements. This causes leading or trailing spaces to be preserved in values following a comma.
As a result, annotations that define multiple IP addresses fail if a space is included after the comma.
Example
If an annotation is defined as:
127.0.0.1, 0.0.0.0
After splitting on , the resulting values are:
["127.0.0.1", " 0.0.0.0"]
The second value contains a leading space, which causes IP validation to fail.
Why This Is Problematic
- A space character is never valid in an IP address.
- Including a space after a comma is extremely common and idiomatic in programming and configuration formats.
- Users do not typically expect comma-separated configuration values to require manual whitespace management.
- This creates unnecessary fragility in configuration and leads to avoidable validation errors.
Related snippet
|
return strings.Split(value, ",") |
Proposed Resolution
Either:
- Trim whitespace on each split element (preferred)
or
- Explicitly document that whitespace is not allowed in comma-separated annotation values.
Potential problems
This splitting helper appears to be shared across annotations, so trimming would change parsing behavior globally.
Summary
When parsing comma-separated annotation values in the APISIX Ingress Controller, the implementation performs a simple
strings.Split(value, ",")without trimming whitespace from the resulting elements. This causes leading or trailing spaces to be preserved in values following a comma.As a result, annotations that define multiple IP addresses fail if a space is included after the comma.
Example
If an annotation is defined as:
127.0.0.1, 0.0.0.0After splitting on
,the resulting values are:["127.0.0.1", " 0.0.0.0"]The second value contains a leading space, which causes IP validation to fail.
Why This Is Problematic
Related snippet
apisix-ingress-controller/internal/adc/translator/annotations/types.go
Line 134 in c48e9b3
Proposed Resolution
Either:
or
Potential problems
This splitting helper appears to be shared across annotations, so trimming would change parsing behavior globally.