Skip to content
New issue

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

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

Already on GitHub? # to your account

return err for invalid env default value #334

Merged
merged 3 commits into from
Jul 11, 2020

Conversation

vito
Copy link
Contributor

@vito vito commented Apr 21, 2020

fixes #329

This change is pretty important for us because we use env vars not only as a way of providing defaults but as a way for users to configure our software in e.g. docker-compose.yml.

Without this change, bogus values do not raise errors, and this can cause nil panics in production code because it normally assumes that all flag values have been unmarshaled and any errors raised there will be respected. Rather than having to write defensive code, I think it would be better for env value defaults to behave the exact same as if they were specified via flags, as this allows us to push as much validation as possible into the parsing stage and catch errors as early as possible.

Thanks!

vito and others added 3 commits April 21, 2020 10:59
Signed-off-by: Alex Suraci <suraci.alex@gmail.com>
Signed-off-by: Jamie Klassen <cklassen@pivotal.io>
include flag name when erroring on env default
Copy link
Owner

@jessevdk jessevdk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thanks!

@jessevdk jessevdk merged commit f07ca6c into jessevdk:master Jul 11, 2020
jamieklassen pushed a commit to concourse/concourse that referenced this pull request Sep 29, 2020
since jessevdk/go-flags#334 got merged a while ago,
there's no need to point to our fork.

Signed-off-by: Jamie Klassen <jklassen@vmware.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Env variables totally bypass flag type validation
2 participants