Skip to content

StringArray flags don't support multiple values via environment variables #678

@emilic

Description

@emilic

Environment variables for StringArray flags (e.g. FGA_CUSTOM_HEADERS, FGA_API_SCOPES) only support a single value. Setting multiple values via env var silently produces one entry containing the entire string, which either fails parsing or is ignored.

Example:

FGA_CUSTOM_HEADERS="X-Foo: bar,X-Baz: qux" fga store list
# Results in one invalid header entry "X-Foo: bar,X-Baz: qux"
# instead of two separate headers

Root cause:

BindViperToFlags (internal/cmdutils/bind-viper-to-flags.go) passes the viper value through fmt.Sprintf("%v", value). When the value comes from an env var, viper returns a plain string — there's no splitting logic. The YAML config file path works correctly (viper returns a []any slice which is now handled), but env vars do not.

Affected flags:

  • --custom-headers / FGA_CUSTOM_HEADERS
  • --api-scopes / FGA_API_SCOPES

Workaround:

Use the config file (~/.fga.yaml) instead:

custom-headers:
  - "X-Foo: bar"
  - "X-Baz: qux"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Intake

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions