← Back to PRs

#19111: fix(config): warn on numeric IDs that lose precision

by Clawborn open 2026-02-17 11:34 View on GitHub →
size: S trusted-contributor
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