Commit 3137ecb
fix(event_handler): normalize Union and RootModel sequences in body validation (#8067)
* handle Union and RootModel sequences in Body validation
* fix(event-handler): make sequence detection recursive for nested Union/RootModel
The original fix only checked one level deep. This makes
_is_or_contains_sequence recursive so it catches:
- Optional[RootModel[List[Model]]] (Union containing RootModel)
- RootModel[Union[Model, List[Model]]] (RootModel wrapping Union)
Adds 16 regression tests covering edge cases: Optional, empty list,
single-element list, pipe syntax, cross-resolver, large payloads, etc.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Leandro Damascena <lcdama@amazon.pt>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 2ab8f39 commit 3137ecb
File tree
2 files changed
+531
-3
lines changed- aws_lambda_powertools/event_handler/middlewares
- tests/functional/event_handler/_pydantic
2 files changed
+531
-3
lines changedLines changed: 36 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
431 | 433 | | |
432 | 434 | | |
433 | 435 | | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
434 | 468 | | |
435 | 469 | | |
436 | | - | |
| 470 | + | |
437 | 471 | | |
438 | 472 | | |
439 | 473 | | |
| |||
0 commit comments