GeezerVison is showing github.com — id(web/world): session-WS invite, view and error frames shape-trusted — a non-string invite capability is persisted as '[object Object]', non-string view/error text renders coerced · Issue #7924 · developing-today/code
id(web/world): session-WS invite, view and error frames shape-trusted — a non-string invite capability is persisted as '[object Object]', non-string view/error text renders coerced #7924Descriptionid(web/world): session-WS invite, view and error frames shape-trusted — a non-string invite capability is persisted as '[object Object]', non-string view/error text renders coerced
Summary
On the world page, three of the remaining session-WebSocket frame handlers in
pkgs/id/web/src/world.ts receive() trust the frame's shape, unlike their
sibling handlers in the same switch. A wrong-shape frame from the server
(stale/buggy host, middlebox, or a future server change) is not rejected: a
non-string invite capability is adopted, coerced, and persisted to
sessionStorage as the session capability, and non-string view data /
error messages are rendered as their coerced string form
('[object Object]') instead of the frame being rejected.
Evidence (verified on main @ 30bd3a1; world.ts unchanged from a97c23c)
pkgs/id/web/src/world.ts:
- The frame is accepted with a bare cast —
const frame = parsed as WorldFrame;
(receive(), ~line 199) — with the declared contract invite?: { capability?: string; … },
data?: string, view_revision?: number, message?: string (~lines 24–44).
- Sibling cases validate before use:
snapshot is checked with
isWorldSnapshot, event with isWorldEvent, and the records case was
filed separately as id(web/world): session-WS records frame shape-trusted — a string records renders per-character entries, a non-string next_after is echoed back as the pagination cursor #7908; failures go to rejectFrame(). The upload
socket in the same file validates chunk_bytes (integer, 1..6144) before use.
- The
invite case (~lines 297–305) has no equivalent guard:
const invite = frame.invite ?? frame; if (invite.capability) { showCapability(invite.capability); … }
— any truthy value is passed to showCapability (~lines 180–185), which does
capability.value = value; sessionStorage.setItem(storageKey, value); and
unhides the invite output. An object capability is stored as the literal
string '[object Object]', a numeric one as '12345', and the status still
reports “Invite ready to share” — the bogus value is then the capability the
page rehydrates from sessionStorage and offers to copy/share.
- The
view case (~lines 237–266): the surface path is guarded by
renderWorldSurface, and the patch path checks
typeof frame.view_revision === "number", but the fallback
if (frame.data !== undefined) { view.textContent = frame.data; renderedViewRevision = frame.view_revision ?? null; }
accepts any type: an object data renders as '[object Object]', and a
non-number view_revision is stored verbatim as the rendered revision,
after which patch base-revision comparisons can never match it.
- The
error case (~lines 306–310): setStatus(frame.message ?? "World request failed", "error")
and the log line accept any type; an object message is displayed as
'[object Object]' instead of a real error or a rejected frame.
Reproduction (probe on the laptop, ~/git/fleet/probe-world-frames-20261108,
real world.ts driven through the same FakeWebSocket harness as
world-records.test.ts; probe copy byte-identical to main; 6/6 probe tests
pass — the malformed cases assert the current wrong behavior — and the
baseline world-records.test.ts suite is 6/6 green):
- Control:
{type:"invite", invite:{capability:"cap-valid-123", display_name:"bob"}}
→ sessionStorage stores cap-valid-123, status “Invite ready to share”. ✔
{type:"invite", invite:{capability:{forged:true}, display_name:"bob"}}
→ sessionStorage stores '[object Object]', status still “Invite ready to share”.
{type:"invite", invite:{capability:12345, display_name:"bob"}}
→ sessionStorage stores '12345', status still “Invite ready to share”.
{type:"view", data:{not:"text"}, view_revision:"7"} → the world view
renders '[object Object]' (and the string revision is stored).
{type:"error", message:{code:42}} → the status line shows '[object Object]'.
- Control:
{type:"error", message:"world is full"} → shown verbatim. ✔
Existing tests do not cover this: the world suites
(world-records.test.ts, world-rejoin.test.ts, world-surface.test.ts, …)
deliver only well-shaped invite/view/error frames, if any.
Why it matters
The invite capability is a credential-like value: it is persisted in
sessionStorage, rehydrated on the next load, pre-fills the capability field
the user joins with, and is what the copy button shares. A single
wrong-shape frame silently replaces a valid capability with
'[object Object]' / a coerced number and reports success — the user then
joins (or shares an invite) with a capability the server never issued, and
the failure surfaces later, elsewhere, with no trace back to the bad frame.
The view/error coercions are the same defect class at display severity:
bogus rendered state and useless error text instead of the house pattern —
validate, and rejectFrame() on a mismatch — that the snapshot/event cases
in the same switch already follow.
Related but distinct: #7908 covers the session-WS records frame in the
same receive(); #7833/#7831 cover the REST /api/world/host-view and
/api/world/invite HTTP responses in the same file (different functions and
transport — this issue is the WebSocket invite frame, not the HTTP invite
response). A fixer may reasonably handle them in one pass.
Acceptance criteria
- An
invite frame whose effective capability (nested invite object or top-level) is present but not a string is rejected (e.g. via the existing rejectFrame() path): nothing is written to sessionStorage or the capability field, the invite output is not shown, and “Invite ready to share” is not reported. A missing capability stays a no-op as today.
- A
view frame whose data is present but not a string is rejected the same way and does not change the rendered view; a non-number view_revision is never stored as the rendered revision.
- An
error frame whose message is present but not a string is rejected (or falls back to the default message) — a coerced '[object Object]' is never displayed as the status or log line.
- Well-formed frames behave exactly as today: valid invite capabilities are stored and reported, string view data renders, string error messages show verbatim, and the existing world suites stay green.
- New tests deliver object/numeric invite capabilities, object view
data, a string view_revision, and an object error message, and pin the rejection.
Activitydeveloping-today commented on Nov 9, 2026 added kind/bugSomething isn't working (prefixed form of the classic bug label) task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests app/idPackage/app: id (pkgs/ or apps/ in this repo) effort/sSmall: expected under 2 hours of work on Nov 9, 2026dezren39 commented on Nov 9, 2026 🤖 Agent note · filed
- Agent: new-issue-creator job (lane A, slug
new-issue-creator-code-a)
- Session / ID: cron job new-issue-creator-code-a, run 2026-11-08 20:05 CST
- Found via: filed this run
- Task: Validate the session-WS
invite, view and error frame shapes in pkgs/id/web/src/world.ts receive() — reject a non-string invite capability / view data / error message instead of persisting or rendering their coerced forms.
- Expectation: effort/s — done when the acceptance criteria in the issue body pass and the existing world web suites stay green.
- Links: verification probe on the laptop at
~/git/fleet/probe-world-frames-20261108 (real world.ts, byte-identical to main @ 30bd3a1; 6/6 probe tests pass asserting the current wrong behavior; baseline world-records.test.ts 6/6 green). Related, distinct: issue id(web/world): session-WS records frame shape-trusted — a string records renders per-character entries, a non-string next_after is echoed back as the pagination cursor #7908 (session-WS records frame, same switch), issues id(web/world): /api/world/host-view and /api/world/invite responses shape-trusted — a wrong-shape 200 shows raw TypeErrors, renders bogus per-character records, or persists a fake 'undefined' invite capability #7833/id(web/world): /api/world/host-view and /api/world/invite responses shape-trusted — a wrong-shape 200 shows raw TypeErrors or stores a fake 'undefined' capability #7831 (REST host-view/invite responses, different transport).
dezren39 commented on Nov 11, 2026 🤖 Agent note · parked — awaiting triage
dezren39 commented on Nov 11, 2026 agent-note:v1
state: parked
task: 14284
lane: tmp-code-v
PR #8536 opened @cf3b0466b3 (branch queue/14284-7924-world-frame-guards): invite/view/error frame guards in pkgs/id/web/src/world.ts + new pkgs/id/web/src/world-frames.test.ts.
Tests: new suite 5/5 post-fix (4/5 fail pre-fix), all 9 world suites 81/81 on laptop, tsc clean.
Parked: CI checks QUEUED on PR #8536 (fleet CI stall) and Codex review running with no findings yet. Resume: when checks complete, disposition any Codex findings, merge on green, complete task 14284 as fixed_merged. dezren39 commented on Nov 11, 2026 agent-note:v1
state: done
task: 14284
lane: any-b
summary: PR #8536 merged (squash, merge commit 6219b31); issue #7924 auto-closed. On resume, Codex had one unresolved P1 on the original head (property-based coverage for frame-shape invariants): fixed in 70e8aaa with a fixed-seed generated-shape property test (240 frames, explicit acceptance oracle, state-preservation assertions, coverage guards for the display_name and base_view_revision branches); vitest world-frames 6 passed. Codex re-review on 70e8aaa completed with no findings.
next: none for task 14284
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|