Repository navigation
test(kv): cover the invalid int error path in strict mode - #461
Merged
Merged
Conversation
assignField's parse int error was never exercised, and Decode in non-strict mode silently swallows assign errors so the only way to reach it is through Strict. Signed-off-by: Akanksha Trehun <akankshatrehun@gmail.com>
There was a problem hiding this comment.
🟢 Approval recommended
The change is a focused test-only addition that correctly exercises a previously untested error branch without altering production behavior.
Pull request overview
Adds a regression test to ensure kv.Decoder exercises (and surfaces) the assignField integer parsing failure path, which is only observable when the decoder is in Strict mode.
Changes:
- Added a new subtest that decodes an invalid
intvalue (key4=notanumber) and asserts the resulting error contains"parse int". - Enables
Strict()in that subtest soDecodereturns assign/parse errors instead of discarding them in default (non-strict) mode.
File summaries
| File | Description |
|---|---|
| kv/decoder_test.go | Adds a strict-mode test case that triggers and asserts the invalid-int parsing error path. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
kke
approved these changes
Sep 8, 2026
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.
kv.Decoder'sassignFieldhas a parse int error branch that no test exercised. Adding a case for it also surfaced thatDecodein non-strict mode (the default) silently discards assign errors, including this one, so the only way to actually observe the error is throughStrictmode. This test usesStrictto reach it.Test only, no production code changed.
Tested with
go test ./kv/...,gofmt -l, andgo vet ./kv/..., all clean.