Summary
In this release, we focused on the Event Handler utility - we added three new features and shipped several important bug fixes across Event Handler and Idempotency.
- File uploads - handle
multipart/form-datauploads with full OpenAPI validation and Swagger UI file picker - Cookie parameters - use cookies as typed, validated parameters alongside
Query(),Header(), andForm() - Request object - access the resolved route pattern, path parameters, and HTTP method in middleware and route handlers
A huge thanks to @oyiz-michael, @siwyd, @abhu85, and @danjhd for their contributions!
File upload support for OpenAPI
You can now handle file uploads in your API endpoints with full OpenAPI validation and Swagger UI support. If using Swagger, it renders a file picker automatically. A special thanks to @oyiz-michael for starting the initial work on this feature.
from typing import Annotated
from aws_lambda_powertools.event_handler import APIGatewayRestResolver
from aws_lambda_powertools.event_handler.openapi.params import File, Form, UploadFile
app = APIGatewayRestResolver(enable_validation=True)
app.enable_swagger(path="/swagger")
@app.post("/upload")
def upload(
file_data: Annotated[UploadFile, File(description="CSV file")],
separator: Annotated[str, Form(description="CSV separator")] = ",",
):
return {
"filename": file_data.filename,
"content_type": file_data.content_type,
"file_size": len(file_data),
}You can receive files as raw bytes (Annotated[bytes, File()]) or as an UploadFile object with filename and content type metadata.
Cookie parameter support for OpenAPI
You can now use cookies as typed, validated parameters in your API endpoints - just like Query(), Header(), or Form(). The OpenAPI schema generates in: cookie parameters automatically, and validation works across all resolver types.
from typing import Annotated
from aws_lambda_powertools.event_handler import APIGatewayRestResolver
from aws_lambda_powertools.event_handler.openapi.params import Cookie
app = APIGatewayRestResolver(enable_validation=True)
@app.get("/me")
def get_me(
session_id: Annotated[str, Cookie(description="Session identifier")],
theme: Annotated[str, Cookie(description="UI theme")] = "light",
):
return {"session_id": session_id, "theme": theme}Request object for middleware and route handlers
We added a Request object that gives middleware and route handlers access to the resolved route pattern, Powertools-extracted path parameters, HTTP method, headers, query parameters, and body. Previously, middleware only had access to app.current_event, which returns raw API Gateway parameters (e.g. {"proxy": "users/123"} for {proxy+} routes) instead of the resolved ones.
You can access the Request object in two ways:
In middleware via app.request:
from aws_lambda_powertools.event_handler import APIGatewayRestResolver, Response
from aws_lambda_powertools.event_handler.middlewares import NextMiddleware
app = APIGatewayRestResolver()
def auth_middleware(app: APIGatewayRestResolver, next_middleware: NextMiddleware) -> Response:
req = app.request
route = req.route # "/users/{user_id}"
path_params = req.path_parameters # {"user_id": "123"}
method = req.method # "GET"
# auth logic here...
return next_middleware(app)
app.use(middlewares=[auth_middleware])In route handlers via type annotation:
from aws_lambda_powertools.event_handler import APIGatewayRestResolver, Request
app = APIGatewayRestResolver()
@app.get("/users/<user_id>")
def get_user(user_id: str, request: Request):
user_agent = request.headers.get("user-agent")
return {"id": user_id, "route": request.route, "user_agent": user_agent}Changes
- feat(event_handler): add Cookie parameter support for OpenAPI utility (#8095) by @leandrodamascena
- fix(data_classes): support {proxy+} and path parameters in authorizer response (#8092) by @leandrodamascena
- fix(event_handler): sync middleware receives real response in async ASGI context (#8089) by @leandrodamascena
- feat(event_handler): add Request object for middleware access to resolved route and args (#8036) by @oyiz-michael
- fix(event_handler): support finding type annotated resolver when merging schemas (#8074) by @siwyd
- fix(idempotency): serialize Pydantic models with mode='json' for UUID/date support (#8075) by @abhu85
- fix(event_handler): normalize Union and RootModel sequences in body validation (#8067) by @danjhd
📜 Documentation updates
- ci: remove me-south-1 region (#8108) by @leandrodamascena
- docs: adding docs to Request object (#8105) by @leandrodamascena
- feat(event_handler): add File parameter support for multipart/form-data uploads (#8093) by @leandrodamascena
- docs: fix ranthebuilder link in Update we_made_this.md (#8084) by @ran-isenberg
- chore(deps): bump squidfunk/mkdocs-material from
8f41b60to868ad4din /docs (#8083) by @dependabot[bot] - chore(deps): bump requests from 2.32.4 to 2.33.0 in /docs (#8070) by @dependabot[bot]
- chore(deps): bump mkdocs-material from 9.7.1 to 9.7.5 (#8045) by @dependabot[bot]
🔧 Maintenance
- docs: adding docs to Request object (#8105) by @leandrodamascena
- chore(deps-dev): bump isort from 7.0.0 to 8.0.1 (#8101) by @dependabot[bot]
- chore(deps-dev): bump aws-cdk-aws-lambda-python-alpha from 2.243.0a0 to 2.248.0a0 (#8103) by @dependabot[bot]
- chore(deps-dev): bump types-requests from 2.32.4.20260107 to 2.33.0.20260402 (#8102) by @dependabot[bot]
- chore(deps-dev): bump ruff from 0.15.8 to 0.15.9 in the dev-dependencies group (#8100) by @dependabot[bot]
- chore(deps-dev): bump requests from 2.33.0 to 2.33.1 (#8104) by @dependabot[bot]
- chore(deps-dev): bump ty from 0.0.23 to 0.0.26 (#8078) by @dependabot[bot]
- chore(deps-dev): bump pygments from 2.19.2 to 2.20.0 (#8077) by @dependabot[bot]
- chore(deps): bump squidfunk/mkdocs-material from
8f41b60to868ad4din /docs (#8083) by @dependabot[bot] - chore(deps-dev): bump the dev-dependencies group across 1 directory with 4 updates (#8086) by @dependabot[bot]
- chore(deps): bump mkdocs-material from 9.7.5 to 9.7.6 (#8079) by @dependabot[bot]
- chore(deps): bump valkey-glide from 2.2.7 to 2.3.0 (#8080) by @dependabot[bot]
- chore(deps-dev): bump sentry-sdk from 2.54.0 to 2.56.0 (#8082) by @dependabot[bot]
- chore(deps): bump cryptography from 46.0.5 to 46.0.6 (#8072) by @dependabot[bot]
- chore(deps): bump the github-actions group across 1 directory with 10 updates (#8081) by @dependabot[bot]
- chore(deps-dev): bump aws-cdk from 2.1111.0 to 2.1113.0 in the aws-cdk group (#8058) by @dependabot[bot]
- chore(deps-dev): bump requests from 2.32.5 to 2.33.0 (#8069) by @dependabot[bot]
- chore(deps): bump requests from 2.32.4 to 2.33.0 in /docs (#8070) by @dependabot[bot]
- chore(deps-dev): bump cdklabs-generative-ai-cdk-constructs from 0.1.315 to 0.1.316 (#8061) by @dependabot[bot]
- chore(deps-dev): bump boto3-stubs from 1.42.73 to 1.42.74 (#8062) by @dependabot[bot]
- chore(deps): bump mkdocs-material from 9.7.1 to 9.7.5 (#8045) by @dependabot[bot]
- chore(deps-dev): bump boto3-stubs from 1.42.67 to 1.42.68 (#8043) by @dependabot[bot]
- chore(deps-dev): bump nox from 2025.11.12 to 2026.2.9 (#8044) by @dependabot[bot]
- chore(deps-dev): bump aws-cdk from 2.1110.0 to 2.1111.0 in the aws-cdk group (#8039) by @dependabot[bot]
- chore(deps): bump protobuf from 6.33.5 to 7.34.0 (#8046) by @dependabot[bot]
This release was made possible by the following contributors:
@abhu85, @danjhd, @dependabot[bot], @github-actions[bot], @leandrodamascena, @oyiz-michael, @ran-isenberg, @siwyd, dependabot[bot] and github-actions[bot]