Repository navigation
fix(ui): reject blank required strings in Control UI update readers - #124264
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed August 15, 2026, 5:09 PM ET / 21:09 UTC. ClawSweeper reviewWhat this changesThe PR changes Control UI update-state readers to reject blank required protocol strings, tolerate additive fields, and add protocol-parity regression coverage. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked by patch quality or review findings - 4 items remain This PR remains necessary: current main still accepts blank required update fields. The revised approach fixes that boundary, but it newly removes the five-commit UI bound, allowing an out-of-contract payload to render an unbounded list; keep it open for that focused repair and UI proof. Priority: P2 Review scores
Verification
How this fits togetherGateway hello snapshots, update events, and update-status responses feed Control UI readers that normalize update metadata before the sidebar and Updates page render it. The readers must preserve useful forward-compatible data without allowing malformed payloads to create invalid or unbounded UI state. flowchart LR
A[Gateway update payload] --> B[Hello, event, or status response]
B --> C[Control UI update reader]
C --> D[Required-field and list bounds]
D --> E[Normalized update state]
E --> F[Sidebar banner]
E --> G[Updates commit list]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource -7, Tests +182. Total +175 across 2 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Retain the non-empty-string repair and additive tolerance, but restore a five-entry bound before normalizing commits and prove the bound in a running Control UI. Do we have a high-confidence way to reproduce the issue? Yes — source inspection shows a six-entry payload reaches the PR reader's unbounded filter/map path and the Updates page renders every normalized entry; no test was run in this read-only review. Is this the best way to solve the issue? No — the required-string fix is sound, but the best repair must retain the existing five-entry UI safety bound while keeping the intended per-entry tolerance. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against db0d133ec952. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
The Control UI update readers accepted `""` for fields the canonical UpdateAvailableSchema/UpdateScheduleStateSchema declare as NonEmptyString, so a malformed Gateway payload rendered an update banner with blank version text. Root cause is the reader treating "is a string" as the contract for fields whose canonical contract is "is a non-empty string". Fixed at that boundary with the protocol's own dependency-free `isNonEmptyProtocolString` primitive: required NonEmptyString fields now reject the payload when blank, and optional ones are dropped rather than discarding the whole payload. Deliberately does NOT re-derive the canonical schema in the browser: - `additionalProperties: false` is a producer-side contract the Gateway enforces on its own outbound results (src/gateway/server-methods/update.ts). Rejecting unknown keys client-side would turn every additive protocol field into a blank overlay, since a service-worker-cached document keeps an older bundle across a Gateway upgrade. - Canonical `maxLength` counts grapheme clusters (typebox 1.3.6 guard/string.mjs), so the previous `subject.length <= 120` copy dropped valid emoji subjects the schema accepts. The bound is producer-side and is gone rather than approximated. - typebox itself stays out of this module: it is in the Control UI startup graph, which has a hard gzip budget (scripts/check-control-ui-performance.mts). Drift is now pinned in tests instead of duplicated in production: the boundary suite runs fixtures through both the reader and Value.Check over the canonical schemas, asserting that anything the schema accepts still reaches the overlay. Production LOC: net -7 against main.
400183a to
d76b08e
Compare
readUpdateAvailableValue's per-entry filter/map dropped the existing five-commit bound while switching from all-or-nothing rejection to tolerant filtering. The canonical schema caps commits at 5 (packages/gateway-protocol/src/schema/config.ts), and the Updates page renders every entry this reader returns, so the cap is the protocol's own render-side contract, not extra strictness. Slice to MAX_COMMITS after filtering and cover an eight-entry valid payload.
|
Restored the five-entry commit bound: filtering keeps dropping single malformed entries, but the result now slices to On the red New head: ed117af. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
…penclaw#124264) * fix(ui): reject blank required strings in Control UI update readers The Control UI update readers accepted `""` for fields the canonical UpdateAvailableSchema/UpdateScheduleStateSchema declare as NonEmptyString, so a malformed Gateway payload rendered an update banner with blank version text. Root cause is the reader treating "is a string" as the contract for fields whose canonical contract is "is a non-empty string". Fixed at that boundary with the protocol's own dependency-free `isNonEmptyProtocolString` primitive: required NonEmptyString fields now reject the payload when blank, and optional ones are dropped rather than discarding the whole payload. Deliberately does NOT re-derive the canonical schema in the browser: - `additionalProperties: false` is a producer-side contract the Gateway enforces on its own outbound results (src/gateway/server-methods/update.ts). Rejecting unknown keys client-side would turn every additive protocol field into a blank overlay, since a service-worker-cached document keeps an older bundle across a Gateway upgrade. - Canonical `maxLength` counts grapheme clusters (typebox 1.3.6 guard/string.mjs), so the previous `subject.length <= 120` copy dropped valid emoji subjects the schema accepts. The bound is producer-side and is gone rather than approximated. - typebox itself stays out of this module: it is in the Control UI startup graph, which has a hard gzip budget (scripts/check-control-ui-performance.mts). Drift is now pinned in tests instead of duplicated in production: the boundary suite runs fixtures through both the reader and Value.Check over the canonical schemas, asserting that anything the schema accepts still reaches the overlay. Production LOC: net -7 against main. * fix(ui): restore the five-entry cap on tolerant commit filtering readUpdateAvailableValue's per-entry filter/map dropped the existing five-commit bound while switching from all-or-nothing rejection to tolerant filtering. The canonical schema caps commits at 5 (packages/gateway-protocol/src/schema/config.ts), and the Updates page renders every entry this reader returns, so the cap is the protocol's own render-side contract, not extra strictness. Slice to MAX_COMMITS after filtering and cover an eight-entry valid payload.
Fixes #124232
What Problem This Solves
The Control UI update readers accept
""for fields the canonical protocol declares asNonEmptyString.UpdateAvailableSchemarequires non-emptycurrentVersion,latestVersion, andchannel(packages/gateway-protocol/src/schema/config.ts:72-76, viaNonEmptyStringatpackages/gateway-protocol/src/schema/primitives.ts:24), butui/src/app/update-schedule-dto.tsonly checkedtypeof x === "string". An operator could be shown an update banner with blank version text built from a payload the protocol itself considers invalid.The same gap repeated on the schedule root, the package/git schedule targets, and the campaign id, and the file was inconsistent with itself:
readGitInstallMetadataenforced non-emptiness whilereadScheduleTargetdid not.Why This Change Was Made
The fix is at the boundary that owns the invariant, using the protocol's own dependency-free primitive:
NonEmptyStringfields now reject the payload when blank, viaisNonEmptyProtocolString(packages/gateway-protocol/src/protocol-value-normalization.ts). That module has zero imports, so it is safe for the Control UI startup graph.NonEmptyStringfields are now dropped when blank rather than discarding the whole payload. A missingcurrentSharenders fine; a blanked overlay does not.Number.isInteger(x) && Number(x) >= nchains collapse into oneisBoundedIntegerhelper, which also removes theNumber(...)re-casts.Deliberately not done: re-deriving the canonical schema in the browser. Three independent reasons, each verified against source rather than assumed:
1. Closed-object checking is a producer-side contract, and enforcing it client-side breaks additive tolerance.
closedObjectsetsadditionalProperties: false, and the only place that runs against these schemas at runtime is the Gateway validating its own outbound result (src/gateway/server-methods/update.ts:203-207). Thehello.snapshotpath the UI actually reads has no compiled validator at all —HelloOkSchemais exported but never compiled. Meanwhile the protocol is additive-first (AGENTS.md;docs/gateway/clients.md:237-243), its own guards "intentionally allow additive payload fields" (packages/gateway-protocol/README.md:78-80), and an additive field does not movePROTOCOL_VERSION, so the4..4handshake cannot catch it. The Control UI is service-worker cached, so an already-open document keeps an older bundle across a Gateway upgrade (ui/src/app/sw-refresh.runtime.ts:18-21) — older-UI/newer-Gateway is a routine transient state, not a hypothetical. A client-side closed check would turn every additive field into a silently blank update overlay. Every other snapshot/event decoder in the Control UI does tolerant field extraction;GatewayHelloOkeven re-typessnapshotasunknownon purpose (ui/src/api/gateway.ts:102-106).2. The canonical
maxLengthcannot be hand-copied. typebox 1.3.6 measuresminLength/maxLengthin grapheme clusters (node_modules/typebox/build/guard/string.mjs,IsMaxLengthoverNextGraphemeClusterIndex), whileString#lengthcounts UTF-16 code units. So the previoussubject.length <= 120check rejected commit subjects the canonical schema accepts:That bound is producer-side hygiene, so it is now gone rather than approximated. This is the concrete reason a hand-written mirror of the schema is not viable at all: it silently diverges on the rules that are hardest to notice.
3. typebox cannot enter this module.
update-schedule-dto.tsis statically reachable from the entry point (main.ts→app-host.ts→sidebar-update-card.ts→update-overlay-helpers.ts→ here), so it is inside the measured startup graph. The UI's existingValue.Checkcallers (ui/src/lib/tasks/data.ts,task-summary.ts) sit behind route-level dynamic imports and are not measured — the constraint comments say "startup bundle" precisely, and they are correct.User Impact
Operators no longer see an update banner or schedule state with blank version text. Payloads from a newer Gateway carrying additive fields keep rendering instead of silently disappearing, and commit subjects containing emoji are no longer dropped.
Evidence
Regression proof (fails before, passes after). New boundary cases were run against three trees:
main(8f807ae912d)400183a4a59)LC_ALL=en_US.UTF-8 node scripts/run-vitest.mjs ui/src/app/update-overlay-helpers.test.ts— 21 passed.LC_ALL=en_US.UTF-8 node scripts/run-vitest.mjs ui/src/app/overlays.test.ts ui/src/app/overlays-update-campaign.test.ts ui/src/app/overlays-update-race.test.ts ui/src/app/update-confirmation.runtime.test.ts ui/src/app/update-success-notice.test.ts ui/src/pages/config/updates.test.ts— 92 passed across the consuming surfaces.node scripts/check-changed.mjs -- ui/src/app/update-schedule-dto.ts ui/src/app/update-overlay-helpers.test.ts— exit 0: UI typecheck, core test typecheck, lint, i18n catalog, dead-export scan, formatting..claude/skills/autoreview/scripts/autoreview --mode uncommitted— clean, no accepted/actionable findings.Bundle budget. The startup gate is
scripts/check-control-ui-performance.mts, ratcheted againstconfig/control-ui-startup-budget-baseline.json(startupJsGzipBytes: 334391, cap 350 KiB, tolerance 1056 B → effective limit 335,447 B). This change adds no import to the startup graph:isNonEmptyProtocolStringcomes from an already-reachable zero-dependency module, andui/package.json/packages/gateway-protocol/package.jsonare untouched.For the record, importing typebox here was measured rather than asserted. Bundling
Value.Check(UpdateAvailableSchema, …)with esbuild (--bundle --minify --format=esm --platform=browser) produces 38,697 B gzip — about 37x the 1,056 B of headroom, and well past the 4,096 B-per-step ratchet. That matches the precedent inpackages/gateway-protocol/src/schema/session-placement-state.ts, whose comment records a prior incident where pulling the protocol barrel into startup took the bundle to 395 KiB against a 370 KiB budget.Drift protection. Production no longer carries a copy of the schema to drift, so drift is pinned where it costs nothing:
update-overlay-helpers.test.tsimports the canonical schemas and asserts the one direction that matters — every canonical-valid fixture must satisfyValue.Checkand round-trip through the reader unchanged. If a schema change outgrows the reader, that fails in CI.What changed after review
isClosedRecordand all eightKeySetconstants are gone. Production is now net −7 lines againstmain(+91 / −98), down from +159.subject.length <= 120vs typebox's grapheme-clustermaxLength; verified in typebox source and reproduced. The producer-side bound is removed, with a regression test using a 100-emoji subject.key in keys)__proto__/constructor/toStringwire keys neither reach the result nor polluteObject.prototype.One follow-up spotted while reading and not fixed here, since it belongs to a different owner:
scripts/check-control-ui-performance.mts:386-394—--update-baselinewithout--startup-js-byteswrites the locally measured value and skipsvalidateExplicitStartupJsBytes, so the 4096 B ratchet only guards the CI-measured path.Second round: restored commit cap, CI diagnosis
ClawSweeper P2 — five-entry commit bound. The rework above switched
readUpdateAvailableValue's commit handling from all-or-nothing rejection toper-entry
filter().map(), and that dropped the existingrawCommits.length <= 5bound along with it. The canonical schema still capscommitsat 5entries (
commits: Type.Array(UpdateCommitSchema, { maxItems: 5 }),packages/gateway-protocol/src/schema/config.ts:80), and the Updates pagerenders every entry this reader returns, so an out-of-contract payload past
the cap could grow into an unbounded rendered list. Fixed by slicing to a
named
MAX_COMMITS = 5after filtering, so a malformed entry still doesn'thide the rest of the list (unchanged tolerant behavior) but the render bound
holds regardless of how many valid-looking entries a producer sends. Added
caps commits at five entries even when every entry is validinupdate-overlay-helpers.test.ts(8-entry payload, asserts.slice(0, 5)).CI:
checks-ui-e2e (2/12)failure was unrelated CI flake, not this diff.The run at push time failed
ui/src/e2e/session-management.sidebar.e2e.test.ts> "retains the selectedsession and one observer while reconnecting across route changes"
(
expect.polltimeout waiting for sidebar row text to read "Selectedsession recovered";
https://github.com/openclaw/openclaw/actions/runs/31908289886/job/95069436970).
Checked whether this diff could plausibly affect it: this PR only touches
ui/src/app/update-schedule-dto.tsand its test. The only importers ofupdate-schedule-dto.tsareupdate-overlay-helpers.ts(and its test) andoverlays.ts; the failing test never references sessions/update overlays andits mocked
sessions.list/sessions.subscribefixtures carry noupdateAvailable/updateSchedulesnapshot data, so the changed code pathcannot execute in that test. Confirmed via
git diff --stat $(git merge-base origin/main HEAD) HEADthat the PR touches exactly thosetwo files.
Checked for a same-window CI flake pattern instead: this happened during the
same evening CI window as
#124290, an open P1 documenting
ui/src/e2e/agent-file-lifecycle.e2e.test.tsfailing with the identical"Matcher did not succeed in time." shape across three unrelated PRs
(#124253, #124256, #124257) that don't touch the failing path either. One of
those occurrences (PR #124257, shard 10/12,
https://github.com/openclaw/openclaw/actions/runs/31908362789) ran in the
same CI run as another unrelated
checks-ui-e2eshard failure(
config-safe-write.e2e.test.ts, shard 6/12, same run), and a fourthunrelated PR in the same window
(https://github.com/openclaw/openclaw/actions/runs/31908722207, shard
11/12) failed a
new-session-page.prompt-attachments.e2e.test.tsassertion.Four different
checks-ui-e2etest files failed across four unrelated PRsin the same short CI window, none of them importing or exercising this PR's
diff — consistent with shared-runner timing flakiness in the mocked-Gateway
E2E matrix that evening rather than a regression from this change.
Reran the failed job:
gh run rerun 31908289886 --failed.Gates (this round)
LC_ALL=en_US.UTF-8 node scripts/run-vitest.mjs ui/src/app/update-overlay-helpers.test.ts— 22 passed (was 21; +1 new cap test).node scripts/check-changed.mjs -- ui/src/app/update-schedule-dto.ts ui/src/app/update-overlay-helpers.test.ts— exit 0: UI/core typecheck, lint, i18n catalog, dead-export scan, formatting.oxfmt— no changes needed on either file..claude/skills/autoreview/scripts/autoreview --mode uncommitted— clean, no accepted/actionable findings.