openfga / openfga/cli

StringArray flags don't support multiple values via environment variables

Open Beginner friendly
#678 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
102
Forks
49
Avg merge
1d 1h
Merged PRs (30d)
16

Description

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"

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in internal/cmdutils/bind-viper-to-flags.go at BindViperToFlags and reproduce the issue with FGA_CUSTOM_HEADERS or FGA_API_SCOPES. Verify how environment-variable strings are converted compared with the YAML slice path. Done means multiple environment-variable values become separate flag entries without regressing config-file behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.