Skip to content

fix(id/web): validate world host-view and invite responses at the fetch boundary (#7833) - #8532

Merged
dezren39 merged 1 commit into
mainfrom
queue/14008-7833-world-shape
Nov 11, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/14008-7833-world-shape

Conversation

@dezren39

@dezren39 dezren39 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Fixes #7833.

The world page shape-trusted both of its HTTP responses: a wrong-shape 200 from /api/world/host-view or /api/world/invite surfaced raw engine TypeErrors, rendered bogus per-character records, or persisted a fake undefined invite capability to sessionStorage while reporting success.

What changed

  • New pkgs/id/web/src/world-http.ts with fetch-boundary validators in the id(web/image-upload): /api/upload response shape-trusted — a wrong-shape 200 inserts an image node with src undefined into the document #7823 parseUploadResponse pattern, with the server contracts in pkgs/id/src/web/world_ws.rs as the oracle:
    • parseWorldHostViewPage — body must be an object, records a plain object, records_sequence a finite number, next_after a string or null, snapshot (when present) must satisfy the same snapshot guard the WebSocket path uses, view/surface string/object-or-null. Malformed pages throw the designed "Host view unavailable" vocabulary before any state is touched.
    • parseWorldInviteResponse — body must be an object with a non-empty string capability; anything else throws through the "Invite failed" path, so showCapability is never called and nothing is written to sessionStorage. display_name falls back gracefully (null → the requested name) when absent/wrong-typed.
  • world.ts routes both fetches through the validators; no other behavior changes.

Tests (oracle: the server contracts + the issue's live-probed malformed cases)

  • world-http.test.ts (new, 19 tests): well-formed controls for both endpoints plus null / {} / array / string bodies, wrong-typed capability/records/records_sequence/next_after, and guard-failing snapshots.
  • Targeted: vitest run src/world-http.test.ts src/world-rejoin.test.ts src/world-records.test.ts src/world-contract.test.ts — 53 passed. tsc --noEmit clean.
  • Full pkgs/id web suite: 743 passed, 9 skipped, 1 failed — the failure (search-panel.test.ts role=search accessibility) reproduces identically on clean origin/main and is pre-existing, unrelated to this change.

Queue: task 14008, lane tmp-code-u.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 11, 2026 04:36
@coderabbitai

coderabbitai Bot commented Nov 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 9 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2e53ac39-0853-43f8-9714-a9fc3ee5bf9f
Commits

Reviewing files that changed from the base of the PR and between 9307e8b and d894722.

Files selected for processing: 3

  • pkgs/id/web/src/world-http.test.ts
  • pkgs/id/web/src/world-http.ts
  • pkgs/id/web/src/world.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T04:37:52.602864Z d894722 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39

Copy link
Copy Markdown
Member Author

agent-note:v1
state: salvage-check
task: 17284
lane: code-a
worker: repo-worker-code
What: Salvage check for duplicate PR #7858 (fix(id/web): validate host-view and invite response shapes, #7831), diffed against this PRs landed implementation (commit d894722, pkgs/id/web/src/world-http.ts: parseWorldHostViewPage / parseWorldInviteResponse, plus the #7908 records-frame check in world.ts). The host-view and invite shape validation in #7858 is fully covered here. ONE delta is not covered, and it conflicts rather than merely missing: #7858 requires invite display_name to be a non-empty string (its world-shape.test.ts cases: missing / empty / wrong-type all fail closed), while this PRs landed contract deliberately falls back to a null display_name when absent or wrong-typed (world-http.test.ts asserts exactly that). That is a contract decision between #7831 and #7833, not something to override inside a shepherd merge; it is recorded on #7831, which stays open for that delta. PR #7858 is being closed as superseded by this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant