Skip to content

fix: deserialize hgetall decimal values as numbers - #1490

Open
pcbeingused333 wants to merge 2 commits into
upstash:mainfrom
pcbeingused333:fix/c3972-hgetall-decimals
Open

pcbeingused333 wants to merge 2 commits into
upstash:mainfrom
pcbeingused333:fix/c3972-hgetall-decimals

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

HGETALL returns stored decimal values such as 1.5 and -0.25 as strings, causing arithmetic on those fields to concatenate text. The unsafe-integer guard also matches non-integer numbers, preventing them from reaching JSON deserialization.

Restrict the guard to integer values so decimals are parsed as numbers while unsafe integers retain their original strings. Include a patch changeset.

Testing

bun test packages/redis/pkg/commands/hgetall-deserialize.test.ts

The regression fails on main because both decimal fields remain strings. With the fix, all three tests pass, covering decimals alongside an unsafe integer, ordinary JSON values, missing hashes, and disabled automatic deserialization. These tests exercise command deserialization directly and do not require a Redis server.

Disclosure: this change was prepared with AI assistance.

# Conflicts:
#	packages/redis/pkg/commands/hgetall.ts

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant