Skip to content

feat(errors): enforce safe API error policy#316

Merged
mikewheeleer merged 1 commit into
Talenttrust:mainfrom
Jayking40:#273-Enforce-safe-error-message-policy-on-all-API-routes-via-errorMessagePolicy
Jun 2, 2026
Merged

feat(errors): enforce safe API error policy#316
mikewheeleer merged 1 commit into
Talenttrust:mainfrom
Jayking40:#273-Enforce-safe-error-message-policy-on-all-API-routes-via-errorMessagePolicy

Conversation

@Jayking40

Copy link
Copy Markdown
Contributor

Enforce Safe API Error Responses

Summary

This PR centralizes API error serialization so internal exception details are not returned to clients. All terminal Express errors are mapped through the safe error message policy, with request IDs included for support correlation and redacted structured logs retained for diagnostics.

Changes

  • Added centralized terminal error handling for unknown errors, application errors, malformed JSON, and validation failures
  • Ensured request IDs are available even when JSON parsing fails
  • Fixed terminal handler registration order so all API routes are protected by the final error middleware
  • Replaced caught internal error responses in job and DLQ flows with policy-managed errors
  • Added integration coverage for unknown errors, application errors, validation errors, malformed JSON, and 404 responses
  • Documented the standardized safe error response envelope and status/code mappings

Testing

  • npx jest --runTestsByPath src/errors/errorMessagePolicy.integration.test.ts src/errors/appError.test.ts src/errors/safeErrors.test.ts --runInBand --silent
  • npx eslint src/app.ts src/index.ts src/errors/appError.ts src/errors/errorMessagePolicy.integration.test.ts src/middleware/errorHandlers.ts src/logger.ts

Note: full build/lint is currently blocked by an unrelated pre-existing syntax error in src/webhookDelivery.ts.

Closes #273

@drips-wave

drips-wave Bot commented Jun 1, 2026

Copy link
Copy Markdown

@Jayking40 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@mikewheeleer mikewheeleer merged commit 3fbd74f into Talenttrust:main Jun 2, 2026
2 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enforce safe-error message policy on all API routes via errorMessagePolicy

2 participants