#19111: fix(config): warn on numeric IDs that lose precision
size: S
trusted-contributor
Cluster:
Discord and MS Teams Fixes
Large numeric IDs (e.g. Telegram chat IDs) can lose precision when parsed as JavaScript numbers.
Fix: Add validation that warns when numeric IDs exceed safe integer range.
Recreated from #16934 with only relevant files.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds a config validation utility that warns users when numeric values in their config exceed `Number.MAX_SAFE_INTEGER`, which causes silent precision loss during `JSON.parse`. This is a targeted fix for a real issue with Discord/Telegram snowflake IDs that lose precision when written without quotes in JSON config files. The implementation is clean — a recursive `walk` function scans the raw pre-Zod config object and produces warnings (not errors), and it's integrated at the right location in the plugin-aware validation path.
- New `validation-numeric-ids.ts` module with `warnUnsafeNumericIds()` function that recursively detects unsafe numeric values
- Comprehensive test suite covering safe integers, unsafe integers, multiple warnings, edge cases (NaN, Infinity), and deep nesting
- Integration into `validateConfigObjectWithPluginsBase` in `validation.ts`, appending warnings to the existing warnings array
- **Issue found**: The warning message's suggested fix (`e.g. "${value}"`) interpolates the *already-corrupted* value, which could mislead users into quoting the wrong number
<h3>Confidence Score: 4/5</h3>
- This PR is safe to merge — it only adds non-blocking warnings and does not alter config parsing or validation logic.
- The implementation is well-structured with good test coverage. The only issue is a misleading warning message that suggests quoting the already-corrupted value. The change is additive (warnings only), doesn't affect existing validation behavior, and is properly scoped to the plugin-aware validation path.
- `src/config/validation-numeric-ids.ts` — warning message suggests the corrupted value as the fix
<sub>Last reviewed commit: 012a98e</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#19401: fix(ui): prevent precision loss when coercing large numeric strings...
by Operative-001 · 2026-02-17
77.5%
#22557: fix(discord): coerce exec approval approver IDs to string to preven...
by zwffff · 2026-02-21
74.5%
#10807: fix(config): coerce numeric meta.lastTouchedAt to ISO string
by mcaxtr · 2026-02-07
73.7%
#17380: fix(imessage): reject non-numeric chat_id values to prevent silent ...
by aldoeliacim · 2026-02-15
73.0%
#12048: fix: deduplicate config warnings to log once instead of on every re...
by mcaxtr · 2026-02-08
72.9%
#12204: fix(discord): resolve numeric guildId/channelId pairs in channel al...
by mcaxtr · 2026-02-09
72.4%
#22524: fix(doctor): preserve precision of large Discord snowflake IDs in -...
by jmasson · 2026-02-21
72.3%
#16828: fix(config): transform Discord user/role IDs to strings
by Limitless2023 · 2026-02-15
72.3%
#18966: fix(config): downgrade unknown bundled plugin references to warnings
by moxunjinmu · 2026-02-17
72.1%
#21463: fix(discord): prevent WebSocket death spiral + fix numeric channel ID…
by akropp · 2026-02-20
71.5%