Toggling a working factory view can trigger at least two different bugs.
1. Displays diagram in the visualization container; error in console
Run codeassembly/87:
- diagram displays
- error is seen in console:
run-to-flow.ts:260 Uncaught TypeError: Cannot read properties of undefined (reading 'orchestrated-reviewer')
at buildReviewerNodes (run-to-flow.ts:260:48)
at createFlowConfig (run-to-flow.ts:666:25)
at FlowDiagram.tsx:61:32
at FlowDiagramInner (FlowDiagram.tsx:61:18)
2. Displays nothing in the visualization container; error in console
Example: codeassembly/CODY-113
run-to-flow.ts:260 Uncaught TypeError: Cannot read properties of undefined (reading 'orchestrated-reviewer')
at buildReviewerNodes (run-to-flow.ts:260:48)
at createFlowConfig (run-to-flow.ts:666:25)
at FlowDiagram.tsx:61:32
at FlowDiagramInner (FlowDiagram.tsx:61:18)
Root cause
extractReviewerNames() in run-to-flow.ts correctly handles three data shapes for reviewer names (flat reviewers record, iterations[].perReviewer, and reviewerDetails). However, four downstream access sites assume parallelReview.reviewers is always a defined object. For V2 run data, the Zod .partial().loose() schema doesn't enforce the reviewers field, so it can be undefined at runtime despite the TypeScript type declaring it as required.
Affected access sites (all in run-to-flow.ts):
- Line 260 in
buildReviewerNodes — primary crash location
- Line 286 in
resolveReviewerStatus
- Line 524 in
buildReviewerEdges
- Line 572 in
buildReviewerEdges (re-review section)
Proposed solution
Add optional chaining (?.) at all 4 access sites. All downstream uses of the resulting reviewerInfo already handle undefined via optional chaining or explicit checks.
Acceptance criteria
Toggling a working factory view can trigger at least two different bugs.
1. Displays diagram in the visualization container; error in console
Run codeassembly/87:
2. Displays nothing in the visualization container; error in console
Example: codeassembly/CODY-113
Root cause
extractReviewerNames()inrun-to-flow.tscorrectly handles three data shapes for reviewer names (flatreviewersrecord,iterations[].perReviewer, andreviewerDetails). However, four downstream access sites assumeparallelReview.reviewersis always a defined object. For V2 run data, the Zod.partial().loose()schema doesn't enforce thereviewersfield, so it can beundefinedat runtime despite the TypeScript type declaring it as required.Affected access sites (all in
run-to-flow.ts):buildReviewerNodes— primary crash locationresolveReviewerStatusbuildReviewerEdgesbuildReviewerEdges(re-review section)Proposed solution
Add optional chaining (
?.) at all 4 access sites. All downstream uses of the resultingreviewerInfoalready handleundefinedvia optional chaining or explicit checks.Acceptance criteria
parallelReview.reviewersis absentidlestatus) when reviewer info is unavailableiterations[].perReviewerandreviewerDetailspaths withreviewersundefined