Repository navigation
fix: put "invalid value" before the cause in parse errors - #228
Merged
Merged
Conversation
Parse wrapped the parser error first and ErrInvalidValue last, so the message read backwards: strconv.ParseInt: parsing "x": invalid syntax: invalid value Swap the operands so the message goes from the general error to its cause, as Go error chains usually do: invalid value: strconv.ParseInt: parsing "x": invalid syntax Only the text changes: errors.Is still matches both ErrInvalidValue and the cause. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The EnvParser interface was removed with the parser hierarchy in #223, but the Option comment still called it "a contract for EnvParser parameters options". Describe what an option does instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #228 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 3 3
Lines 99 99
=========================================
Hits 99 99 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Description
Two small fixes found in a review of the repository.
Error message order.
Parsewrapped the parser error first andErrInvalidValuelast, so the message read backwards:The operands are swapped, so the message goes from the general error to its cause:
Stale doc comment.
option.Optionwas described as "a contract for EnvParser parameters options", but theEnvParserinterface went away with the parser hierarchy in #223. The comment now says what an option does.Github Issue
None.
Possible failures/side-effects
errors.Isstill matches bothErrInvalidValueand the cause (TestEnvErrorSentinels, the fuzz test of the error contract).ExampleEnvand its copy in README.md show the new message.Testing
go test -race ./...passes.FuzzParseran for 10s without failures.make lint-full: vet, fmt, goimports and golangci-lint report 0 issues.🤖 Generated with Claude Code