GeezerVison is showing github.com — 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 · Issue #7908 · developing-today/code
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 #7908Labels app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests Descriptionid(web/world): session-WS records frame is shape-trusted — a string records renders per-character entries, a non-string next_after is echoed back as the pagination cursor
Summary
On the world page, the session WebSocket's records frame handler in
pkgs/id/web/src/world.ts trusts the frame's shape, unlike its sibling
handlers in the same receive() switch. A wrong-shape frame from the
server (stale/buggy host, middlebox, or a future server change) is not
rejected: its payload is merged and rendered as if it were the world's
records, and a malformed pagination cursor is sent straight back to the
server as the next page request.
Evidence (verified on main @ 1f5ac11)
pkgs/id/web/src/world.ts:
- The frame is accepted with a bare cast — line 199:
const frame = parsed as WorldFrame; — and the declared contract is records?: Record<string, unknown> / next_after?: string | null (lines 37–38).
- Sibling cases validate before use:
snapshot is checked with isWorldSnapshot (line 203) and event with isWorldEvent (line 223); failures go to rejectFrame() (line 176).
- The
records case (line 267) has no equivalent guard:
- line 272:
for (const [k, v] of Object.entries(frame.records ?? {})) — Object.entries on a string yields per-character entries, on an array per-index entries, on a number/boolean nothing at all.
- line 275:
recordsAfter = frame.next_after ?? null; — any non-null value, whatever its type, becomes the cursor, and lines 286–293 send it back verbatim as after in the next records request.
Reproduction (probe on the laptop, ~/git/fleet/probe-records-ws-frame-20261108,
real world.ts driven through the same FakeWebSocket harness as
world-records.test.ts; probe copy byte-identical to main, 6/6 tests pass —
the BUG cases assert the current wrong behavior):
- Control:
{type:"records", records:{a1:1}, next_after:null} renders {a1: 1} and terminates the fetch. ✔
records: "abc" → renders {"0":"a","1":"b","2":"c"} — per-character junk presented as world records.
records: [10, 20] → renders {"0":10,"1":20}.
records: 42 → the fetch silently completes rendering {} — the world's records look empty.
next_after: 123 → the client sends the follow-up page request with after: 123 (a number, not a string).
next_after: {k: 1} → the client sends after: {"k": 1} verbatim.
Existing tests do not cover this: pkgs/id/web/src/world-records.test.ts
covers the #1458 pagination coalescing and the #2953 __proto__
define-semantics, but every delivered frame has a well-shaped records
object and a string/null next_after. The baseline suite is green
(6/6 in the probe).
Why it matters
The records panel is how a participant reads the world's published
state. A single wrong-shape frame currently (a) fabricates records that
do not exist (per-character/per-index entries), (b) silently reports an
empty world for scalar payloads, and (c) corrupts the pagination
protocol by echoing a non-string cursor the server never issued —
against a server that treats an unknown cursor as a first page, that
also re-merges page one and can keep the fetch alive past the page the
server meant to end it on. The snapshot/event cases in the same switch
already show the house pattern: validate, and rejectFrame() on a
mismatch instead of rendering it.
Related but distinct: #7833 covers the REST /api/world/host-view
path in the same file (refreshHostView, a different function and
transport); this issue is the session-WebSocket records frame in
receive(). A fixer may reasonably handle both in one pass. The
Rust-side cursor-shape fixes (#6615, #6778, #6600) and open #6578 cover
server-side readers, not this browser handler.
Acceptance criteria
Activityadded 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, 2026developing-today commented on Nov 9, 2026 ContributorAuthor More actions dezren39 commented on Nov 11, 2026 agent-note:v1
lane: code-j
task: 14271
issue: #7908
state: triaged
note: Inline triage by lane code-j (runbook section 1c): work kind task/small-fix, priority/normal, effort/s, kind/bug - all already labelled and confirmed against the issue body (session-WS records frame in pkgs/id/web/src/world.ts shape-trusted, unlike the guarded snapshot/event sibling cases). Removed status/needs-triage; claim labels synced. First concrete step: add an isWorldRecords-style guard beside isWorldSnapshot/isWorldEvent - records must be a plain object and next_after a string or null/undefined - routing failures to the existing rejectFrame() path. Acceptance check: wrong-shape frames change no rendered records or fetch state and a non-string cursor is never echoed; existing world-records tests stay green; new tests pin string/array/numeric records and numeric/object next_after rejection. Continuing to the fix in this same session. dezren39 commented on Nov 11, 2026 agent-note:v1
lane: code-j
task: 14271
issue: #7908
stage: parked
note: Task 14271 parked as CI wait on PR #8510. Triaged inline and fixed in the same session by lane code-j: isWorldRecordsFrame guard in pkgs/id/web/src/world.ts validates the session-WS records frame (plain-object records, string-or-null next_after) with failures routed to rejectFrame(), matching the snapshot/event siblings; new world-records test pins string/array/numeric/boolean records and numeric/object next_after rejection. Tests: world-records 7/7 pass, typecheck clean, full web suite 712 pass with the single pre-existing search-panel failure (proven on clean main). Resume: PR #8510 checks green + Codex clean, then merge (closes this issue). dezren39 commented on Nov 11, 2026 🤖 Agent note · done — wrong-shape records frames rejected; PR #8649 merged, issue closed
MetadataMetadataapp/idPackage/app: id (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests DevelopmentNo branches or pull requestsIssue actions
|