Skip to content

docs(routes): adopt 422 Unprocessable Entity for validation errors (#568)#575

Merged
nanotaboada merged 2 commits intomasterfrom
feat/422-unprocessable-entity-#568
Apr 21, 2026
Merged

docs(routes): adopt 422 Unprocessable Entity for validation errors (#568)#575
nanotaboada merged 2 commits intomasterfrom
feat/422-unprocessable-entity-#568

Conversation

@nanotaboada
Copy link
Copy Markdown
Owner

@nanotaboada nanotaboada commented Apr 21, 2026

Summary

  • Added responses={422: ...} to @api_router.post and @api_router.put decorators, making 422 explicit in the OpenAPI schema
  • Updated post_async and put_async docstrings with Raises: entries that document 422 (Pydantic validation failure) and clarify the distinction from 400 (semantic ambiguity)
  • Updated CHANGELOG.md [Unreleased] section

Test plan

  • uv run flake8 . passes
  • uv run black --check . passes
  • uv run pytest — all 25 tests pass
  • OpenAPI docs at /docs show 422 response on POST and PUT endpoints

Closes #568

🤖 Generated with Claude Code


This change is Reviewable

Summary by CodeRabbit

  • Documentation
    • API endpoints now explicitly document request validation failures (HTTP 422 Unprocessable Entity) for create and update operations.
    • Docstrings and OpenAPI metadata clarify the distinction between schema/validation errors (422) and semantic/identity issues (400).
    • Updated API documentation and metadata to more accurately list possible error responses, improving client error handling and clarity.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c79912fd-9781-41d7-9787-e22b811402fb

📥 Commits

Reviewing files that changed from the base of the PR and between d35a8a1 and 4697be3.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • routes/player_route.py
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • routes/player_route.py

Walkthrough

Adds explicit OpenAPI responses={422: ...} to POST and PUT player endpoints and updates their docstrings and CHANGELOG to document 422 Unprocessable Entity for Pydantic request-body validation failures, distinguishing it from 400 for malformed/semantic errors.

Changes

Cohort / File(s) Summary
Route OpenAPI & Docstrings
routes/player_route.py
Added responses={422: {"description": "Unprocessable Entity"}} to POST /players/ and PUT /players/squadnumber/{squad_number} route decorators; updated post_async and put_async docstrings to document 422 for Pydantic validation failures and clarified PUT wording about identity mismatch.
Changelog
CHANGELOG.md
Inserted entry under Changed documenting explicit 422 Unprocessable Entity handling, OpenAPI metadata addition, and docstring Raises: distinction between 422 and 400.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Assessment against linked issues

Objective Addressed Explanation
Route docstrings document 422 for validation failures and 400 for malformed requests [#568]
OpenAPI route decorators declare responses={422: {...}} where applicable [#568]
CHANGELOG.md updated [#568]
Verify manual HTTPException instances use correct 400 vs 422 semantics [#568] No changes observed that audit or update existing HTTPException usages elsewhere in the codebase.

Out-of-scope changes

(No out-of-scope functional code changes detected.)

Possibly related PRs

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title follows Conventional Commits format with 'docs:' prefix, is 73 characters (under 80), and accurately describes the main change: adding explicit 422 Unprocessable Entity documentation for validation errors in routes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📋 Issue Planner

Built with CodeRabbit's Coding Plans for faster development and fewer bugs.

View plan used: #568

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/422-unprocessable-entity-#568
  • 🛠️ sync documentation: Commit on current branch
  • 🛠️ sync documentation: Create PR
  • 🛠️ enforce http error handling: Commit on current branch
  • 🛠️ enforce http error handling: Create PR
  • 🛠️ idiomatic review: Commit on current branch
  • 🛠️ idiomatic review: Create PR
  • 🛠️ verify api contract: Commit on current branch
  • 🛠️ verify api contract: Create PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

)

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
@nanotaboada nanotaboada force-pushed the feat/422-unprocessable-entity-#568 branch from d35a8a1 to 4697be3 Compare April 21, 2026 12:53
@nanotaboada nanotaboada changed the title docs(routes): adopt 422 Unprocessable Entity for payload validation errors (#568) docs(routes): adopt 422 Unprocessable Entity for validation errors (#568) Apr 21, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (92ba1c7) to head (02239bc).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #575   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            7         7           
  Lines          172       172           
=========================================
  Hits           172       172           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud
Copy link
Copy Markdown

@nanotaboada nanotaboada merged commit c270f8f into master Apr 21, 2026
11 checks passed
@nanotaboada nanotaboada deleted the feat/422-unprocessable-entity-#568 branch April 21, 2026 15:14
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.

Adopt 422 Unprocessable Entity for payload validation errors

1 participant