Skip to content

Commit a98ee0a

Browse files
Merge branch 'develop' into feat/buffer-log
2 parents 10d81d9 + 40ce855 commit a98ee0a

File tree

16 files changed

+320
-107
lines changed

16 files changed

+320
-107
lines changed

CHANGELOG.md

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
## Bug Fixes
88

99
* **logger:** correctly pick powertools or custom handler in custom environments ([#6083](https://github.com/aws-powertools/powertools-lambda-python/issues/6083))
10+
* **openapi:** validate response serialization when falsy ([#6119](https://github.com/aws-powertools/powertools-lambda-python/issues/6119))
1011
* **security:** fix encryption_context handling in data masking operations ([#6074](https://github.com/aws-powertools/powertools-lambda-python/issues/6074))
1112

1213
## Documentation
@@ -22,29 +23,37 @@
2223

2324
## Maintenance
2425

25-
* **ci:** new pre-release 3.6.1a5 ([#6124](https://github.com/aws-powertools/powertools-lambda-python/issues/6124))
26-
* **ci:** new pre-release 3.6.1a4 ([#6120](https://github.com/aws-powertools/powertools-lambda-python/issues/6120))
26+
* **ci:** remove python3.8 runtime when bootstrapping a new region ([#6101](https://github.com/aws-powertools/powertools-lambda-python/issues/6101))
2727
* **ci:** new pre-release 3.6.1a0 ([#6084](https://github.com/aws-powertools/powertools-lambda-python/issues/6084))
28-
* **ci:** new pre-release 3.6.1a1 ([#6090](https://github.com/aws-powertools/powertools-lambda-python/issues/6090))
28+
* **ci:** new pre-release 3.6.1a6 ([#6132](https://github.com/aws-powertools/powertools-lambda-python/issues/6132))
2929
* **ci:** new pre-release 3.6.1a2 ([#6098](https://github.com/aws-powertools/powertools-lambda-python/issues/6098))
30-
* **ci:** remove python3.8 runtime when bootstrapping a new region ([#6101](https://github.com/aws-powertools/powertools-lambda-python/issues/6101))
30+
* **ci:** new pre-release 3.6.1a5 ([#6124](https://github.com/aws-powertools/powertools-lambda-python/issues/6124))
31+
* **ci:** new pre-release 3.6.1a4 ([#6120](https://github.com/aws-powertools/powertools-lambda-python/issues/6120))
3132
* **ci:** new pre-release 3.6.1a3 ([#6107](https://github.com/aws-powertools/powertools-lambda-python/issues/6107))
32-
* **deps:** bump squidfunk/mkdocs-material from `c62453b` to `f5bcec4` in /docs ([#6087](https://github.com/aws-powertools/powertools-lambda-python/issues/6087))
33+
* **ci:** new pre-release 3.6.1a1 ([#6090](https://github.com/aws-powertools/powertools-lambda-python/issues/6090))
3334
* **deps:** bump zgosalvez/github-actions-ensure-sha-pinned-actions from 3.0.21 to 3.0.22 ([#6113](https://github.com/aws-powertools/powertools-lambda-python/issues/6113))
35+
* **deps:** bump squidfunk/mkdocs-material from `c62453b` to `f5bcec4` in /docs ([#6087](https://github.com/aws-powertools/powertools-lambda-python/issues/6087))
3436
* **deps:** bump aws-actions/configure-aws-credentials from 4.0.3 to 4.1.0 ([#6082](https://github.com/aws-powertools/powertools-lambda-python/issues/6082))
37+
* **deps-dev:** bump mkdocstrings-python from 1.16.0 to 1.16.1 ([#6128](https://github.com/aws-powertools/powertools-lambda-python/issues/6128))
38+
* **deps-dev:** bump boto3-stubs from 1.36.19 to 1.36.22 ([#6116](https://github.com/aws-powertools/powertools-lambda-python/issues/6116))
39+
* **deps-dev:** bump cdklabs-generative-ai-cdk-constructs from 0.1.292 to 0.1.293 ([#6129](https://github.com/aws-powertools/powertools-lambda-python/issues/6129))
3540
* **deps-dev:** bump sentry-sdk from 2.20.0 to 2.21.0 ([#6096](https://github.com/aws-powertools/powertools-lambda-python/issues/6096))
36-
* **deps-dev:** bump sentry-sdk from 2.21.0 to 2.22.0 ([#6114](https://github.com/aws-powertools/powertools-lambda-python/issues/6114))
37-
* **deps-dev:** bump bandit from 1.8.2 to 1.8.3 ([#6117](https://github.com/aws-powertools/powertools-lambda-python/issues/6117))
38-
* **deps-dev:** bump aws-cdk from 2.178.1 to 2.178.2 ([#6089](https://github.com/aws-powertools/powertools-lambda-python/issues/6089))
41+
* **deps-dev:** bump mkdocs-material from 9.6.3 to 9.6.4 ([#6097](https://github.com/aws-powertools/powertools-lambda-python/issues/6097))
42+
* **deps-dev:** bump aws-cdk-lib from 2.178.2 to 2.179.0 ([#6130](https://github.com/aws-powertools/powertools-lambda-python/issues/6130))
43+
* **deps-dev:** bump aws-cdk-aws-lambda-python-alpha from 2.178.1a0 to 2.178.2a0 ([#6095](https://github.com/aws-powertools/powertools-lambda-python/issues/6095))
3944
* **deps-dev:** bump boto3-stubs from 1.36.17 to 1.36.19 ([#6093](https://github.com/aws-powertools/powertools-lambda-python/issues/6093))
40-
* **deps-dev:** bump mkdocstrings-python from 1.15.0 to 1.16.0 ([#6118](https://github.com/aws-powertools/powertools-lambda-python/issues/6118))
4145
* **deps-dev:** bump cfn-lint from 1.24.0 to 1.25.1 ([#6115](https://github.com/aws-powertools/powertools-lambda-python/issues/6115))
42-
* **deps-dev:** bump aws-cdk-aws-lambda-python-alpha from 2.178.1a0 to 2.178.2a0 ([#6095](https://github.com/aws-powertools/powertools-lambda-python/issues/6095))
46+
* **deps-dev:** bump mkdocstrings-python from 1.15.0 to 1.16.0 ([#6118](https://github.com/aws-powertools/powertools-lambda-python/issues/6118))
47+
* **deps-dev:** bump aws-cdk from 2.178.1 to 2.178.2 ([#6089](https://github.com/aws-powertools/powertools-lambda-python/issues/6089))
48+
* **deps-dev:** bump sentry-sdk from 2.21.0 to 2.22.0 ([#6114](https://github.com/aws-powertools/powertools-lambda-python/issues/6114))
49+
* **deps-dev:** bump boto3-stubs from 1.36.22 to 1.36.24 ([#6131](https://github.com/aws-powertools/powertools-lambda-python/issues/6131))
50+
* **deps-dev:** bump aws-cdk from 2.178.2 to 2.1000.2 ([#6126](https://github.com/aws-powertools/powertools-lambda-python/issues/6126))
51+
* **deps-dev:** bump aws-cdk-aws-lambda-python-alpha from 2.178.2a0 to 2.179.0a0 ([#6127](https://github.com/aws-powertools/powertools-lambda-python/issues/6127))
4352
* **deps-dev:** bump coverage from 7.6.11 to 7.6.12 ([#6080](https://github.com/aws-powertools/powertools-lambda-python/issues/6080))
4453
* **deps-dev:** bump mkdocstrings-python from 1.14.6 to 1.15.0 ([#6079](https://github.com/aws-powertools/powertools-lambda-python/issues/6079))
4554
* **deps-dev:** bump boto3-stubs from 1.36.16 to 1.36.17 ([#6078](https://github.com/aws-powertools/powertools-lambda-python/issues/6078))
46-
* **deps-dev:** bump boto3-stubs from 1.36.19 to 1.36.22 ([#6116](https://github.com/aws-powertools/powertools-lambda-python/issues/6116))
47-
* **deps-dev:** bump mkdocs-material from 9.6.3 to 9.6.4 ([#6097](https://github.com/aws-powertools/powertools-lambda-python/issues/6097))
55+
* **deps-dev:** bump bandit from 1.8.2 to 1.8.3 ([#6117](https://github.com/aws-powertools/powertools-lambda-python/issues/6117))
56+
* **docs:** enable sitemap generation ([#6103](https://github.com/aws-powertools/powertools-lambda-python/issues/6103))
4857

4958

5059
<a name="v3.6.0"></a>

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
[![Build](https://github.com/aws-powertools/powertools-lambda-python/actions/workflows/quality_check.yml/badge.svg)](https://github.com/aws-powertools/powertools-lambda-python/actions/workflows/python_build.yml)
55
[![codecov.io](https://codecov.io/github/aws-powertools/powertools-lambda-python/branch/develop/graphs/badge.svg)](https://app.codecov.io/gh/aws-powertools/powertools-lambda-python)
6-
![PythonSupport](https://img.shields.io/static/v1?label=python&message=%203.8|%203.9|%203.10|%203.11|%203.12&color=blue?style=flat-square&logo=python) ![PyPI version](https://badge.fury.io/py/aws-lambda-powertools.svg) ![PyPi monthly downloads](https://img.shields.io/pypi/dm/aws-lambda-powertools) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/aws-powertools/powertools-lambda-python/badge)](https://api.securityscorecards.dev/projects/github.com/aws-powertools/powertools-lambda-python) [![Join our Discord](https://dcbadge.vercel.app/api/server/B8zZKbbyET?style=flat-square)](https://discord.gg/B8zZKbbyET)
6+
![PythonSupport](https://img.shields.io/static/v1?label=python&message=%203.9|%203.10|%203.11|%203.12|%203.13&color=blue?style=flat-square&logo=python) ![PyPI version](https://badge.fury.io/py/aws-lambda-powertools.svg) ![PyPi monthly downloads](https://img.shields.io/pypi/dm/aws-lambda-powertools) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/aws-powertools/powertools-lambda-python/badge)](https://api.securityscorecards.dev/projects/github.com/aws-powertools/powertools-lambda-python) [![Join our Discord](https://dcbadge.vercel.app/api/server/B8zZKbbyET?style=flat-square)](https://discord.gg/B8zZKbbyET)
77

88
Powertools for AWS Lambda (Python) is a developer toolkit to implement Serverless [best practices and increase developer velocity](https://docs.powertools.aws.dev/lambda/python/latest/#features).
99

aws_lambda_powertools/event_handler/middlewares/openapi_validation.py

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,13 @@ def handler(self, app: EventHandlerInstance, next_middleware: NextMiddleware) ->
136136
return self._handle_response(route=route, response=response)
137137

138138
def _handle_response(self, *, route: Route, response: Response):
139-
# Process the response body if it exists
140-
if response.body:
141-
# Validate and serialize the response, if it's JSON
142-
if response.is_json():
143-
response.body = self._serialize_response(
144-
field=route.dependant.return_param,
145-
response_content=response.body,
146-
)
139+
# Check if we have a return type defined
140+
if route.dependant.return_param:
141+
# Validate and serialize the response, including None
142+
response.body = self._serialize_response(
143+
field=route.dependant.return_param,
144+
response_content=response.body,
145+
)
147146

148147
return response
149148

@@ -164,15 +163,6 @@ def _serialize_response(
164163
"""
165164
if field:
166165
errors: list[dict[str, Any]] = []
167-
# MAINTENANCE: remove this when we drop pydantic v1
168-
if not hasattr(field, "serializable"):
169-
response_content = self._prepare_response_content(
170-
response_content,
171-
exclude_unset=exclude_unset,
172-
exclude_defaults=exclude_defaults,
173-
exclude_none=exclude_none,
174-
)
175-
176166
value = _validate_field(field=field, value=response_content, loc=("response",), existing_errors=errors)
177167
if errors:
178168
raise RequestValidationError(errors=_normalize_errors(errors), body=response_content)
@@ -187,7 +177,6 @@ def _serialize_response(
187177
exclude_defaults=exclude_defaults,
188178
exclude_none=exclude_none,
189179
)
190-
191180
return jsonable_encoder(
192181
value,
193182
include=include,
@@ -199,7 +188,7 @@ def _serialize_response(
199188
custom_serializer=self._validation_serializer,
200189
)
201190
else:
202-
# Just serialize the response content returned from the handler
191+
# Just serialize the response content returned from the handler.
203192
return jsonable_encoder(response_content, custom_serializer=self._validation_serializer)
204193

205194
def _prepare_response_content(
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Exposes version constant to avoid circular dependencies."""
22

3-
VERSION = "3.6.1a5"
3+
VERSION = "3.6.1a6"

aws_lambda_powertools/utilities/parser/models/event_bridge.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from datetime import datetime
22
from typing import List, Optional
33

4-
from pydantic import BaseModel, ConfigDict, Field
4+
from pydantic import BaseModel, ConfigDict, Field, field_validator
55

66
from aws_lambda_powertools.utilities.parser.types import RawDictOrModel
77

@@ -19,3 +19,9 @@ class EventBridgeModel(BaseModel):
1919
detail_type: str = Field(..., alias="detail-type")
2020
detail: RawDictOrModel
2121
replay_name: Optional[str] = Field(None, alias="replay-name")
22+
23+
@field_validator("detail", mode="before")
24+
def validate_detail(cls, v, fields):
25+
# EventBridge Scheduler sends detail field as '{}' string when no payload is present
26+
# See: https://github.com/aws-powertools/powertools-lambda-python/issues/6112
27+
return {} if fields.data.get("source") == "aws.scheduler" and v == "{}" else v

docs/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# v9.1.18
2-
FROM squidfunk/mkdocs-material@sha256:f5bcec4e71c138bcb89c0dccb633c830f54a0218e1aefedaade952b61b908d00
2+
FROM squidfunk/mkdocs-material@sha256:26153027ff0b192d3dbea828f2fe2dd1bf6ff753c58dd542b3ddfe866b08bf60
33
# pip-compile --generate-hashes --output-file=requirements.txt requirements.in
44
COPY requirements.txt /tmp/
55
RUN pip install --require-hashes -r /tmp/requirements.txt

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ site_description: Powertools for AWS Lambda (Python)
33
site_author: Amazon Web Services
44
repo_url: https://github.com/aws-powertools/powertools-lambda-python
55
edit_uri: edit/develop/docs
6+
site_url: https://docs.powertools.aws.dev/lambda/python
67

78
nav:
89
- Homepage:

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "aws-lambda-powertools-python-e2e",
33
"version": "1.0.0",
44
"devDependencies": {
5-
"aws-cdk": "^2.178.2"
5+
"aws-cdk": "^2.1000.2"
66
},
77
"dependencies": {
88
"package-lock.json": "^1.0.0"

0 commit comments

Comments
 (0)