Skip to content

[Type Safety][Warning] JSON.parse results used without Zod validation in dashboard SSE handlers #1107

@OneStepAt4time

Description

@OneStepAt4time

Summary

Multiple dashboard components parse SSE/WebSocket data via JSON.parse(e.data) and then directly cast the result to typed interfaces without runtime validation:

  1. TranscriptViewer.tsx:72-76const data: ParsedEntry = raw.data (annotation, not validation)
  2. TerminalPassthrough.tsx:105-107 — same pattern
  3. resilient-websocket.ts:66JSON.parse(event.data as string) passed directly to callbacks

Meanwhile, useSessionPolling.ts:182 correctly uses SessionSSEEventDataSchema.safeParse().

Files Affected

  • dashboard/src/components/session/TranscriptViewer.tsx:72-76
  • dashboard/src/components/session/TerminalPassthrough.tsx:105-107
  • dashboard/src/api/resilient-websocket.ts:66

Suggested Fix

Use the existing SessionSSEEventDataSchema.safeParse() pattern in all SSE/WebSocket message handlers, matching the approach already used in useSessionPolling.ts.


Code review finding from full codebase audit (2026-04-04)

Metadata

Metadata

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions