Skip to content

feat(event_handler): support any Pydantic Field annotation in parameter#8305

Merged
leandrodamascena merged 2 commits into
developfrom
feat/field-annotation-param-validation
Jun 29, 2026
Merged

feat(event_handler): support any Pydantic Field annotation in parameter#8305
leandrodamascena merged 2 commits into
developfrom
feat/field-annotation-param-validation

Conversation

@leandrodamascena

Copy link
Copy Markdown
Contributor

Issue number: closes #8304

Summary

Changes

This PR makes any Pydantic Field annotation work with any parameter location (Path/Query/Header/Body).

I generalized that path so a plain Field and a location marker can be combined freely. The discriminator case is now just one example of the general behavior, not a special case.

User experience

Before, this raised an error. Now it just works:

StrField = Annotated[str, Field()]

@app.get("/items")
def get_items(q: Annotated[StrField, Query]):           # works
    ...

@app.get("/count")
def get_count(n: Annotated[int, Field(gt=0), Query]):   # gt=0 enforced (422 on n <= 0)
    ...

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@leandrodamascena leandrodamascena requested a review from a team as a code owner June 29, 2026 09:24
@leandrodamascena leandrodamascena requested a review from hjgraca June 29, 2026 09:24
@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 29, 2026
@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.73684% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 96.63%. Comparing base (6c203ea) to head (7c4223b).

Files with missing lines Patch % Lines
..._lambda_powertools/event_handler/openapi/params.py 94.73% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #8305   +/-   ##
========================================
  Coverage    96.62%   96.63%           
========================================
  Files          296      296           
  Lines        14686    14689    +3     
  Branches      1230     1231    +1     
========================================
+ Hits         14191    14194    +3     
  Misses         360      360           
  Partials       135      135           

☔ View full report in Codecov by Harness.
📢 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.

@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 29, 2026
@mergify

mergify Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@leandrodamascena leandrodamascena merged commit 2c6b5e0 into develop Jun 29, 2026
17 of 18 checks passed
@leandrodamascena leandrodamascena deleted the feat/field-annotation-param-validation branch June 29, 2026 10:11
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

event_handlers size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Support Field annotation for event_handler parameter validation

2 participants