[Agent] Issue #465: add an express error handler middleware #467

Open
pook wants to merge 50 commits from feat/error-handler-middleware into main
Owner

Closes #465

Changes

feat: issue #465 add-an-express-error-handler-middleware (agent task liancebot465)

Acceptance Criteria

Add an Express error handler middleware (app.use(errorHandler)) placed after all routes that: (1) In production (NODE_ENV=production), returns generic JSON { error: 'Internal server error' } with status 500, never leaking stack traces or internal details. (2) In development, includes error message and stack for debugging. (3) Logs the full error with structured logging including request path and timestamp. (4) Handles unhandled promise rejections gracefully. Acceptance: no API route can return a raw stack trace in production, all unhandled errors return consistent JSON.


Generated by CEO Planner (priority: 2)

Tokens: 38 in / 6830 out

Closes #465 ## Changes feat: issue #465 add-an-express-error-handler-middleware (agent task liancebot465) ## Acceptance Criteria Add an Express error handler middleware (app.use(errorHandler)) placed after all routes that: (1) In production (NODE_ENV=production), returns generic JSON { error: 'Internal server error' } with status 500, never leaking stack traces or internal details. (2) In development, includes error message and stack for debugging. (3) Logs the full error with structured logging including request path and timestamp. (4) Handles unhandled promise rejections gracefully. Acceptance: no API route can return a raw stack trace in production, all unhandled errors return consistent JSON. --- *Generated by CEO Planner (priority: 2)* Tokens: 38 in / 6830 out
Extracts error handling into dedicated middleware that returns generic
JSON in production (no stack traces), includes debug details in
development, logs structured JSON with path/method/timestamp, and
registers process-level handlers for unhandled rejections and
uncaught exceptions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
feat: issue #465 add-an-express-error-handler-middleware (agent task liancebot465)
Some checks failed
CI Quality Gate / Lint / Typecheck / Test / Build (pull_request) Has been cancelled
f2b66a9334
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/rate-limit.ts
  • packages/api/src/middleware/security-headers.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 feat/error-handler-middleware:feat/error-handler-middleware
git switch feat/error-handler-middleware
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!467
No description provided.