Skip to content

fix(cli): reject Infinity/NaN in config set/batch/patch values - #120156

Merged
obviyus merged 3 commits into
openclaw:mainfrom
xialonglee:fix/gap-config-set-infinity-nan
Aug 26, 2026
Merged

obviyus merged 3 commits into
openclaw:mainfrom
xialonglee:fix/gap-config-set-infinity-nan

Conversation

@xialonglee

@xialonglee xialonglee commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where openclaw config set <path> <value> (and the equivalent --batch-* / config patch inputs) would silently accept Infinity, -Infinity, or NaN values and later write them as null to the config file. The CLI reported success, but the stored value was corrupted.

Example:

openclaw config set channels.custom.timeout 1e999
# "Updated channels.custom.timeout. No gateway restart needed."
# Config file contained: "timeout": null

Why This Change Was Made

JSON5 and V8's JSON parser accept tokens like Infinity, NaN, and overflow exponents (1e999) as numeric values, but JSON.stringify converts them to null. 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-value config set and --strict-json mode
  • parseJson5Raw() — config set --batch-json / --batch-file
  • readConfigPatchInput() — config patch --file / --stdin
  • writeConfigFileFromContext() — normal config file writer
  • formatJsonFileValue() / writeRootBoundJsonFile() — single-file top-level include fast path

The guard rejects only Infinity, -Infinity, and NaN; 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-path and --provider-allow-symlink-command, keeping them out of the provider-builder CLI path as they are on current main.

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 set builder mode.

Evidence

Before fix

$ node -e "const JSON5 = require('json5'); console.log(JSON5.parse('1e999')); console.log(JSON.stringify(JSON5.parse('1e999')));"
Infinity
null

openclaw config set channels.custom.timeout 1e999 wrote null to openclaw.json while printing "Updated ...".

After fix

$ pnpm exec tsx -e "import { parseConfigSetValue } from './src/cli/config-cli-path.ts'; console.log(parseConfigSetValue('1e999', false));"
Error: Value must be a finite number, got Infinity

$ pnpm exec tsx -e "import { parseBatchSource } from './src/cli/config-set-input.ts'; console.log(parseBatchSource({ batchJson: '[{\"path\":\"x\",\"value\":1e999}]' }));"
Error: Value must be a finite number, got Infinity

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 passed
  • node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json <11 files> — 0 warnings/errors
  • pnpm format:check <11 files> — passed
  • pnpm 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, and config patch --file CLI against isolated config files. Also verifies retired provider-builder bypass options (--provider-allow-insecure-path, --provider-allow-symlink-command) are rejected.

Key markers from the proof log:

[proof] scene=config-set-scalar before exit=0 stored_value=null
[proof] scene=config-set-scalar before corruption=confirmed
[proof] scene=config-set-batch before exit=0 stored_value=null
[proof] scene=config-set-batch before corruption=confirmed
[proof] scene=config-patch before exit=0 stored_value=null
[proof] scene=config-patch before corruption=confirmed
Error: Value must be a finite number, got Infinity
[proof] scene=config-set-scalar after exit=1 stored_value=MISSING status=rejected
[proof] scene=config-set-batch after exit=1 stored_value=MISSING status=rejected
[proof] scene=config-patch after exit=1 stored_value=MISSING status=rejected
[proof] scene=error-message after status=found
OpenClaw does not recognize option "--provider-allow-insecure-path".
OpenClaw does not recognize option "--provider-allow-symlink-command".
[proof] scene=provider-retired-options after status=rejected insecure=1 symlink=1

The before run shows 1e999 being silently persisted as null for scalar, batch, and patch inputs. The after run shows all three modes plus retired provider options rejected before writing, leaving the config file unchanged.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S labels Aug 7, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Aug 7, 2026
@clawsweeper

clawsweeper Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 21, 2026, 7:49 PM ET / 23:49 UTC.

ClawSweeper review

What this changes

