Add Zod validation error test: POST /api/generate with invalid body returns 400 #418

Closed
opened 2026-04-10 15:04:34 -04:00 by pook · 1 comment
Owner

PR #409 implements Zod schema validation for POST /api/generate (issue #402). Add a dedicated test file tests/routes/generate-validation.test.ts:

  1. Test POST /api/generate with empty body {} — expect 400 with validation error details
  2. Test with missing required fields (e.g., no documentType) — expect 400
  3. Test with invalid documentType value (e.g., 'invalid_type') — expect 400
  4. Test with documentType present and valid (e.g., 'privacy_policy') — expect the request to proceed past validation (may still fail on auth/OpenAI but should NOT return 400)
  5. Verify error response format matches the app's standard error format

Use supertest with the Express app. Mock authentication middleware to bypass auth for these tests.

Acceptance criteria:

  • All invalid inputs return 400 with descriptive error
  • Valid input schema passes validation (may fail later for other reasons, that's OK)
  • Error response format is consistent

Generated by CEO Planner (priority: 4)

PR #409 implements Zod schema validation for POST /api/generate (issue #402). Add a dedicated test file `tests/routes/generate-validation.test.ts`: 1. Test POST /api/generate with empty body `{}` — expect 400 with validation error details 2. Test with missing required fields (e.g., no `documentType`) — expect 400 3. Test with invalid `documentType` value (e.g., 'invalid_type') — expect 400 4. Test with `documentType` present and valid (e.g., 'privacy_policy') — expect the request to proceed past validation (may still fail on auth/OpenAI but should NOT return 400) 5. Verify error response format matches the app's standard error format Use supertest with the Express app. Mock authentication middleware to bypass auth for these tests. Acceptance criteria: - All invalid inputs return 400 with descriptive error - Valid input schema passes validation (may fail later for other reasons, that's OK) - Error response format is consistent --- *Generated by CEO Planner (priority: 4)*
Author
Owner

Closed 2026-04-10 final triage pass.

Either the referenced PR is already closed (conflicts with main), or this is a worker-tail task spawned after CEO was paused. Surviving active work tracked by #350 (PR #340 webhook rate limiting) and #351 (PR #336 /generate rate limiting).

Pipeline state: 14 open PRs, CEO paused until PR review pass is complete. Shim /shim/ceo now fetches open issues/PRs and injects into prompt to prevent this duplication loop recurring.

Closed 2026-04-10 final triage pass. Either the referenced PR is already closed (conflicts with main), or this is a worker-tail task spawned after CEO was paused. Surviving active work tracked by #350 (PR #340 webhook rate limiting) and #351 (PR #336 /generate rate limiting). Pipeline state: 14 open PRs, CEO paused until PR review pass is complete. Shim `/shim/ceo` now fetches open issues/PRs and injects into prompt to prevent this duplication loop recurring.
pook closed this issue 2026-04-10 15:12:49 -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#418
No description provided.