Skip to content

bug: Ingress annotations: comma-separated values are not trimmed, causing invalid IP parsing when spaces are present #2723

@vdegans

Description

@vdegans

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

  1. A space character is never valid in an IP address.
  2. Including a space after a comma is extremely common and idiomatic in programming and configuration formats.
  3. Users do not typically expect comma-separated configuration values to require manual whitespace management.
  4. This creates unnecessary fragility in configuration and leads to avoidable validation errors.

Related snippet

Proposed Resolution

Either:

  1. Trim whitespace on each split element (preferred)
    or
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions