Skip to content

feat: standardise backend error responses to RFC 7807#269

Open
Robinsonchiziterem wants to merge 1 commit intoCalebux:mainfrom
Robinsonchiziterem:feature/rfc-7807-error-standardization
Open

feat: standardise backend error responses to RFC 7807#269
Robinsonchiziterem wants to merge 1 commit intoCalebux:mainfrom
Robinsonchiziterem:feature/rfc-7807-error-standardization

Conversation

@Robinsonchiziterem
Copy link
Copy Markdown

PR #172 Add standardized error response format (RFC 7807 Problem Details) across all backend routes

Description

This PR completely standardizes the SYNCRO backend and SDK error responses around the RFC 7807 Problem Details specification for HTTP APIs.

Key changes include:

  • Error Infrastructure: Established a robust AppError base class hierarchy (NotFoundError, ValidationError, ConflictError, ForbiddenError, etc.).
  • Global Error Handling: Implemented a global Express error-handling middleware that intercepts thrown errors and formats them into standardized, predictable JSON shapes, while safely masking internal stack traces in production.
  • Route Refactoring: Refactored the Zod validation interceptor (validateRequest) and migrated all backend routes (subscriptions, merchants, team, api-keys, audit, etc.) to throw semantic errors natively instead of relying on legacy, disparate res.status().json(...) blocks.
  • Documentation: Updated Swagger/OpenAPI documentation to broadcast the new standardized error schema.
  • SDK Updates: Synchronized the SYNCRO SDK (sdk/src/index.ts and sdk/src/errors.ts) to natively parse, extract, and re-throw these RFC 7807 HTTP errors for clean client-side consumption.

Related Issue

Closes #172


Test Plan

  • Tested locally (Route and SDK TypeScript type-checking validated)
  • Verified expected behavior (SDK correctly unwraps Zod validation records from detail or extensions)
  • No regressions introduced (Note: global test suite and tsc are currently failing on main within src/services/ due to broken upstream merges from PR Fix/137 event listener health retry #260, which blocks full end-to-end regression validation)

Screenshots (if applicable)

N/A


Checklist

  • Code builds successfully (Currently blocked by pre-existing upstream service layer corruption in main)
  • Tests pass (Currently blocked by pre-existing upstream service layer corruption in main)
  • Follows project conventions
  • No sensitive data exposed

Closes #172

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 30, 2026

@Robinsonchiziterem 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

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.

Add standardized error response format (RFC 7807 Problem Details) across all backend routes

1 participant