Skip to content

Commit 2cfef59

Browse files
Merge branch 'develop' into fix/thread-safe-tests
2 parents 1e92d75 + 6e900c7 commit 2cfef59

14 files changed

Lines changed: 102 additions & 30 deletions

File tree

CHANGELOG.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
## Bug Fixes
88

9+
* **event_source:** fix decode headers with signed bytes ([#6878](https://github.com/aws-powertools/powertools-lambda-python/issues/6878))
10+
* **logger:** caplog working with parent Logger ([#6847](https://github.com/aws-powertools/powertools-lambda-python/issues/6847))
911
* **logger:** fix exception on flush without buffer ([#6794](https://github.com/aws-powertools/powertools-lambda-python/issues/6794))
1012

1113
## Features
@@ -14,29 +16,31 @@
1416

1517
## Maintenance
1618

17-
* **ci:** new pre-release 3.15.2a2 ([#6865](https://github.com/aws-powertools/powertools-lambda-python/issues/6865))
19+
* **ci:** new pre-release 3.15.2a3 ([#6876](https://github.com/aws-powertools/powertools-lambda-python/issues/6876))
1820
* **ci:** new pre-release 3.15.2a0 ([#6852](https://github.com/aws-powertools/powertools-lambda-python/issues/6852))
1921
* **ci:** new pre-release 3.15.2a1 ([#6860](https://github.com/aws-powertools/powertools-lambda-python/issues/6860))
20-
* **ci:** new pre-release 3.15.2a3 ([#6876](https://github.com/aws-powertools/powertools-lambda-python/issues/6876))
22+
* **ci:** new pre-release 3.15.2a2 ([#6865](https://github.com/aws-powertools/powertools-lambda-python/issues/6865))
23+
* **ci:** new pre-release 3.15.2a4 ([#6881](https://github.com/aws-powertools/powertools-lambda-python/issues/6881))
2124
* **ci:** fix command to replace layer number ([#6868](https://github.com/aws-powertools/powertools-lambda-python/issues/6868))
2225
* **deps:** bump valkey-glide from 1.3.5 to 2.0.1 ([#6871](https://github.com/aws-powertools/powertools-lambda-python/issues/6871))
23-
* **deps:** bump pydantic-settings from 2.9.1 to 2.10.1 ([#6872](https://github.com/aws-powertools/powertools-lambda-python/issues/6872))
24-
* **deps:** bump datadog-lambda from 6.110.0 to 6.111.0 ([#6857](https://github.com/aws-powertools/powertools-lambda-python/issues/6857))
2526
* **deps:** bump redis from 5.3.0 to 6.2.0 ([#6827](https://github.com/aws-powertools/powertools-lambda-python/issues/6827))
27+
* **deps:** bump pydantic-settings from 2.9.1 to 2.10.1 ([#6872](https://github.com/aws-powertools/powertools-lambda-python/issues/6872))
2628
* **deps:** bump pydantic from 2.11.5 to 2.11.7 ([#6844](https://github.com/aws-powertools/powertools-lambda-python/issues/6844))
2729
* **deps:** bump docker/setup-buildx-action from 3.10.0 to 3.11.1 ([#6823](https://github.com/aws-powertools/powertools-lambda-python/issues/6823))
28-
* **deps-dev:** bump boto3-stubs from 1.38.42 to 1.38.43 ([#6864](https://github.com/aws-powertools/powertools-lambda-python/issues/6864))
30+
* **deps:** bump datadog-lambda from 6.110.0 to 6.111.0 ([#6857](https://github.com/aws-powertools/powertools-lambda-python/issues/6857))
2931
* **deps-dev:** bump pytest from 8.4.0 to 8.4.1 ([#6874](https://github.com/aws-powertools/powertools-lambda-python/issues/6874))
32+
* **deps-dev:** bump boto3-stubs from 1.38.41 to 1.38.42 ([#6858](https://github.com/aws-powertools/powertools-lambda-python/issues/6858))
33+
* **deps-dev:** bump boto3-stubs from 1.38.43 to 1.38.44 ([#6873](https://github.com/aws-powertools/powertools-lambda-python/issues/6873))
3034
* **deps-dev:** bump aws-cdk from 2.1019.1 to 2.1019.2 ([#6875](https://github.com/aws-powertools/powertools-lambda-python/issues/6875))
3135
* **deps-dev:** bump sentry-sdk from 2.29.1 to 2.31.0 ([#6870](https://github.com/aws-powertools/powertools-lambda-python/issues/6870))
3236
* **deps-dev:** bump aws-cdk from 2.1018.1 to 2.1019.1 ([#6837](https://github.com/aws-powertools/powertools-lambda-python/issues/6837))
3337
* **deps-dev:** bump mypy from 1.16.0 to 1.16.1 ([#6828](https://github.com/aws-powertools/powertools-lambda-python/issues/6828))
34-
* **deps-dev:** bump boto3-stubs from 1.38.43 to 1.38.44 ([#6873](https://github.com/aws-powertools/powertools-lambda-python/issues/6873))
38+
* **deps-dev:** bump bandit from 1.8.3 to 1.8.5 ([#6856](https://github.com/aws-powertools/powertools-lambda-python/issues/6856))
3539
* **deps-dev:** bump boto3-stubs from 1.38.34 to 1.38.41 ([#6845](https://github.com/aws-powertools/powertools-lambda-python/issues/6845))
3640
* **deps-dev:** bump aws-cdk-aws-lambda-python-alpha from 2.200.1a0 to 2.202.0a0 ([#6846](https://github.com/aws-powertools/powertools-lambda-python/issues/6846))
41+
* **deps-dev:** bump boto3-stubs from 1.38.42 to 1.38.43 ([#6864](https://github.com/aws-powertools/powertools-lambda-python/issues/6864))
42+
* **deps-dev:** bump boto3-stubs from 1.38.44 to 1.38.45 ([#6880](https://github.com/aws-powertools/powertools-lambda-python/issues/6880))
3743
* **deps-dev:** bump cfn-lint from 1.35.4 to 1.36.1 ([#6855](https://github.com/aws-powertools/powertools-lambda-python/issues/6855))
38-
* **deps-dev:** bump bandit from 1.8.3 to 1.8.5 ([#6856](https://github.com/aws-powertools/powertools-lambda-python/issues/6856))
39-
* **deps-dev:** bump boto3-stubs from 1.38.41 to 1.38.42 ([#6858](https://github.com/aws-powertools/powertools-lambda-python/issues/6858))
4044

4145

4246
<a name="v3.15.1"></a>

aws_lambda_powertools/logging/logger.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,9 @@ def _init_logger(
374374
if not self._is_deduplication_disabled:
375375
logger.debug("Adding filter in root logger to suppress child logger records to bubble up")
376376
for handler in logging.root.handlers:
377+
# skip suppressing pytest's handler, allowing caplog fixture usage
378+
if type(handler).__name__ == "LogCaptureHandler" and type(handler).__module__ == "_pytest.logging":
379+
continue
377380
# It'll add a filter to suppress any child logger from self.service
378381
# Example: `Logger(service="order")`, where service is Order
379382
# It'll reject all loggers starting with `order` e.g. order.checkout, order.shared

aws_lambda_powertools/shared/functions.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,3 +291,19 @@ def sanitize_xray_segment_name(name: str) -> str:
291291
def get_tracer_id() -> str | None:
292292
xray_trace_id = os.getenv(constants.XRAY_TRACE_ID_ENV)
293293
return xray_trace_id.split(";")[0].replace("Root=", "") if xray_trace_id else None
294+
295+
296+
def decode_header_bytes(byte_list):
297+
"""
298+
Decode a list of byte values that might be signed.
299+
If any negative values exist, handle them as signed bytes.
300+
Otherwise use the normal bytes construction.
301+
"""
302+
has_negative = any(b < 0 for b in byte_list)
303+
304+
if not has_negative:
305+
# Use normal bytes construction if all values are positive
306+
return bytes(byte_list)
307+
# Convert signed bytes to unsigned (0-255 range)
308+
unsigned_bytes = [(b & 0xFF) for b in byte_list]
309+
return bytes(unsigned_bytes)
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.15.2a3"
3+
VERSION = "3.15.2a4"

aws_lambda_powertools/utilities/data_classes/kafka_event.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from functools import cached_property
55
from typing import TYPE_CHECKING, Any
66

7+
from aws_lambda_powertools.shared.functions import decode_header_bytes
78
from aws_lambda_powertools.utilities.data_classes.common import CaseInsensitiveDict, DictWrapper
89

910
if TYPE_CHECKING:
@@ -110,7 +111,7 @@ def headers(self) -> list[dict[str, list[int]]]:
110111
@cached_property
111112
def decoded_headers(self) -> dict[str, bytes]:
112113
"""Decodes the headers as a single dictionary."""
113-
return CaseInsensitiveDict((k, bytes(v)) for chunk in self.headers for k, v in chunk.items())
114+
return CaseInsensitiveDict((k, decode_header_bytes(v)) for chunk in self.headers for k, v in chunk.items())
114115

115116

116117
class KafkaEventBase(DictWrapper):

aws_lambda_powertools/utilities/kafka/consumer_records.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from functools import cached_property
55
from typing import TYPE_CHECKING, Any
66

7+
from aws_lambda_powertools.shared.functions import decode_header_bytes
78
from aws_lambda_powertools.utilities.data_classes.common import CaseInsensitiveDict
89
from aws_lambda_powertools.utilities.data_classes.kafka_event import KafkaEventBase, KafkaEventRecordBase
910
from aws_lambda_powertools.utilities.kafka.deserializer.deserializer import get_deserializer
@@ -115,7 +116,9 @@ def original_headers(self) -> list[dict[str, list[int]]]:
115116
@cached_property
116117
def headers(self) -> dict[str, bytes]:
117118
"""Decodes the headers as a single dictionary."""
118-
return CaseInsensitiveDict((k, bytes(v)) for chunk in self.original_headers for k, v in chunk.items())
119+
return CaseInsensitiveDict(
120+
(k, decode_header_bytes(v)) for chunk in self.original_headers for k, v in chunk.items()
121+
)
119122

120123

121124
class ConsumerRecords(KafkaEventBase):

aws_lambda_powertools/utilities/parser/models/kafka.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from pydantic import BaseModel, field_validator
55

6-
from aws_lambda_powertools.shared.functions import base64_decode, bytes_to_string
6+
from aws_lambda_powertools.shared.functions import base64_decode, bytes_to_string, decode_header_bytes
77

88
SERVERS_DELIMITER = ","
99

@@ -28,9 +28,7 @@ class KafkaRecordModel(BaseModel):
2828
# key is optional; only decode if not None
2929
@field_validator("key", mode="before")
3030
def decode_key(cls, value):
31-
if value is not None:
32-
return base64_decode(value)
33-
return value
31+
return base64_decode(value) if value is not None else value
3432

3533
@field_validator("value", mode="before")
3634
def data_base64_decode(cls, value):
@@ -41,7 +39,7 @@ def data_base64_decode(cls, value):
4139
def decode_headers_list(cls, value):
4240
for header in value:
4341
for key, values in header.items():
44-
header[key] = bytes(values)
42+
header[key] = decode_header_bytes(values)
4543
return value
4644

4745

@@ -51,7 +49,7 @@ class KafkaBaseEventModel(BaseModel):
5149

5250
@field_validator("bootstrapServers", mode="before")
5351
def split_servers(cls, value):
54-
return None if not value else value.split(SERVERS_DELIMITER)
52+
return value.split(SERVERS_DELIMITER) if value else None
5553

5654

5755
class KafkaSelfManagedEventModel(KafkaBaseEventModel):

poetry.lock

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

provenance/3.15.2a4/multiple.intoto.jsonl

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "aws_lambda_powertools"
3-
version = "3.15.2a3"
3+
version = "3.15.2a4"
44
description = "Powertools for AWS Lambda (Python) is a developer toolkit to implement Serverless best practices and increase developer velocity."
55
authors = ["Amazon Web Services"]
66
include = ["aws_lambda_powertools/py.typed", "THIRD-PARTY-LICENSES"]

0 commit comments

Comments
 (0)