This 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
Reviewed head: 538724c8485815272549e94eec515bbbfa8f9166

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is well-targeted and source-supported, but its otherwise strong real CLI evidence does not cover the current merge context and include writer.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: The linked CLI proof shows the old-base branch rejects scalar, batch, and patch values, but it does not show the current merge result or the root-bound include writer; add redacted current-merge output before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The linked CLI proof shows the old-base branch rejects scalar, batch, and patch values, but it does not show the current merge result or the root-bound include writer; add redacted current-merge output before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 8 items Current main remains unguarded: Scalar config values are returned directly from JSON.parse or JSON5.parse; no finite-number check runs before mutation.
Current serialization corrupts non-finite values: The root writer passes the stamped config directly to JSON.stringify, and the include fast path does the same for included values.
Observed JavaScript serialization contract: Node serialized Infinity, -Infinity, and NaN as {"value":null}, matching the reported persistence failure once parsed values reach either writer.
Findings None None.
Security None None.

Live Verification

Command: OPENCLAW_STATE_DIR="$(mktemp -d)" pnpm openclaw config set channels.custom.timeout 1e999

Result: PASS (completed)

OPENCLAW_STATE_DIR="$(mktemp -d)" pnpm openclaw config set channels.custom.timeout 1e999
runner@runnervm76f27:/tmp/clawsweeper-live-proof-120156-dCd9tX/target$ OPENCLAW_STATE_DIR="$(mktemp -d)" pnpm openclaw config set channels.custom.timeout 1e999
$ node scripts/run-node.mjs config set channels.custom.timeout 1e999
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[browser] build: node scripts/build-copilot-runtime.mjs
[canvas] build: node scripts/bundle-a2ui.mjs
OPENCLAW_STATE_DIR="$(mktemp -d)" pnpm openclaw config set channels.custom.timeout 1e999
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.88 kB
[log]
[success] rolldown v1.2.0 Finished in 43.06 ms
[diffs] build: node ../../scripts/build-diffs-viewer-runtime.mjs curated
[diffs-language-pack] build: node ../../scripts/build-diffs-viewer-runtime.mjs full
[discord] build: node ../../scripts/build-discord-activity-sdk.mjs
[tsdown-build] invocation 1/2 finished in 0.7s
[tsdown-build] invocation 2/2 finished in 8.4s
runtime-postbuild: 9 phases completed in 1012ms (slowest: stable root runtime imports 270ms)
│
◇

OpenClaw 2026.7.2 (538724c) — If you're lost, run doctor; if you're brave, run prod; if you're wise, run tests.

23:50:31 [state-migrations] Auto-migrated legacy state:
- Recorded Matrix inbound dedupe migration completion (0 SQLite roots, 0 JSON roots scanned)
│
◇  Doctor changes ──────────────────────────────────────────────────────────────────────╮
│                                                                                       │
│  - Recorded Matrix inbound dedupe migration completion (0 SQLite roots, 0 JSON roots  │
│    scanned)                                                                           │
│                                                                                       │
├───────────────────────────────────────────────────────────────────────────────────────╯
Error: Value must be a finite number, got Infinity
[ELIFECYCLE] Command failed with exit code 1.
runner@runnervm76f27:/tmp/clawsweeper-live-proof-120156-dCd9tX/target$ OPENCLAW_STATE_DIR="$(mktemp -d)" pnpm openclaw config set channels.custom.timeout 1e999

















Assertions:

  • PASS expect_output: Value must be a finite number

How this fits together

The 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
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The linked CLI proof shows the old-base branch rejects scalar, batch, and patch values, but it does not show the current merge result or the root-bound include writer; add redacted current-merge output before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - Current main substantially changed the config mutation and writer implementation after the proof base; mergeable status does not prove scalar, batch, patch, root-writer, and include-writer behavior on the resulting code.
Agent review details

Security

None.

PR surface

Source +22, Tests +180. Total +202 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 7 44 22 +22
Tests 6 181 1 +180
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 225 23 +202

Review metrics

Metric Value Why it matters
Config mutation boundaries 3 input parsers and 2 serialization paths guarded The change deliberately tightens the persisted-config contract at every identified route into JSON serialization.
Production versus test delta production +44/-22, tests +181/-1 The net production growth is justified by one shared validation invariant plus calls at the two persistence owners; most added lines are regression coverage.

Stored data model

