Skip to content

fix: standardize error response format to { message } across all endpoints#183

Open
jakebromberg wants to merge 3 commits intomainfrom
fix/26-error-format-consistency
Open

fix: standardize error response format to { message } across all endpoints#183
jakebromberg wants to merge 3 commits intomainfrom
fix/26-error-format-consistency

Conversation

@jakebromberg
Copy link
Member

Summary

  • errorHandler.ts: Non-WxycError errors no longer leak raw error.message to clients — they now return { message: 'Internal server error' } and log the real error via console.error
  • library/flowsheet/djs controllers: Replaced all res.send('plain string') calls with res.json({ message: '...' }) and removed the extra status field from { status, message } response objects
  • New test suite at tests/unit/middleware/errorHandler.test.ts covering both WxycError and non-WxycError paths

Test plan

  • Unit tests verify WxycError returns { message } with correct status code
  • Unit tests verify non-WxycError returns generic { message: 'Internal server error' } (previously leaked raw message)
  • Unit tests verify non-Error thrown values are handled
  • Unit tests verify console.error is called for unhandled errors
  • Full unit test suite passes (124 tests, 9 suites)

Made with Cursor

@jakebromberg jakebromberg force-pushed the fix/26-error-format-consistency branch from fb9e3a8 to 813682f Compare February 27, 2026 06:14
@jakebromberg jakebromberg force-pushed the fix/26-error-format-consistency branch from b78cb87 to 152b2eb Compare March 2, 2026 17:37
@jakebromberg jakebromberg force-pushed the fix/26-error-format-consistency branch from 152b2eb to e4509f0 Compare March 2, 2026 20:40
Copy link
Collaborator

@AyBruno AyBruno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jake Bromberg and others added 3 commits March 9, 2026 22:57
…oints

Mixed formats (plain strings, { status, message }, leaked error.message)
are now consistently { message: '...' }. Internal errors no longer
expose raw error messages to clients.

Co-authored-by: Cursor <cursoragent@cursor.com>
Replaces res.status().json/send() error patterns with throw new
WxycError() so the centralized error handler formats all error
responses consistently.
@jakebromberg jakebromberg force-pushed the fix/26-error-format-consistency branch from e4509f0 to 15c96a0 Compare March 10, 2026 06:30
@jakebromberg jakebromberg requested a review from AyBruno March 10, 2026 06:45
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.

2 participants