Skip to content

Commit 3cbca63

Browse files
Merge branch 'develop' into feat/batch-secrets
2 parents 54f6f9a + d997beb commit 3cbca63

File tree

41 files changed

+1107
-624
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1107
-624
lines changed

.github/workflows/bootstrap_region.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
with:
5353
node-version: "22"
5454
- name: Setup dependencies
55-
uses: aws-powertools/actions/.github/actions/cached-node-modules@5ae7c190d6b51491bb14f593c3509c1bcbf7a3c1
55+
uses: aws-powertools/actions/.github/actions/cached-node-modules@da5bcb1a3d22f87bc48b570c818d26f44c0fc960
5656
- id: credentials
5757
name: AWS Credentials
5858
uses: aws-actions/configure-aws-credentials@b47578312673ae6fa5b5096b330d9fbac3d116df

CHANGELOG.md

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,32 @@
44
<a name="unreleased"></a>
55
# Unreleased
66

7+
## Maintenance
8+
9+
* **deps:** bump mkdocs-material from 9.6.15 to 9.6.16 ([#7065](https://github.com/aws-powertools/powertools-lambda-python/issues/7065))
10+
* **deps:** bump squidfunk/mkdocs-material from `0bfdba4` to `bb7b015` in /docs ([#7059](https://github.com/aws-powertools/powertools-lambda-python/issues/7059))
11+
* **deps:** bump aws-powertools/actions from 1.1.0 to 1.3.0 ([#7061](https://github.com/aws-powertools/powertools-lambda-python/issues/7061))
12+
* **deps:** bump mkdocs-material from 9.6.15 to 9.6.16 in /docs ([#7060](https://github.com/aws-powertools/powertools-lambda-python/issues/7060))
13+
* **deps-dev:** bump boto3-stubs from 1.39.14 to 1.39.16 ([#7066](https://github.com/aws-powertools/powertools-lambda-python/issues/7066))
14+
* **deps-dev:** bump coverage from 7.10.0 to 7.10.1 ([#7063](https://github.com/aws-powertools/powertools-lambda-python/issues/7063))
15+
* **deps-dev:** bump aws-cdk-aws-lambda-python-alpha from 2.207.0a0 to 2.208.0a0 ([#7062](https://github.com/aws-powertools/powertools-lambda-python/issues/7062))
16+
* **deps-dev:** bump sentry-sdk from 2.33.2 to 2.34.0 ([#7064](https://github.com/aws-powertools/powertools-lambda-python/issues/7064))
17+
18+
19+
<a name="v3.17.1"></a>
20+
## [v3.17.1] - 2025-07-29
21+
## Maintenance
22+
23+
24+
25+
<a name="v3.18.0"></a>
26+
## [v3.18.0] - 2025-07-29
727
## Documentation
828

29+
* **event_handler:** add section about Pydantic serialization ([#7049](https://github.com/aws-powertools/powertools-lambda-python/issues/7049))
930
* **event_handler:** enhance documentation on query/header parameters behavior ([#7000](https://github.com/aws-powertools/powertools-lambda-python/issues/7000))
1031
* **parameters:** fix typo in transform auto instruction ([#7017](https://github.com/aws-powertools/powertools-lambda-python/issues/7017))
32+
* **parser:** fix a a typo in SqsEnvelope ([#7052](https://github.com/aws-powertools/powertools-lambda-python/issues/7052))
1133

1234
## Features
1335

@@ -18,35 +40,41 @@
1840

1941
## Maintenance
2042

21-
* **ci:** new pre-release 3.17.1a3 ([#7014](https://github.com/aws-powertools/powertools-lambda-python/issues/7014))
43+
* version bump
44+
* **ci:** new pre-release 3.17.1a4 ([#7018](https://github.com/aws-powertools/powertools-lambda-python/issues/7018))
45+
* **ci:** improve feature flags UA ([#7051](https://github.com/aws-powertools/powertools-lambda-python/issues/7051))
46+
* **ci:** new pre-release 3.17.1a8 ([#7045](https://github.com/aws-powertools/powertools-lambda-python/issues/7045))
47+
* **ci:** new pre-release 3.17.1a9 ([#7054](https://github.com/aws-powertools/powertools-lambda-python/issues/7054))
2248
* **ci:** new pre-release 3.17.1a7 ([#7038](https://github.com/aws-powertools/powertools-lambda-python/issues/7038))
2349
* **ci:** new pre-release 3.17.1a0 ([#6989](https://github.com/aws-powertools/powertools-lambda-python/issues/6989))
2450
* **ci:** new pre-release 3.17.1a1 ([#6997](https://github.com/aws-powertools/powertools-lambda-python/issues/6997))
2551
* **ci:** add a new workflow to build docs in new PRs ([#7002](https://github.com/aws-powertools/powertools-lambda-python/issues/7002))
2652
* **ci:** new pre-release 3.17.1a2 ([#7008](https://github.com/aws-powertools/powertools-lambda-python/issues/7008))
27-
* **ci:** new pre-release 3.17.1a5 ([#7025](https://github.com/aws-powertools/powertools-lambda-python/issues/7025))
28-
* **ci:** new pre-release 3.17.1a4 ([#7018](https://github.com/aws-powertools/powertools-lambda-python/issues/7018))
2953
* **ci:** new pre-release 3.17.1a6 ([#7029](https://github.com/aws-powertools/powertools-lambda-python/issues/7029))
54+
* **ci:** new pre-release 3.17.1a3 ([#7014](https://github.com/aws-powertools/powertools-lambda-python/issues/7014))
55+
* **ci:** new pre-release 3.17.1a5 ([#7025](https://github.com/aws-powertools/powertools-lambda-python/issues/7025))
56+
* **ci:** remove closed-issue and opened-pr workflows ([#7047](https://github.com/aws-powertools/powertools-lambda-python/issues/7047))
3057
* **deps:** update aws-powertools/actions requirement to 5ae7c190d6b51491bb14f593c3509c1bcbf7a3c1 ([#7034](https://github.com/aws-powertools/powertools-lambda-python/issues/7034))
31-
* **deps-dev:** bump aws-cdk-lib from 2.205.0 to 2.206.0 ([#6996](https://github.com/aws-powertools/powertools-lambda-python/issues/6996))
58+
* **deps-dev:** bump pytest-asyncio from 0.26.0 to 1.1.0 ([#6995](https://github.com/aws-powertools/powertools-lambda-python/issues/6995))
59+
* **deps-dev:** bump boto3-stubs from 1.39.8 to 1.39.9 ([#7011](https://github.com/aws-powertools/powertools-lambda-python/issues/7011))
60+
* **deps-dev:** bump boto3-stubs from 1.39.11 to 1.39.12 ([#7027](https://github.com/aws-powertools/powertools-lambda-python/issues/7027))
3261
* **deps-dev:** bump testcontainers from 4.10.0 to 4.12.0 ([#7021](https://github.com/aws-powertools/powertools-lambda-python/issues/7021))
33-
* **deps-dev:** bump coverage from 7.9.2 to 7.10.0 ([#7033](https://github.com/aws-powertools/powertools-lambda-python/issues/7033))
3462
* **deps-dev:** bump boto3-stubs from 1.39.7 to 1.39.8 ([#7006](https://github.com/aws-powertools/powertools-lambda-python/issues/7006))
3563
* **deps-dev:** bump ruff from 0.12.3 to 0.12.4 ([#7005](https://github.com/aws-powertools/powertools-lambda-python/issues/7005))
36-
* **deps-dev:** bump boto3-stubs from 1.39.11 to 1.39.12 ([#7027](https://github.com/aws-powertools/powertools-lambda-python/issues/7027))
37-
* **deps-dev:** bump boto3-stubs from 1.39.8 to 1.39.9 ([#7011](https://github.com/aws-powertools/powertools-lambda-python/issues/7011))
3864
* **deps-dev:** bump aws-cdk from 2.1021.0 to 2.1022.0 ([#7031](https://github.com/aws-powertools/powertools-lambda-python/issues/7031))
39-
* **deps-dev:** bump pytest-asyncio from 0.26.0 to 1.1.0 ([#6995](https://github.com/aws-powertools/powertools-lambda-python/issues/6995))
65+
* **deps-dev:** bump aws-cdk-lib from 2.206.0 to 2.207.0 ([#7035](https://github.com/aws-powertools/powertools-lambda-python/issues/7035))
66+
* **deps-dev:** bump coverage from 7.9.2 to 7.10.0 ([#7033](https://github.com/aws-powertools/powertools-lambda-python/issues/7033))
4067
* **deps-dev:** bump sentry-sdk from 2.33.0 to 2.33.2 ([#7023](https://github.com/aws-powertools/powertools-lambda-python/issues/7023))
68+
* **deps-dev:** bump aws-cdk-lib from 2.205.0 to 2.206.0 ([#6996](https://github.com/aws-powertools/powertools-lambda-python/issues/6996))
4169
* **deps-dev:** bump boto3-stubs from 1.39.4 to 1.39.7 ([#6994](https://github.com/aws-powertools/powertools-lambda-python/issues/6994))
4270
* **deps-dev:** bump aws-cdk-aws-lambda-python-alpha from 2.205.0a0 to 2.206.0a0 ([#6993](https://github.com/aws-powertools/powertools-lambda-python/issues/6993))
4371
* **deps-dev:** bump aws-cdk from 2.1020.2 to 2.1021.0 ([#6992](https://github.com/aws-powertools/powertools-lambda-python/issues/6992))
44-
* **deps-dev:** bump aws-cdk-lib from 2.206.0 to 2.207.0 ([#7035](https://github.com/aws-powertools/powertools-lambda-python/issues/7035))
4572
* **deps-dev:** bump boto3-stubs from 1.39.12 to 1.39.13 ([#7036](https://github.com/aws-powertools/powertools-lambda-python/issues/7036))
73+
* **deps-dev:** bump ruff from 0.12.4 to 0.12.5 ([#7032](https://github.com/aws-powertools/powertools-lambda-python/issues/7032))
4674
* **deps-dev:** bump sentry-sdk from 2.32.0 to 2.33.0 ([#6988](https://github.com/aws-powertools/powertools-lambda-python/issues/6988))
4775
* **deps-dev:** bump aws-cdk-aws-lambda-python-alpha from 2.204.0a0 to 2.205.0a0 ([#6986](https://github.com/aws-powertools/powertools-lambda-python/issues/6986))
48-
* **deps-dev:** bump ruff from 0.12.4 to 0.12.5 ([#7032](https://github.com/aws-powertools/powertools-lambda-python/issues/7032))
4976
* **deps-dev:** bump aws-cdk-aws-lambda-python-alpha from 2.206.0a0 to 2.207.0a0 ([#7037](https://github.com/aws-powertools/powertools-lambda-python/issues/7037))
77+
* **deps-dev:** bump boto3-stubs from 1.39.13 to 1.39.14 ([#7042](https://github.com/aws-powertools/powertools-lambda-python/issues/7042))
5078
* **deps-dev:** bump boto3-stubs from 1.39.9 to 1.39.11 ([#7022](https://github.com/aws-powertools/powertools-lambda-python/issues/7022))
5179

5280

@@ -6844,7 +6872,9 @@
68446872
* Merge pull request [#5](https://github.com/aws-powertools/powertools-lambda-python/issues/5) from jfuss/feat/python38
68456873

68466874

6847-
[Unreleased]: https://github.com/aws-powertools/powertools-lambda-python/compare/v3.17.0...HEAD
6875+
[Unreleased]: https://github.com/aws-powertools/powertools-lambda-python/compare/v3.17.1...HEAD
6876+
[v3.17.1]: https://github.com/aws-powertools/powertools-lambda-python/compare/v3.18.0...v3.17.1
6877+
[v3.18.0]: https://github.com/aws-powertools/powertools-lambda-python/compare/v3.17.0...v3.18.0
68486878
[v3.17.0]: https://github.com/aws-powertools/powertools-lambda-python/compare/v3.16.0...v3.17.0
68496879
[v3.16.0]: https://github.com/aws-powertools/powertools-lambda-python/compare/v3.15.1...v3.16.0
68506880
[v3.15.1]: https://github.com/aws-powertools/powertools-lambda-python/compare/v3.15.0...v3.15.1

aws_lambda_powertools/event_handler/api_gateway.py

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ def __call__(
469469

470470
# Save CPU cycles by building middleware stack once
471471
if not self._middleware_stack_built:
472-
self._build_middleware_stack(router_middlewares=router_middlewares)
472+
self._build_middleware_stack(router_middlewares=router_middlewares, app=app)
473473

474474
# If debug is turned on then output the middleware stack to the console
475475
if app._debug:
@@ -487,7 +487,7 @@ def __call__(
487487
# Call the Middleware Wrapped _call_stack function handler with the app
488488
return self._middleware_stack(app)
489489

490-
def _build_middleware_stack(self, router_middlewares: list[Callable[..., Any]]) -> None:
490+
def _build_middleware_stack(self, router_middlewares: list[Callable[..., Any]], app) -> None:
491491
"""
492492
Builds the middleware stack for the handler by wrapping each
493493
handler in an instance of MiddlewareWrapper which is used to contain the state
@@ -505,7 +505,25 @@ def _build_middleware_stack(self, router_middlewares: list[Callable[..., Any]])
505505
The Route Middleware stack is processed in reverse order. This is so the stack of
506506
middleware handlers is applied in the order of being added to the handler.
507507
"""
508-
all_middlewares = router_middlewares + self.middlewares
508+
# Build middleware stack in the correct order for validation:
509+
# 1. Request validation middleware (first)
510+
# 2. Router middlewares + user middlewares (middle)
511+
# 3. Response validation middleware (before route handler)
512+
# 4. Route handler adapter (last)
513+
514+
all_middlewares = []
515+
516+
# Add request validation middleware first if validation is enabled
517+
if hasattr(app, "_request_validation_middleware"):
518+
all_middlewares.append(app._request_validation_middleware)
519+
520+
# Add user middlewares in the middle
521+
all_middlewares.extend(router_middlewares + self.middlewares)
522+
523+
# Add response validation middleware before the route handler if validation is enabled
524+
if hasattr(app, "_response_validation_middleware"):
525+
all_middlewares.append(app._response_validation_middleware)
526+
509527
logger.debug(f"Building middleware stack: {all_middlewares}")
510528

511529
# IMPORTANT:
@@ -1639,17 +1657,16 @@ def __init__(
16391657
self._json_body_deserializer = json_body_deserializer
16401658

16411659
if self._enable_validation:
1642-
from aws_lambda_powertools.event_handler.middlewares.openapi_validation import OpenAPIValidationMiddleware
1643-
1644-
# Note the serializer argument: only use custom serializer if provided by the caller
1645-
# Otherwise, fully rely on the internal Pydantic based mechanism to serialize responses for validation.
1646-
self.use(
1647-
[
1648-
OpenAPIValidationMiddleware(
1649-
validation_serializer=serializer,
1650-
has_response_validation_error=self._has_response_validation_error,
1651-
),
1652-
],
1660+
from aws_lambda_powertools.event_handler.middlewares.openapi_validation import (
1661+
OpenAPIRequestValidationMiddleware,
1662+
OpenAPIResponseValidationMiddleware,
1663+
)
1664+
1665+
# Store validation middlewares to be added in the correct order later
1666+
self._request_validation_middleware = OpenAPIRequestValidationMiddleware()
1667+
self._response_validation_middleware = OpenAPIResponseValidationMiddleware(
1668+
validation_serializer=serializer,
1669+
has_response_validation_error=self._has_response_validation_error,
16531670
)
16541671

16551672
def _validate_response_validation_error_http_code(
@@ -2668,7 +2685,7 @@ def _call_exception_handler(self, exp: Exception, route: Route) -> ResponseBuild
26682685
route=route,
26692686
)
26702687

2671-
# OpenAPIValidationMiddleware will only raise ResponseValidationError when
2688+
# OpenAPIResponseValidationMiddleware will only raise ResponseValidationError when
26722689
# 'self._response_validation_error_http_code' is not None or
26732690
# when route has custom_response_validation_http_code
26742691
if isinstance(exp, ResponseValidationError):

0 commit comments

Comments
 (0)