Repository navigation
fix(ui): reject nondecimal strings in config form number coercion - #109675
wangmiao0668000666 wants to merge 4 commits into
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 18, 2026, 2:50 AM ET / 06:50 UTC. Summary PR surface: Source +23, Tests +177. Total +200 across 5 files. Reproducibility: yes. the supplied before/after real Control UI and gateway transcript identifies the affected save path, and the focused regression cases exercise the same renderer and serialization boundaries. Review metrics: 1 noteworthy metric.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Land the shared boundary only after confirming that config forms should accept standard decimal/scientific notation but leave radix and other JavaScript-only spellings to schema validation. Do we have a high-confidence way to reproduce the issue? Yes: the supplied before/after real Control UI and gateway transcript identifies the affected save path, and the focused regression cases exercise the same renderer and serialization boundaries. Is this the best way to solve the issue? Unclear until maintainer intent is confirmed: the shared helper is the narrowest maintainable implementation, but the accepted numeric grammar is a user-facing compatibility choice. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d8b183176917. Label changesLabel justifications:
Evidence reviewedPR surface: Source +23, Tests +177. Total +200 across 5 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
Review history (8 earlier review cycles)
|
|
Real Control UI + real gateway proof for the 🦪 needs-proof gate (head Setup: built the PR worktree ( Field: Settings → AI & Agents → Agents → Agent Defaults → Compaction → "Compaction Active Transcript Size Threshold" ( Before (same build, only After (this PR): typing Decimal control (this PR): typing Driver transcripts (Playwright log lines, incl. persisted-file reads after each autosave)Note on scope: plain |
|
P1 fix pushed: head What changed: the strict decimal gate now runs at the earliest input-normalization boundary, before any Regression coverage for both field classes:
Refreshed real-browser proof for the plain number field (real gateway from this branch's
PR body Evidence section updated with the same before/after pairs. |
068e147 to
95ffcae
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Round 3 — P1 addressed: scientific notation preserved, radix spellings still rejected @
|
|
Note on the red CI: the two failing checks ( |
The decimal grammar now mirrors the HTML valid floating-point number grammar: scientific spellings (1e5, -2.5E-3, .5e2) coerce exactly as Number() reads them, while radix and JS-only spellings (0x10, 0b1010, 0o17, 1_000, Infinity, NaN, leading +, 1e, e5) still stay strings for schema validation to reject. Rejecting 1e5 was a compatibility break with the HTML number input grammar and standard Number() spelling. Co-Authored-By: Claude <[email protected]>
4c671dc to
39df5c3
Compare
|
Rebased onto current main ( |
|
Thanks @wangmiao0668000666. The broader config-form integrity fix incorporated this PR's numeric grammar and regression coverage, with contributor credit preserved, and has now merged in #116282 at Closing this PR as superseded by the landed canonical fix. |
|
Thanks @vincentkoc for carrying the numeric grammar and regression coverage into the broader fix — verified the landed grammar in |



What Problem This Solves
The Control UI config form coerces string input back to schema-typed numbers before submitting
config.set/config.apply, but the coercion used a bareNumber(trimmed).Number()accepts radix and JS-only spellings, so typing0x10into a numeric field or astring|numberunion field silently persisted16— the stored config value differs from what the user typed, with no error surfaced. Same for0b1010→10,0o17→15,1_000→1000,Infinity, and leading+spellings.Entry paths are real: mixed
string|numberunions render as plain text inputs, array items arrive as strings, and HTML number inputs always emit string.values — all flow throughpatchForm→serializeFormForSubmit→coerceFormValues→coerceConfigFormNumberString.Why This Change Was Made
Gate coercion on a decimal regex (
/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/,ui/src/components/config-form.shared.ts) before callingNumber(). The grammar mirrors the HTML valid floating-point number grammar exactly: radix and JS-only spellings (0x10,0b1010,0o17,1_000,Infinity,NaN, leading+, dangling exponents like1e/e5) fall through to the keep-as-string path, so the typed text is submitted verbatim and the gateway's schema validation rejects it with a visible error instead of silently storing a reinterpreted number.Scientific notation (
1e5,-2.5E-3,.5e2) is deliberately accepted: it is part of the HTML number input grammar and the standardNumber()spelling, so rejecting it would be a compatibility break, andNumber("1e5")→100000is not a reinterpretation — the persisted value means exactly what the user typed. Anything a real<input type="number">can hold coerces exactly asNumber()reads it; spellings the browser itself sanitizes away (0x10,1_000,+5) are rejected at thepatchFormboundary for the text-input entry paths (union fields, array items).This mirrors the merged nondecimal-reject pattern: #107480 (
parseCronEveryMsrejects0x10/+1in cron repeat amounts) and #105158 (parseStrictFiniteNumberrejects hex--cpus 0x10in fleet). Negative decimals, floats, and.5/5.spellings coerce exactly as before, and the existing finite/integer guards are untouched.No new config/env/options; the production change is one module-level regex in
ui/src/components/config-form.shared.ts.User Impact
0x10/0b1010/1_000/Infinityinto a numeric config field no longer silently writes a different number intoopenclaw.json; the typed text is preserved and rejected by schema validation where the user can see it.1e5) saves as the number it spells (100000), matching the HTML number grammar andNumber()contract.42.5,-7,.5) behaves exactly as before.Evidence
Production-entry proof — real
createRuntimeConfigCapabilitysave flowA standalone script (not committed) drives the real capability —
ensureLoaded+ensureSchemaLoaded+patchForm+save()against a plain fake gateway client object — and inspects the exactrawbytes submitted toconfig.set. No test mocks anywhere in the path.Before fix (
origin/main@19b5e564d7):{ "hex-into-number-field": { "typed": "0x10", "submittedValue": 16, "submittedType": "number" }, "binary-into-integer-field": { "typed": "0b1010", "submittedValue": 10, "submittedType": "number" }, "exponent-into-number-field": { "typed": "1e3", "submittedValue": 1000, "submittedType": "number" }, "hex-into-string|number-union": { "typed": "0x10", "submittedValue": 16, "submittedType": "number" }, "valid-decimal-still-coerces": { "typed": "42.5", "submittedValue": 42.5, "submittedType": "number" }, "valid-negative-still-coerces": { "typed": "-7", "submittedValue": -7, "submittedType": "number" } }After fix (this PR, regex + guard in
config-form.shared.ts):{ "hex-into-number-field": { "typed": "0x10", "submittedValue": "0x10", "submittedType": "string" }, "binary-into-integer-field": { "typed": "0b1010", "submittedValue": "0b1010", "submittedType": "string" }, "exponent-into-number-field": { "typed": "1e3", "submittedValue": 1000, "submittedType": "number" }, "hex-into-string|number-union": { "typed": "0x10", "submittedValue": "0x10", "submittedType": "string" }, "valid-decimal-still-coerces": { "typed": "42.5", "submittedValue": 42.5, "submittedType": "number" }, "valid-negative-still-coerces": { "typed": "-7", "submittedValue": -7, "submittedType": "number" } }Note the round-3 behavior change:
1e3now coerces to1000(standard scientific spelling, not a reinterpretation), while radix/JS-only spellings still stay strings.Control-red
Reverse-verified both directions: reverting the regex to the strict decimal-only form turns the 6 new scientific-notation assertions red (
1e5/1e3/.5e2/-2.5E-3coercion in number fields, integer fields, and the union field); restoring it returns the suite to green. Reverting the whole guard to a bareNumber(trimmed)reproduces the silent16/10rewrites.Regression tests —
ui/src/lib/config/index.test.ts+ui/src/components/config-form.browser.test.tsit.each(["0x10", "0b1010", "0o17", "+5", "1_000", "Infinity", "NaN", "1e", "e5"]): number AND integer fields keep radix/JS-only spellings as strings in the submittedconfig.setpayload.it.each([["42.5", 42.5], ["-7", -7], [".5", 0.5], ["1e3", 1000], ["1e5", 100000], [".5e2", 50], ["-2.5E-3", -0.0025]]): decimal and scientific spellings coerce to numbers.1e5→100000(number),0x10stays a string,42→42.inputevents on rendered number inputs —1e5patches100000,-2.5E-3patches-0.0025,42.5into an integer field is held back as a string for schema validation.Test suite
Lint / format
Real Control UI browser proof (round 3, refreshed 2026-07-18)
Real gateway from this branch's
dist/+ real Chromium driving the served Control UI (no mocks),agents.defaults.compaction.reserveTokens(integer field):1e5autosaves and persists"reserveTokens": 100000inopenclaw.json(new behavior — scientific notation preserved).42.5into the same integer field still fails schema validation: "Save failed" pill, typed text retained, file keeps100000.100000in the field; typing a plain decimal (150000) saves as a number, exactly as before.0x10,1_000,+5) cannot even be entered into a real<input type="number">— Chromium sanitizes them to the empty string — so their rejection is proven at thepatchFormboundary in the tests above.Screenshots + transcript: #109675 (comment)