Persistent data-model change detected: serialized state: src/cli/config-cli-path.ts, serialized state: src/config/io.write-config.test.ts, serialized state: src/config/mutate.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Refresh current-main mutation proof (recommended)
    Run the isolated-config CLI proof against the current merge result, including root and root-bound include writes, and show that rejected values leave each target unchanged.

Technical review

Best 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.

Labels

Label justifications:

  • P2: This repairs silent configuration corruption in a bounded but user-facing CLI workflow.
  • merge-risk: 🚨 compatibility: The branch changes accepted config-mutation input behavior and needs current-merge proof that existing write paths retain their expected upgrade behavior.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The linked CLI proof shows the old-base branch rejects scalar, batch, and patch values, but it does not show the current merge result or the root-bound include writer; add redacted current-merge output before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Current main remains unguarded: Scalar config values are returned directly from JSON.parse or JSON5.parse; no finite-number check runs before mutation. (src/cli/config-cli-path.ts:161, 7469b5427244)
  • Current serialization corrupts non-finite values: The root writer passes the stamped config directly to JSON.stringify, and the include fast path does the same for included values. (src/config/io.write.ts:424, 7469b5427244)
  • Observed JavaScript serialization contract: Node serialized Infinity, -Infinity, and NaN as {"value":null}, matching the reported persistence failure once parsed values reach either writer. (7469b5427244)
  • Patch covers the owner boundaries: The branch recursively rejects non-finite numbers and calls the guard at parse boundaries plus both serialization paths. (src/config/io.read-helpers.ts:84, 538724c84858)
  • Dependency signal and guard semantics: The affected parsers import the pinned json5 dependency, while the new recursive guard uses the repository’s canonical non-array record predicate. (package.json:1980, 7469b5427244)
  • Current-area provenance: Blame assigns the current unguarded parse and root-write lines to the recent main rewrite, so this identifies a current area contributor rather than an original defect author. (src/cli/config-cli-path.ts:161, 3376c2980016)

Likely related people:

  • steipete: Current-main blame assigns the implicated parse and writer lines to a recent main rewrite, and recent config-set fixes also touch this CLI surface. (role: recent area contributor; confidence: high; commits: 3376c2980016, 69e4fbbeb5f8, 8bec61bab199; files: src/cli/config-cli-path.ts, src/config/io.write.ts, src/cli/config-cli.ts)
  • joshavant: The config-set builder and dry-run expansion established the batch/provider input surface this PR modifies. (role: feature-history contributor; confidence: medium; commits: e99963100d22; files: src/cli/config-set-input.ts, src/cli/config-cli.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Run scalar, batch, patch, root-writer, and root-bound include-writer rejection scenarios against the current merge result and show target files remain unchanged.
  • Add a redacted command/output summary or artifact link to the PR body; a body update should trigger a fresh review automatically, or a maintainer can comment @clawsweeper re-review.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (7 earlier review cycles)
  • reviewed 2026-08-07T06:24:41.524Z sha 5809c4c :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-07T06:53:02.638Z sha 5809c4c :: needs real behavior proof before merge. :: [P1] Enforce finiteness at the shared config write boundary
  • reviewed 2026-08-07T08:48:50.668Z sha 5809c4c :: needs changes before merge. :: [P1] Enforce finiteness at both config serialization paths | [P1] Remove the restored retired provider bypass fields
  • reviewed 2026-08-07T11:44:07.101Z sha 538724c :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-10T04:04:37.071Z sha 538724c :: needs maintainer review before merge. :: none
  • reviewed 2026-08-10T04:56:07.730Z sha 538724c :: needs maintainer review before merge. :: none
  • reviewed 2026-08-14T22:13:50.000Z sha 538724c :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 7, 2026
@xialonglee

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 7, 2026
…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 clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 7, 2026
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. label Aug 7, 2026
@xialonglee

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 10, 2026
@clawsweeper clawsweeper Bot added clawsweeper-recovery-stuck rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. clawsweeper-recovery-stuck labels Aug 16, 2026
@obviyus

obviyus commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

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.

@obviyus
obviyus merged commit 8952582 into openclaw:main Aug 26, 2026
144 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
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]>
@xialonglee
xialonglee deleted the fix/gap-config-set-infinity-nan branch September 17, 2026 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants