fix(doctor): preserve precision of large Discord snowflake IDs in --fix#22524
Open
jmasson wants to merge 4 commits intoopenclaw:mainfrom
Open
fix(doctor): preserve precision of large Discord snowflake IDs in --fix#22524jmasson wants to merge 4 commits intoopenclaw:mainfrom
jmasson wants to merge 4 commits intoopenclaw:mainfrom
Conversation
When `openclaw.json` contains a bare numeric Discord ID exceeding `Number.MAX_SAFE_INTEGER`, `JSON5.parse()` silently rounds it. The repair function then called `String()` on the lossy number, producing a valid-looking but wrong ID. Fix by extracting original digit sequences from the raw config text before conversion, so `maybeRepairDiscordNumericIds` can recover the exact original value instead of stringifying the rounded number. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Store an array of original digit strings per lossy Number key and shift() during repair so each occurrence gets the correct original value. Adds a test for the collision case. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
|
@greptile-apps review |
1 similar comment
Author
|
@greptile-apps review |
Extract only the "discord" object from raw text using brace-depth tracking before scanning for large integers. Handles both quoted and unquoted JSON5 keys. Prevents numbers from unrelated config fields from polluting the precision recovery lookup. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
|
@greptile_apps review |
Braces inside JSON string values (e.g. "note": "Use } here") would throw off the depth counter when extracting the discord config section. Now skips over single- and double-quoted strings, handling escapes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
|
@greptile-apps review |
18 tasks
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.
Summary
doctor --fixsilently corrupts Discord snowflake IDs that exceedNumber.MAX_SAFE_INTEGER.JSON5.parse()rounds the bare integer, then the repair stringifies the lossy number — producing a valid-looking but wrong ID.maybeRepairDiscordNumericIdsnow accepts the raw config file text and extracts original digit sequences via regex before conversion. Handles collisions where multiple distinct IDs round to the sameNumberby consuming originals in file order.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
doctor --fixrepair)User-visible / Behavior Changes
doctor --fixnow preserves the exact original digits of large Discord IDs instead of silently truncating them.(recovered original precision from file)when raw text recovery is used.Security Impact (required)
Repro + Verification
Environment
Steps
openclaw.jsonwith a bare numeric Discord ID exceeding MAX_SAFE_INTEGER, e.g.{ "channels": { "discord": { "allowFrom": [100000000000000001] } } }openclaw doctor --fixExpected
allowFromcontains"100000000000000001"(original digits preserved)Actual
allowFromcontains"100000000000000000"(truncated)allowFromcontains"100000000000000001"(correct)Evidence
Two new e2e tests: single large ID precision preservation, and multiple IDs that round to the same
Number.Human Verification (required)
Compatibility / Migration
Failure Recovery (if this breaks)
String(entry)when raw text is unavailableRisks and Mitigations
🤖 Generated with Claude Code
Greptile Summary
This PR fixes a critical data corruption bug in
doctor --fixwhere large Discord snowflake IDs exceedingNumber.MAX_SAFE_INTEGERwere silently truncated during repair.Key changes:
maybeRepairDiscordNumericIdsnow accepts raw config file text and extracts original digit sequences via regex before JSON parsingNumberby storing them in an array and consuming in file order (matching JSON parse order)All previously identified issues from review threads have been addressed.
Confidence Score: 4/5
Last reviewed commit: 9791c9c