Skip to content

fix: return 400 for Zod validation errors instead of 500#7

Open
xiaofengzii wants to merge 7 commits into
mainfrom
fix/zod-errors-400-5753
Open

fix: return 400 for Zod validation errors instead of 500#7
xiaofengzii wants to merge 7 commits into
mainfrom
fix/zod-errors-400-5753

Conversation

@xiaofengzii

Copy link
Copy Markdown
Owner

Summary

This PR updates the global error handler to catch ZodError and return 400 with structured issues array instead of generic 500.

Changes

  • Catch ZodError in global error handler (apps/api/src/middleware/errorHandler.js)
  • Return 400 status code with structured issues array for validation errors
  • Update jobController to use parse (throw on error) instead of safeParse
  • Add tests for valid and invalid job creation payloads

Testing

  • All tests pass: node --test src/tests/*.test.js

/claim SecureBananaLabs#743
Closes SecureBananaLabs#5753

xiaofengzii and others added 7 commits June 8, 2026 16:22
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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.

Zod validation errors should return 400 instead of 500

1 participant