Repository navigation
fix: parse AsIntMap values as base 10 - #1026
Merged
Merged
Conversation
rueian
approved these changes
Sep 5, 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.
AsIntSlicereads a value of"010"as 10,AsIntMapreads the same string as 8. It passes base 0 tostrconv.ParseInt, so a leading zero gets treated as an octal prefix."08"and"09"arent valid octal at all, so one of those anywhere in the reply fails the whole call with an invalid-syntax error and hands back a nil map.Hash values are just whatever got writen into them, so a service or an import that zero-pads its numbers is enough to hit this through
HGETALL.Base 10 does change two other inputs:
"0x1f"and"1_0"become errors rather than 31 and 10. That's whatAsIntSlicealready does with both of them, and I don't think Redis returns either shape as a map value, but it is a behaviour change."010"and"08"went into the existingAsIntMapsubtest.Note
Low Risk
Small, localized parsing fix in AsIntMap with a minor behavior change for non-decimal string literals; aligns with existing slice/scalar int parsing.
Overview
AsIntMapnow parses string hash/map values with base 10 instead ofstrconvbase 0, matchingAsIntSliceandAsInt64.That fixes wrong values for zero-padded decimals (e.g.
"010"was octal 8, now 10) and avoids whole-map failures when a value like"08"or"09"is invalid in octal (common fromHGETALL/ stored string fields).Tests cover
"010"→ 10 and"08"→ 8. Values that only base 0 accepted (e.g."0x1f","1_0") now error instead of parsing—unlikely for typical Redis map payloads.Reviewed by Cursor Bugbot for commit 11fb55b. Bugbot is set up for automated code reviews on this repo. Configure here.