mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-25 16:55:59 +03:00
[GH-ISSUE #5970] [bug]: Hoppscotch truncates precision for long numeric values in the request payload #2345
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#2345
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @qiqingli on GitHub (Mar 10, 2026).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/5970
Originally assigned to: @VivekNeer on GitHub.
Is there an existing issue for this?
Platform
Desktop App
Browser
Chrome
Operating System
macOS
Bug Description
Hoppscotch truncates precision for long numeric values in the request payload, resulting in incorrect parameter values.
Deployment Type
Self-hosted (on-prem deployment)
Version
26.2.1
@VivekNeer commented on GitHub (Mar 10, 2026):
Hello ><
I was able to reproduce this on the latest main (v2026.2.1) on Firefox.
This issue is due to js floating point precision issue where js uses 64 bit IEEE-754 doubles for all numbers so it can represent numbers exactly upto
Number.MAX_SAFE_INTEGER= 2^53 - 1 =9007199254740991.The truncation isn't happening in the HTTP layer it happens earlier, during internal JSON preprocessing in the frontend before the request even leaves the browser. You can see this in the Network tab: the value the server receives is already wrong.
Example:
bigId: 9007199254740993 → truncated to9007199254740992bigId2: 99999999999999999 → truncated to100000000000000000Root cause:
The issue is in
packages/hoppscotch-common/src/helpers/editor/linting/jsonc.ts. Before every JSON body is sent, it passes throughstripComments()to strip JSONC comments and trailing commas. Internally this usesjsonc-parser'sparseTree(), which converts numeric tokens into JavaScriptnumberprimitives. Any integer beyondNumber.MAX_SAFE_INTEGERgets silently rounded at this point. ThenJSON.stringify(node.value)serializes the already-truncated value.Proposed fix:
jsonc-parserstoresoffsetandlengthon every AST node pointing back to the original source text. For the"number"case inconvertNodeToJSON, we can slice the original string instead of going throughnode.value:This is a minimal, safe change only the number case changes, and it reads the exact characters the user typed rather than round-tripping through a lossy JS number.
I'd like to work on this fix. Could this be assigned to me?