fix: preserve large integers in service debug - #1527
Open
Tsukikage7 wants to merge 1 commit into
Open
Conversation
|
Contributor
There was a problem hiding this comment.
Pull request overview
Preserves large integer (e.g., snowflake ID) precision in the Service Debug request editor by parsing JSON in a way that avoids JavaScript number rounding and sending unsafe integers as strings to the generic invoke API.
Changes:
- Add
lossless-jsonto parse debug request JSON without losing precision for large integers. - Update the Service Debug invoke flow to use the new safe-number JSON parsing utility.
- Add regression tests covering unsafe integers (string-preserved) and safe integers (kept as numbers).
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| ui-vue3/package.json | Adds lossless-json dependency used for precision-safe JSON parsing. |
| ui-vue3/yarn.lock | Locks lossless-json version for reproducible installs. |
| ui-vue3/src/views/resources/services/tabs/debug.vue | Uses the new JSON parsing helper so unsafe integers aren’t rounded before sending invoke args. |
| ui-vue3/src/utils/JsonUtil.ts | Introduces JSON parsing helper that preserves unsafe integers as strings. |
| ui-vue3/src/utils/JsonUtil.spec.ts | Adds tests ensuring unsafe integers remain strings and safe integers remain numbers. |
Suppressed comments (1)
ui-vue3/src/utils/JsonUtil.spec.ts:32
- Same as above: avoid relying on
parseJsonWithSafeNumbers<T>implying the parsed structure is exactlyTwhen the helper may convert some numbers to strings. Prefer casting at the call site in tests.
const value = parseJsonWithSafeNumbers<{ text: string; value: number }>(
'{"text":"1694620889412087810","value":9007199254740991}'
)
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+20
to
+24
| export function parseJsonWithSafeNumbers<T>(text: string): T { | ||
| return parse(text, undefined, { | ||
| parseNumber: (value) => (isSafeNumber(value) ? parseFloat(value) : value) | ||
| }) as T | ||
| } |
Comment on lines
+559
to
564
| const parsedArgs = parseJsonWithSafeNumbers<unknown>(requestValue.value) | ||
| if (Array.isArray(parsedArgs)) { | ||
| args = parsedArgs | ||
| } else { | ||
| args = [parsedArgs] | ||
| } |
|
|
||
| describe('parseJsonWithSafeNumbers', () => { | ||
| it('preserves integers outside the JavaScript safe range', () => { | ||
| const args = parseJsonWithSafeNumbers<unknown[]>('[1694620889412087810]') |
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
Preserve large integer values in the service debug request editor so snowflake IDs are not rounded by JavaScript's number handling.
Changes
lossless-json.Closes #1245
Verification
yarn testyarn vite buildFull repository lint and type-check remain blocked by existing baseline errors unrelated to this change.