Skip to content

id(world_presentation): parse_surface collapses duplicate JSON keys before its checks — a forbidden version, width, lines, or rows hidden behind a duplicate is accepted #6491

Closed

Description

@dezren39

id(world_presentation): parse_surface collapses duplicate JSON keys before its checks — a forbidden version, width, lines, or rows hidden behind a duplicate is accepted

Summary

parse_surface (pkgs/id/crates/id-core/src/world_presentation.rs:419) is the gate that decides whether a world program's view output is a valid text/1 or screen/1 presentation — the module's contract is that guests never supply terminal escapes, control characters, or unsupported versions, and every presenter (web/world_ws.rs:182, world/actor.rs:1473, world_session/mod.rs:2404, the native shell) trusts its verdict.

It parses the guest document into a serde_json::Value first (world_presentation.rs:420), dispatches on value.get("kind"), and only then converts the already-collapsed value into TextPayload / ScreenPayload (:428, :445). Duplicate JSON keys therefore collapse last-wins before any check runs: the version gate (:431, :448), the width validation in TextSurface::with_width, the control-character rejection, and the screen row/shape checks only ever see the surviving value. A document whose raw form carries a forbidden value is accepted as long as a benign duplicate follows it.

This is the same defect class as #6473 (world::parse_records) and #6474 (world_fixture::decode) in sibling guest-facing parsers; parse_surface is the remaining presentation-path instance. The in-tree tests cannot express it: they build documents via serde_json::json! values (world_presentation.rs tests, fn screen(value: Value)), which cannot represent duplicate keys.

Verified (laptop, origin/main 49797df, probe ~/git/fleet/probe-surface-dup, real id crate, 1 test passed)

Controls — each single-key invalid form is rejected:

  • {"kind":"text","version":99,"lines":["hi"]} → Err (unsupported version)
  • {"kind":"text","version":1,"width":0,"lines":["hi"]} → Err (zero width)
  • {"kind":"text","version":1,"lines":["<ESC>[31mred"]} → Err (control character)
  • {"kind":"screen","version":99,"width":2,"height":1,"rows":["hi"]} → Err
  • {"kind":"screen","version":1,"width":2,"height":1,"rows":["toolong"]} → Err

Duplicate-key forms — every one is accepted (Ok(Some(..))):

  • {"kind":"text","version":99,"version":1,"lines":["hi"]} → Text
  • {"kind":"text","version":1,"width":0,"width":80,"lines":["hi"]} → Text
  • {"kind":"text","version":1,"lines":["<ESC>[31mred"],"lines":["clean"]} → Text
  • {"kind":"screen","version":99,"version":1,"width":2,"height":1,"rows":["hi"]} → Screen
  • {"kind":"screen","version":1,"width":2,"height":1,"rows":["toolong"],"rows":["hi"]} → Screen
  • {"kind":"screen","kind":"text","version":1,"lines":["hi"]} → Text (the kind dispatch itself is last-wins)

Why it matters

Acceptance criteria

Activity

  1. developing-today commented on Nov 6, 2026

    @developing-today
    Contributor
  2. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    on Nov 6, 2026
  3. dezren39 commented on Nov 6, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

  4. dezren39 commented on Nov 6, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  5. dezren39 commented on Nov 6, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  6. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 6, 2026
  7. 75 remaining items

  8. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done — fixed and merged (task 10977, lane code-d)

  9. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done — already done (task 14983, lane code-d)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    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/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobsource/design-architectFiled by the repo design architect jobstatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions