Skip to content

id(web/home): home feed refresh shape-trusts /api/home/feed — a wrong-shape 200 wipes the rendered lists and surfaces raw TypeErrors #7811

Closed

Description

@developing-today

Problem

id(web/home): the home feed refresh shape-trusts the /api/home/feed response — a wrong-shape 200 response wipes the already-rendered home lists and leaves raw engine errors / bogus rows in place of the feed.

pkgs/id/web/src/home.ts:

  • :105 — const feed = (await response.json()) as HomeFeed; is a bare cast; the result is dereferenced unvalidated at :107-110 (feed.recent, feed.popular, feed.recent_tags, feed.popular_tags, feed.scope).
  • :28 / :55 — both renderers (renderList, renderTagList) call list.replaceChildren() FIRST and only then read documents.length / iterate, so a malformed payload destroys the previously rendered (good) list before it throws.
  • :114 — the catch surfaces the raw exception text (error.message) as the status line, so a shape failure shows e.g. "null is not an object (evaluating 'tags.length')" to the user instead of a clean unavailable message.

Evidence (verified this run, laptop @ main 3bf18dc, home.ts md5 b3b0b3734c290dec5be5053834a871f4)

Probe ~/git/fleet/probe-home-feed/probe.ts (bun, minimal DOM stub, real module imported from the laptop tree):

  • control (well-formed tag list): renders OK — topic:rust — 4 documents
  • renderTagList(list, null): THROW TypeError: null is not an object (evaluating 'tags.length') — list children after throw = 0 (previous good row wiped)
  • renderTagList(list, {}): THROW TypeError: {} is not iterable — list wiped
  • renderTagList(list, [null]): THROW TypeError ... (evaluating 'tag.subject') — list wiped
  • renderTagList(list, [valid, null]): THROW on the second element — list left half-rendered (1 new row, previous content gone)
  • renderTagList(list, "abc"): no throw — silently renders 3 bogus rows: undefined — undefined documents ×3

renderList (documents) shares the same wipe-first shape (:28 then documents.length), and a null feed body throws at feed.recent itself. The refresh polls every 15s (home.ts poll loop), so one bad response (deploy skew, an error envelope returned with 200, a future server field change) blanks the home page's lists until a well-formed response arrives, with a raw TypeError as the only explanation.

The existing test file (pkgs/id/web/src/home.test.ts) covers only well-formed renderTagList inputs (XSS text rendering, occurrence counts) — no malformed-shape cases.

Why it matters

The home page is id's front door. Every other feed consumer in this repo that was audited in this class (projector, aggregator, atlas worker) validates the shape at the boundary before touching state; the home refresh instead mutates the DOM first and validates never. Failing closed here is cheap: keep the last good render and show the designed unavailable message.

Acceptance criteria

  • A malformed feed payload (null body, non-object body, missing/non-array recent/popular/recent_tags/popular_tags, null or wrong-typed elements/fields) does NOT clear or partially replace the currently rendered lists.
  • A malformed payload surfaces a clean user-facing message (e.g. "Feed is temporarily unavailable.") — never a raw TypeError/engine message.
  • Well-formed feeds render exactly as today (existing home.test.ts cases unchanged and green).
  • New regression tests in pkgs/id/web/src/home.test.ts cover the malformed cases above and fail pre-fix.
  • Web suite + typecheck green.

Activity

  1. 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
    source/creatorFiled by the new-issue-creator job
    priority/lowNice to have; do when convenient
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    effort/sSmall: expected under 2 hours of work
    on Nov 8, 2026
  2. developing-today commented on Nov 8, 2026

    @developing-today
    ContributorAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator job (new-issue-creator-code-a)
    • Session / ID: cron job new-issue-creator-code-a, run 2026-11-08T20:35Z
    • Found via: filed this run
    • Task: Validate the /api/home/feed response shape before rendering, so a wrong-shape 200 cannot wipe the home lists or surface raw TypeErrors; add regression tests in home.test.ts.
    • Expectation: effort s — done when issue id(web/home): home feed refresh shape-trusts /api/home/feed — a wrong-shape 200 wipes the rendered lists and surfaces raw TypeErrors #7811's acceptance criteria pass (malformed payloads keep the last good render and show a clean message; web suite + typecheck green)
    • Links: probe ~/git/fleet/probe-home-feed (laptop); enqueued to queue repo-health-code-pilot as a small-fix packet
  3. developing-today commented on Nov 8, 2026

    @developing-today
    ContributorAuthor

    🤖 Agent note · handed off

  4. added
    work/assignedQueue worker lifecycle state
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed on Nov 8, 2026
  5. 26 remaining items

  6. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Nov 9, 2026
  7. developing-today commented on Nov 9, 2026

    @developing-today
    ContributorAuthor

    🤖 Agent note · handed off

  8. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    queue/claimedQueue worker lifecycle state
    on Nov 9, 2026
  9. developing-today commented on Nov 9, 2026

    @developing-today
    ContributorAuthor

    🤖 Agent note · handed off

  10. developing-today commented on Nov 9, 2026

    @developing-today
    ContributorAuthor

    🤖 Agent note · handed off

  11. added a commit that references this issue on Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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 convenientqueue/parkedQueue task is parked (waiting on CI, time, or an event)source/creatorFiled by the new-issue-creator jobstatus/parkedDeliberately paused with a recorded resume conditiontask/small-fixQueue packet kind: bounded fix with reproduction and targeted testswork/assignedQueue worker lifecycle state

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions