Skip to content

Only split environment variables on commas when explicitly told to do so? #55

@deanishe

Description

@deanishe

I ran into an issue yesterday when a string flag's value was being truncated, and I eventually figured out that it was ff splitting the environment variable on the comma, leaving the flag set to only the last few characters of the input.

I believe that splitting by default is not a good idea because none of the default flag types actually support multiple values, meaning the default behaviour is effectively to (incorrectly) truncate input if there's a comma in it.

Splitting is also currently an all-or-nothing proposition: you can have automatic splitting on if you've defined your own custom slice-based Value, but then you also run the risk of standard flag.String values being borked if their input contains a comma.

I think a better solution would be for environment variable splitting to be explicitly opt-in for specific flags or specific types (if that's possible), e.g. ff.WithEnvVarSplit("flag1", "flag2", ...) or ff.WithEnvVarSplit(*CustomValue1, *CustomValue2, ...).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions