Repository navigation
fix(cli): reject Infinity/NaN in config set/batch/patch values - #120156
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed August 21, 2026, 7:49 PM ET / 23:49 UTC. ClawSweeper reviewWhat this changesThis PR rejects Infinity, -Infinity, NaN, and overflowed numeric inputs in config set, batch, patch, and config serialization paths, while retaining the removal of two retired provider-builder flags. Merge readiness⛔ Blocked until stronger real behavior proof is added - 2 items remain Keep open. Current main still silently serializes non-finite config values as null; the patch addresses the right producer and writer boundaries, but its real CLI proof predates the current config-write architecture and does not cover the current merge result’s include-file writer. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherThe config CLI parses values from command arguments, batch JSON, or patch files and sends mutations to config writers. Those writers persist either the root config file or a root-bound included file. flowchart LR
A[Config CLI command] --> B[Value or JSON5 parsing]
B --> C[Config mutation operations]
C --> D[Root config writer]
C --> E[Included-file writer]
D --> F[Persistent config]
E --> F
Before merge
Agent review detailsSecurityNone. PR surfaceSource +22, Tests +180. Total +202 across 13 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep parse-time errors for clear operator feedback and retain the shared writer guards as the final persistence invariant, then prove both root and included-file writes against the current merge result. Do we have a high-confidence way to reproduce the issue? Yes: current main directly parses scalar, batch, and patch JSON5 values and passes them to unguarded JSON serialization; the supplied real CLI trace confirms the same failure on the prior main base. Is this the best way to solve the issue? Yes: parse-time rejection provides an actionable error, while writer-side rejection protects programmatic and include-file paths that parsing alone cannot guarantee. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 7469b5427244. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…move retired provider flags - Move rejectConfigNonFiniteNumbers to config/io.read-helpers and apply it before JSON.stringify in the normal writer and the include-file fast path. - Remove restored providerAllowInsecurePath / providerAllowSymlinkCommand CLI options and their handling, keeping them retired. - Restore regression coverage ensuring the retired options stay rejected.
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Maintainer verification on exact head 538724c. No production changes were needed beyond the contributor commits. I reviewed the shared parser and both config write boundaries. The current-main merge proof rejected 1e999 as Infinity in scalar, batch, stdin patch, and root-config-with-include writes. All four commands exited 1, and byte checks confirmed unchanged root and include files. ClawSweeper local review: zero findings, zero security concerns, zero maintainer decisions. Its Rank-up move requested current-main CLI proof; applied with the four cases and unchanged-file checks. Final local rerun follows this comment. Local gates passed: git diff --check; oxfmt --check on touched files; oxlint on touched files; pnpm tsgo; pnpm check:test-types; grouped Vitest for src/cli and src/config. Telegram generic default-turn probe passed: doctor completed, real DM reply matched OPENCLAW_E2E_OK, and the summary recorded three mock-provider requests. Exact-head openclaw/ci-gate passed: run 31174831488. No CI attribution issue remains. |
fix(cli): reject non-finite config numbers (openclaw#120156) Reject non-finite numeric values at config parsing and serialization boundaries. Preserve root and included config files by failing before JSON.stringify. Keep retired provider bypass flags unavailable. Co-authored-by: xialonglee <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Fixes an issue where
openclaw config set <path> <value>(and the equivalent--batch-*/config patchinputs) would silently acceptInfinity,-Infinity, orNaNvalues and later write them asnullto the config file. The CLI reported success, but the stored value was corrupted.Example:
Why This Change Was Made
JSON5 and V8's JSON parser accept tokens like
Infinity,NaN, and overflow exponents (1e999) as numeric values, butJSON.stringifyconverts them tonull. The config write path never validated finiteness, so non-finite numbers could reach the file.The fix introduces a small recursive guard,
rejectConfigNonFiniteNumbers(), owned by the config IO layer and applied at every user-facing JSON5/JSON parse boundary for config mutations, plus both shared configuration serialization paths:parseConfigSetValue()— single-valueconfig setand--strict-jsonmodeparseJson5Raw()—config set --batch-json/--batch-filereadConfigPatchInput()—config patch --file/--stdinwriteConfigFileFromContext()— normal config file writerformatJsonFileValue()/writeRootBoundJsonFile()— single-file top-level include fast pathThe guard rejects only
Infinity,-Infinity, andNaN; ordinary finite numbers, strings, booleans, objects, and arrays continue to work exactly as before.This revision also removes the accidentally restored retired provider-builder bypass options
--provider-allow-insecure-pathand--provider-allow-symlink-command, keeping them out of the provider-builder CLI path as they are on currentmain.User Impact
Users now get a clear error immediately when they try to set a non-finite numeric value, instead of a misleading success message followed by a corrupted config file. The retired provider-bypass flags remain unavailable through
config setbuilder mode.Evidence
Before fix
$ node -e "const JSON5 = require('json5'); console.log(JSON5.parse('1e999')); console.log(JSON.stringify(JSON5.parse('1e999')));" Infinity nullopenclaw config set channels.custom.timeout 1e999wrotenulltoopenclaw.jsonwhile printing "Updated ...".After fix
Tests
node scripts/run-vitest.mjs src/config/io.write-config.test.ts src/config/mutate.test.ts src/cli/config-cli.test.ts src/cli/config-cli-path.test.ts src/cli/config-set-input.test.ts src/cli/config-cli-input.test.ts— 202 tests passednode scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json <11 files>— 0 warnings/errorspnpm format:check <11 files>— passedpnpm check:test-types— passed (core/extensions/root tsgo lanes)CI proof: exact-head before/after
Proved this change at exact heads using the real
openclaw config set,config set --batch-json, andconfig patch --fileCLI against isolated config files. Also verifies retired provider-builder bypass options (--provider-allow-insecure-path,--provider-allow-symlink-command) are rejected.9aa24e8f538724c8Key markers from the proof log:
The before run shows
1e999being silently persisted asnullfor scalar, batch, and patch inputs. The after run shows all three modes plus retired provider options rejected before writing, leaving the config file unchanged.