Title: id(web): world WebSocket receive() trusts frame shape past the type tag — a parseable-but-wrong-shaped snapshot/event throws out of the handler and is dropped mid-processing · Issue #2802 · developing-today/code · GitHub
Open Graph Title: id(web): world WebSocket receive() trusts frame shape past the type tag — a parseable-but-wrong-shaped snapshot/event throws out of the handler and is dropped mid-processing · Issue #2802 · developing-today/code
X Title: id(web): world WebSocket receive() trusts frame shape past the type tag — a parseable-but-wrong-shaped snapshot/event throws out of the handler and is dropped mid-processing · Issue #2802 · developing-today/code
Description: id(web): world WebSocket receive() trusts frame shape past the type tag — a parseable-but-wrong-shaped snapshot/event throws out of the handler and the frame is dropped mid-processing Repo: developing-today/code · Main: c90fcbc7 · File: ...
Open Graph Description: id(web): world WebSocket receive() trusts frame shape past the type tag — a parseable-but-wrong-shaped snapshot/event throws out of the handler and the frame is dropped mid-processing Repo: develop...
X Description: id(web): world WebSocket receive() trusts frame shape past the type tag — a parseable-but-wrong-shaped snapshot/event throws out of the handler and the frame is dropped mid-processing Repo: develop...
Opengraph URL: https://github.com/developing-today/code/issues/2802
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"id(web): world WebSocket receive() trusts frame shape past the type tag — a parseable-but-wrong-shaped snapshot/event throws out of the handler and is dropped mid-processing","articleBody":"# id(web): world WebSocket `receive()` trusts frame shape past the type tag — a parseable-but-wrong-shaped snapshot/event throws out of the handler and the frame is dropped mid-processing\n\n**Repo:** developing-today/code · **Main:** `c90fcbc7` · **File:** `pkgs/id/web/src/world.ts` — `receive()` at lines 138–225, dispatched from the socket message handler at line 316–319.\n\n## Evidence (verified this run, real module)\n\n`receive()` guards only `JSON.parse` (lines 140–145). Every case after the `frame.type` switch then dereferences nested fields as if the shape were guaranteed:\n\n- `snapshot` (line 148–150): `cursor = frame.snapshot.current_sequence;` then `for (const participant of frame.snapshot.participants)`. The only guard is `if (!frame.snapshot) return;` — a snapshot object without `participants` throws.\n- `event` (line 164–166): `if (!event) return;` then `event.kind.kind` — an event object without `kind` throws.\n- Secondary: `cursor` is assigned `frame.snapshot.current_sequence` and `Math.max(cursor, event.sequence)` with no finiteness/shape check, so a missing/non-numeric sequence poisons `cursor` with `undefined`/`NaN` for the rest of the session (it feeds the rejoin `after:` cursor).\n\nLaptop probe (worktree of `c90fcbc7`, vitest + happy-dom, reusing the `world-records.test.ts` FakeSocket harness and the real template markup; probe retained at `~/git/fleet/probe-2026-10-30-laneA-worldframe/`, `world.ts` md5 `e24c51db39ebed2505a4bdad1df7f8c4`, matching main):\n\n- Deliver `{\"type\":\"snapshot\",\"snapshot\":{\"world_id\":\"lobby\",\"current_sequence\":9}}` → **TypeError: frame.snapshot.participants is not iterable** at `src/world.ts:150`, thrown out of `receive()` (world.ts:318 dispatch). The handler aborts before the participants are rendered, before `setStatus(\"Connected\")`, and before `requestRecords()` — zero records requests were sent.\n- Deliver `{\"type\":\"event\",\"event\":{\"sequence\":5,\"participant_id\":1}}` → **TypeError: Cannot read properties of undefined (reading 'kind')** at `src/world.ts:166`.\n- Control: the well-formed snapshot from `world-records.test.ts` connects and starts the records fetch exactly as the existing tests expect (probe control test passed).\n\nIn a real browser the listener exception surfaces as an uncaught error and that frame's processing simply stops halfway — the user is left on a world page that never shows \"Connected\" and never loads records, with no error status explaining why (the parse-failure path at line 143 does set an \"invalid world frame\" status; the shape-failure path sets nothing).\n\n## Why it matters\n\nWorld frames originate from the world host / Roc world app, not from this client — the same untrusted-shape boundary the codebase already defends elsewhere (`shell-contract.ts` validates shell frames field-by-field; `#2738`/`#2800` cover the same parseable-but-wrong-shaped class in other tools). One buggy or experimental world app that emits a snapshot before its participant list exists (or an event kind variant this client predates) wedges every connected client's world page silently, instead of producing one clear \"invalid frame\" status. The `cursor` poisoning variant can additionally corrupt the rejoin position for the rest of the session.\n\n## Acceptance criteria\n\n- [ ] A snapshot frame whose `participants` is missing or not an array does not throw out of `receive()`; the frame is rejected (or the field defaulted) with a visible error status consistent with the existing invalid-frame path, and a subsequent well-formed snapshot still connects and starts the records fetch.\n- [ ] An event frame whose `kind` is missing or not an object does not throw; same rejection/status behaviour, and subsequent well-formed events still process.\n- [ ] `cursor` never becomes `undefined`/`NaN` from a frame: a snapshot/event with a missing or non-numeric sequence leaves the previous cursor intact.\n- [ ] Regression tests in the style of `world-records.test.ts` (FakeSocket harness) pin all three cases plus the well-formed control; existing web tests still pass (`bunx vitest run` in `pkgs/id/web`).\n- [ ] Well-formed frame handling is byte-for-byte unchanged (snapshot/event/view/records/invite/error paths).\n\nDedup notes: searched open + closed issues this run for world frame / snapshot / participants / receive — no hit. Distinct from #2747/#2748 (aggregator path-segment decoding) and from the wrong-shape filings in other tools (#2738 t3code seed settings, #2800 sync_research_workflow); this is the id world client's own frame boundary. The validation *shape* (per-case guards vs a frame-shape check at the top of `receive()`) is triage's pin — not self-solved.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-30T19:14:57Z","url":"https://github.com/developing-today/code/issues/2802"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3335fff8-873b-1030-0f50-bde67bbe2efb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8292:130DD7:4629B8:5D8D09:6B061E7A |
| html-safe-nonce | c35f264e041aeca66da62f825e7cfc0e578f0e80d2ac0b3279565e9c91bc534c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MjkyOjEzMERENzo0NjI5Qjg6NUQ4RDA5OjZCMDYxRTdBIiwidmlzaXRvcl9pZCI6IjU3NTA2MTI4MjkxNjIzMTUzODYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | bc12412531b5bb0bff3c326b9186f3f26f5ef9e467ec7c07160c65a0bd4f9245 |
| hovercard-subject-tag | issue:6125488462 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/2802/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fffeaa2dfe6e729f3b1c4c7fee68352e8bc9815e401bc5f79604e92b0268146b/developing-today/code/issues/2802 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fffeaa2dfe6e729f3b1c4c7fee68352e8bc9815e401bc5f79604e92b0268146b/developing-today/code/issues/2802 |
| og:image:alt | id(web): world WebSocket receive() trusts frame shape past the type tag — a parseable-but-wrong-shaped snapshot/event throws out of the handler and the frame is dropped mid-processing Repo: develop... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9a7c5824b75ea2ec5e3de73a483229c7bb9f32a774ffd401f010dd9bacf1483d |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b25c3080e84402f75431d8dc7a96b2635219cec7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width