[Agent] Issue #702: in the apigenerate route handler wrap th #705

Open
pook wants to merge 63 commits from agent-task/702 into main
Owner

Closes #702

Changes

feat: issue #702 in-the-apigenerate-route-handler-wrap-th (agent task liancebot702)

Acceptance Criteria

In the /api/generate route handler, wrap the OpenAI API call in a try/catch that handles:

  1. Timeout errors → return 504 { error: 'Generation timed out', code: 'GENERATION_TIMEOUT' }
  2. Rate limit errors (429) → return 429 { error: 'Service temporarily overloaded', code: 'RATE_LIMITED' }
  3. Invalid or empty response → return 502 { error: 'Document generation failed', code: 'AI_RESPONSE_ERROR' }
  4. Generic errors → return 500 { error: 'Internal error', code: 'INTERNAL_ERROR' }

Log errors with request context (correlation ID, user ID). Never expose OpenAI internals or prompt content to the client.


Generated by CEO Planner (priority: 3)

Tokens: 20 in / 7289 out

Closes #702 ## Changes feat: issue #702 in-the-apigenerate-route-handler-wrap-th (agent task liancebot702) ## Acceptance Criteria In the /api/generate route handler, wrap the OpenAI API call in a try/catch that handles: 1. Timeout errors → return 504 { error: 'Generation timed out', code: 'GENERATION_TIMEOUT' } 2. Rate limit errors (429) → return 429 { error: 'Service temporarily overloaded', code: 'RATE_LIMITED' } 3. Invalid or empty response → return 502 { error: 'Document generation failed', code: 'AI_RESPONSE_ERROR' } 4. Generic errors → return 500 { error: 'Internal error', code: 'INTERNAL_ERROR' } Log errors with request context (correlation ID, user ID). Never expose OpenAI internals or prompt content to the client. --- *Generated by CEO Planner (priority: 3)* Tokens: 20 in / 7289 out
feat: issue #702 in-the-apigenerate-route-handler-wrap-th (agent task liancebot702)
Some checks failed
CI Quality Gate / Lint / Typecheck / Test / Build (pull_request) Has been cancelled
05a7946145
Some checks failed
CI Quality Gate / Lint / Typecheck / Test / Build (pull_request) Has been cancelled
This pull request has changes conflicting with the target branch.
  • .forgejo/workflows/ci.yml
  • bun.lock
  • package.json
  • packages/api/src/db/schema.ts
  • packages/api/src/index.ts
  • packages/api/src/middleware/csrf.ts
  • packages/api/src/middleware/rate-limit.ts
  • packages/api/src/middleware/security-headers.ts
  • packages/api/src/routes/admin.ts
  • packages/api/src/routes/billing.ts
  • packages/api/src/routes/generate-tos.ts
  • packages/api/src/routes/generate.ts
  • packages/api/src/routes/health.ts
  • packages/api/src/routes/questionnaire.ts
  • packages/api/src/services/document-generator.ts
  • packages/api/src/services/llm.ts
  • packages/api/src/templates/index.ts
  • packages/api/tsconfig.json
  • packages/shared/src/types.ts
  • packages/web/src/app/questionnaire/page.tsx
  • packages/web/src/components/documents/DocumentList.tsx
  • packages/web/src/components/questionnaire/ReviewStep.tsx
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin agent-task/702:agent-task/702
git switch agent-task/702
Sign in to join this conversation.
No reviewers
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!705
No description provided.