Skip to content

fix(dashboard): render a packet whose links object omits some arrays - #163

Merged
phodal merged 1 commit into
QoderAI:mainfrom
ttsdj:fix/task-evidence-partial-links
Sep 10, 2026
Merged

phodal merged 1 commit into
QoderAI:mainfrom
ttsdj:fix/task-evidence-partial-links

Conversation

@ttsdj

@ttsdj ttsdj commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

What

buildDashboardModel fell back to a default links only when the whole object was absent. A packet whose links is present but omits sessionRefs or artifactRefs therefore reached links.artifactRefs.length and threw:

TypeError: Cannot read properties of undefined (reading 'length')
 ❯ lib/dashboard-model.ts:342:32

The throw happens while building the model, so one such packet takes down the entire Dashboard render rather than degrading a single panel.

Why the shape is reachable

validateTaskEvidencePacket admits it. At scripts/task-evidence-upload/contract.mjs:492-495 the packet validator calls normalizeLinks, but normalizeLinks builds its key list with { optional: [...] } and no required, so a links object containing only some of the arrays passes validation. The call's result is discarded, so nothing materializes the missing arrays either. createTaskEvidencePacket always writes all three, but the read path does not require them.

The regression test asserts that acceptance explicitly, so the precondition is pinned rather than assumed.

The change

Default each array and let any supplied value win, which also keeps an optional projectRef flowing through as before. One production file.

Validation

  • New test a stored packet with a partial links object does not break the Dashboard projection — reports the TypeError above before the change.
  • packages/harness-ui: tsc --noEmit exit 0; full vitest suite 58/58 passed, exit 0.

`buildDashboardModel` fell back to a default `links` only when the whole
object was absent. A packet whose `links` is present but omits `sessionRefs`
or `artifactRefs` therefore reached `links.artifactRefs.length` and threw,
taking down the entire Dashboard render instead of a single panel.

The shape is reachable: `validateTaskEvidencePacket` builds its `links` key
list without a `required` set and discards what `normalizeLinks` returns, so
a partial `links` object passes validation.

Default each array and let any supplied value win, which keeps an optional
`projectRef` flowing through as before.

Validated with the harness-ui typecheck and its full 58-test suite; the new
test reports the TypeError before the change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is small, targeted to the reported crash, and includes a regression test that exercises the previously failing input shape.

Pull request overview

This PR hardens the Dashboard projection against task-evidence packets whose links object is present but omits one or more of the expected reference arrays, preventing a runtime TypeError during model construction and keeping the Dashboard render resilient.

Changes:

  • Default sessionRefs, commitRefs, and artifactRefs individually when building the Dashboard model, while preserving any provided links values.
  • Add a regression test ensuring a stored packet with a partial links object projects successfully and yields empty arrays for missing link fields.
File summaries
File Description
packages/harness-ui/lib/dashboard-model.ts Makes links.*Refs safe to dereference by defaulting missing arrays when projecting evidence deliveries.
packages/harness-ui/test/dashboard-model.test.mjs Adds a regression test covering the partial-links packet shape and asserting the projected links arrays are always present.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@phodal
phodal merged commit 26beecc into QoderAI:main Sep 10, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants