Skip to content

API validation errors should return 400 instead of 500 #3517

@danyili2632

Description

@danyili2632

Parent bounty: #743

Bug

Several API routes validate request bodies with Zod schemas in controllers, but errorHandler treats thrown ZodErrors as unhandled exceptions. That means malformed client input such as POST /api/jobs with a short title or invalid budget currently returns HTTP 500 instead of a client-facing HTTP 400 validation error.

Expected

  • Zod validation failures should return HTTP 400.
  • The response should be consistent with the API error shape: { success: false, message: ... }.
  • Server logs should not classify expected bad client input as an unexpected API error.

Scope

Keep the fix limited to API validation error handling and focused route tests.

This issue is limited only to the creator of this issue. This means that only the issue author can attempt to solve this issue. If you would like to work on it, please create another issue with the same contents and refer to issue #743 for more information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions