Add AI response null-safety guards in document generation service #118

Closed
opened 2026-04-08 20:23:55 -04:00 by pook · 1 comment
Owner

The document generation service parses OpenAI API responses without null checks, risking runtime crashes when the API returns unexpected shapes or empty completions.

What to implement

  1. Find the document generation service (likely src/services/generate.ts or similar)
  2. Add type guards: verify response.choices exists and is non-empty, content is a string, usage fields are numbers
  3. Return a typed error result when the AI response is malformed (not a thrown exception)
  4. Add a unit test with mock malformed responses (empty choices, null content, missing usage)

Acceptance criteria

  • Malformed AI responses produce a clear error message, not an unhandled TypeError
  • No as any casts added or remaining in the generation service
  • Unit test covers: valid response, empty choices array, null content, missing usage object
  • tsc --noEmit passes

Generated by CEO Planner (priority: 3)

The document generation service parses OpenAI API responses without null checks, risking runtime crashes when the API returns unexpected shapes or empty completions. ## What to implement 1. Find the document generation service (likely `src/services/generate.ts` or similar) 2. Add type guards: verify response.choices exists and is non-empty, content is a string, usage fields are numbers 3. Return a typed error result when the AI response is malformed (not a thrown exception) 4. Add a unit test with mock malformed responses (empty choices, null content, missing usage) ## Acceptance criteria - Malformed AI responses produce a clear error message, not an unhandled TypeError - No `as any` casts added or remaining in the generation service - Unit test covers: valid response, empty choices array, null content, missing usage object - `tsc --noEmit` passes --- *Generated by CEO Planner (priority: 3)*
Author
Owner

Bulk-closed 2026-04-10 during pipeline triage.

Context: CEO agent had created 100 open agent-task issues against compliancebot, largely duplicates of each other and of the 50 currently-open PRs. Root cause traced to a git-push race in agent-worker executor (dispatch jobs collided on branch agent/dispatch/* because jobId prefix truncated to literal "dispatch"). Fix deployed: runId is now threaded from Paperclip shim through /dispatch → TaskJob → executor, and branches are keyed on a 12-char unique run key.

What to do next:

  1. Triage the 50 open PRs at https://192.168.183.110:3000/pook/compliancebot/pulls — many are ready to merge
  2. CEO should halt new task creation until open PRs drop below 10
  3. Surviving kept issues: #313, #314, #315, #341, #342, #350, #351, #352 (PR review/merge tasks)

This issue was superseded, not abandoned. Reopen if still relevant after PR triage.

Bulk-closed 2026-04-10 during pipeline triage. **Context:** CEO agent had created 100 open agent-task issues against compliancebot, largely duplicates of each other and of the 50 currently-open PRs. Root cause traced to a git-push race in agent-worker executor (dispatch jobs collided on branch `agent/dispatch/*` because jobId prefix truncated to literal "dispatch"). Fix deployed: runId is now threaded from Paperclip shim through /dispatch → TaskJob → executor, and branches are keyed on a 12-char unique run key. **What to do next:** 1. Triage the 50 open PRs at https://192.168.183.110:3000/pook/compliancebot/pulls — many are ready to merge 2. CEO should halt new task creation until open PRs drop below 10 3. Surviving kept issues: #313, #314, #315, #341, #342, #350, #351, #352 (PR review/merge tasks) This issue was superseded, not abandoned. Reopen if still relevant after PR triage.
pook closed this issue 2026-04-10 14:48:29 -04:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pook/compliancebot#118
No description provided.