Skip to content

fix(serve): give a request that fails pydantic validation an error reason - #38

Merged
vinismarques merged 3 commits into
mainfrom
fix/pydantic-validation-error-reason
Oct 10, 2026
Merged

vinismarques merged 3 commits into
mainfrom
fix/pydantic-validation-error-reason

Conversation

@vinismarques

Copy link
Copy Markdown
Member

Summary

A request that fails pydantic validation is refused with 400, but its body had no error, the field a ValidationError refusal carries. A caller reading error got nothing to show.

 @app.exception_handler(pydantic.ValidationError)
-  400 {"detail": [...]}
+  400 {"error": "stems: Input should be a valid integer", "detail": [...]}

detail is unchanged. Version 5.2.2.

Evidence

  • Before (c9d58fe): test_an_invalid_request_is_refused_with_a_reason_naming_the_field fails with KeyError: 'error'.
    After: it passes; full suite 93 passed, ruff and ty clean.

Merge Danger

Door: two-way

Blast Radius: small

Adds a field to one error response. A client that branches on error being absent for this case would now see it.

@vinismarques
vinismarques merged commit 982d1b4 into main Oct 10, 2026
1 check passed
@vinismarques
vinismarques deleted the fix/pydantic-validation-error-reason branch October 10, 2026 20:41
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.

1 participant