Skip to content

Handle Pydantic ValidationError explicitly in admin API handlers #318

Description

@coderabbitai

Description

In goodmap/admin_api.py, the _create_location_handler and _update_location_handler functions currently catch Pydantic's ValidationError in the generic Exception handler, which returns a 500 Internal Server Error instead of the more appropriate 400 Bad Request.

Proposed Solution

Add specific except blocks for Pydantic's ValidationError in both handlers:

  • Import ValidationError from pydantic
  • Add except ValidationError as e: block after the existing except LocationValidationError as e block
  • Handle validation errors with a 400 response instead of 500

Context

TODO comments have been added to the code as placeholders.

Metadata

Metadata

Assignees

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