return err for invalid env default value #334
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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!