Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Env var expansion logic inconsistent #101

Open
bayesianmind opened this issue Aug 14, 2018 · 1 comment
Open

Env var expansion logic inconsistent #101

bayesianmind opened this issue Aug 14, 2018 · 1 comment
Labels

Comments

@bayesianmind
Copy link

bayesianmind commented Aug 14, 2018

We've seen several users be quite confused about the defaults section of environment variable expansion defined here.

The behavior around quote characters is inconsistent and this has caused user confusion.
${NOTSET:} - fails saying no default has been provided.
${NOTSET:""} - uses empty string and strips the quote characters.
${NOTSET:"value"} - returns "value" with the quotes, usually breaking the customer's usage. It's very natural for them to take a "" default and fill in a string inside the quotes.
${NOTSET:value} - returns value as the user probably intended.

Quotes should either always be stripped or never be stripped.

Option 1:
The most backwards compatible change is simply to allow the form ${NOTSET:} but this is more confusing because "" will still really mean empty string while "a" will mean quoted "a".

Option 2:
Strip outer quotes. Potentially a breaking change in the unlikely case people actually want literal quote characters in their defaults. Better long term outcome because behavior is totally consistent and all forms of defaults are supported. If you want quotes, you would escape them like ${NOTSET:"\"quoted\""}

@glibsm
Copy link
Contributor

glibsm commented Aug 15, 2018

Linked code looked like something I wrote a while back, so I went digging. Found the original PR uber-go/fx#384

Can't quite remember the reason why ${NOTSET:} is treated explicitly as invalid.

@ibarrajo ibarrajo added the bug label Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants