Skip to content

Commit 628b9f8

Browse files
authored
Merge branch 'develop' into chore/pre-release
2 parents 6c6b790 + c2d8f89 commit 628b9f8

File tree

162 files changed

+1953
-1200
lines changed

Some content is hidden

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

162 files changed

+1953
-1200
lines changed

.github/workflows/quality_check.yml

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ jobs:
6868
run: make mypy
6969
- name: Test with pytest
7070
run: make test
71+
- name: Test dependencies with Nox
72+
run: make test-dependencies
7173
- name: Security baseline
7274
run: make security-baseline
7375
- name: Complexity baseline

.github/workflows/release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,12 @@ jobs:
237237

238238
- name: Upload to PyPi prod
239239
if: ${{ !inputs.skip_pypi }}
240-
uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450 # v1.8.14
240+
uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # v1.9.0
241241

242242
# PyPi test maintenance affected us numerous times, leaving for history purposes
243243
# - name: Upload to PyPi test
244244
# if: ${{ !inputs.skip_pypi }}
245-
# uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450 # v1.8.14
245+
# uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # v1.9.0
246246
# with:
247247
# repository-url: https://test.pypi.org/legacy/
248248

.github/workflows/secure_workflows.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Checkout code
3333
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
3434
- name: Ensure 3rd party workflows have SHA pinned
35-
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@76d1d8e0b075d7190b5d59b86da91c7bdbcc99b2 # v3.0.7
35+
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@74606c30450304eee8660aae751818321754feb1 # v3.0.9
3636
with:
3737
allowlist: |
3838
slsa-framework/slsa-github-generator

CHANGELOG.md

+41-6
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,54 @@
88

99
* **event_sources:** change partition and offset field types in KafkaEventRecord ([#4515](https://github.com/aws-powertools/powertools-lambda-python/issues/4515))
1010

11+
## Documentation
12+
13+
* **i-made-this:** add new article about best practices for accelerating serverless development ([#4518](https://github.com/aws-powertools/powertools-lambda-python/issues/4518))
14+
15+
## Features
16+
17+
* **validation:** support JSON Schema referencing in validation utils ([#4508](https://github.com/aws-powertools/powertools-lambda-python/issues/4508))
18+
1119
## Maintenance
1220

13-
* **deps:** bump redis from 5.0.5 to 5.0.6 ([#4527](https://github.com/aws-powertools/powertools-lambda-python/issues/4527))
21+
* **ci:** introduce tests with Nox ([#4537](https://github.com/aws-powertools/powertools-lambda-python/issues/4537))
22+
* **ci:** add the Data Masking feature to nox tests ([#4574](https://github.com/aws-powertools/powertools-lambda-python/issues/4574))
23+
* **ci:** add the Typing feature to nox tests ([#4572](https://github.com/aws-powertools/powertools-lambda-python/issues/4572))
24+
* **ci:** add the Validation feature to nox tests ([#4571](https://github.com/aws-powertools/powertools-lambda-python/issues/4571))
25+
* **ci:** add the Feature Flags feature to nox tests ([#4570](https://github.com/aws-powertools/powertools-lambda-python/issues/4570))
26+
* **ci:** add the Parameters feature to nox tests ([#4569](https://github.com/aws-powertools/powertools-lambda-python/issues/4569))
27+
* **ci:** add the Middleware Factory feature to nox tests ([#4568](https://github.com/aws-powertools/powertools-lambda-python/issues/4568))
28+
* **ci:** add the Metrics feature to nox tests ([#4552](https://github.com/aws-powertools/powertools-lambda-python/issues/4552))
29+
* **ci:** add the Tracer feature to nox tests ([#4567](https://github.com/aws-powertools/powertools-lambda-python/issues/4567))
30+
* **deps:** bump the layer-balancer group in /layer/scripts/layer-balancer with 3 updates ([#4565](https://github.com/aws-powertools/powertools-lambda-python/issues/4565))
1431
* **deps:** bump codecov/codecov-action from 4.4.1 to 4.5.0 ([#4514](https://github.com/aws-powertools/powertools-lambda-python/issues/4514))
15-
* **deps-dev:** bump cdklabs-generative-ai-cdk-constructs from 0.1.182 to 0.1.184 ([#4529](https://github.com/aws-powertools/powertools-lambda-python/issues/4529))
32+
* **deps:** bump squidfunk/mkdocs-material from `96abcbb` to `257eca8` in /docs ([#4540](https://github.com/aws-powertools/powertools-lambda-python/issues/4540))
33+
* **deps:** bump the layer-balancer group in /layer/scripts/layer-balancer with 3 updates ([#4546](https://github.com/aws-powertools/powertools-lambda-python/issues/4546))
34+
* **deps:** bump pypa/gh-action-pypi-publish from 1.8.14 to 1.9.0 ([#4538](https://github.com/aws-powertools/powertools-lambda-python/issues/4538))
35+
* **deps:** bump zgosalvez/github-actions-ensure-sha-pinned-actions from 3.0.7 to 3.0.9 ([#4539](https://github.com/aws-powertools/powertools-lambda-python/issues/4539))
36+
* **deps:** bump fastjsonschema from 2.19.1 to 2.20.0 ([#4543](https://github.com/aws-powertools/powertools-lambda-python/issues/4543))
37+
* **deps:** bump redis from 5.0.5 to 5.0.6 ([#4527](https://github.com/aws-powertools/powertools-lambda-python/issues/4527))
38+
* **deps-dev:** bump urllib3 from 1.26.18 to 1.26.19 in /layer ([#4547](https://github.com/aws-powertools/powertools-lambda-python/issues/4547))
39+
* **deps-dev:** bump aws-cdk-aws-lambda-python-alpha from 2.145.0a0 to 2.146.0a0 ([#4542](https://github.com/aws-powertools/powertools-lambda-python/issues/4542))
40+
* **deps-dev:** bump mypy-boto3-secretsmanager from 1.34.125 to 1.34.128 in the boto-typing group ([#4541](https://github.com/aws-powertools/powertools-lambda-python/issues/4541))
41+
* **deps-dev:** bump mkdocs-material from 9.5.26 to 9.5.27 ([#4544](https://github.com/aws-powertools/powertools-lambda-python/issues/4544))
42+
* **deps-dev:** bump cfn-lint from 0.87.7 to 1.3.0 ([#4577](https://github.com/aws-powertools/powertools-lambda-python/issues/4577))
43+
* **deps-dev:** bump cdklabs-generative-ai-cdk-constructs from 0.1.188 to 0.1.189 ([#4564](https://github.com/aws-powertools/powertools-lambda-python/issues/4564))
44+
* **deps-dev:** bump hvac from 2.2.0 to 2.3.0 ([#4563](https://github.com/aws-powertools/powertools-lambda-python/issues/4563))
45+
* **deps-dev:** bump filelock from 3.15.1 to 3.15.3 ([#4576](https://github.com/aws-powertools/powertools-lambda-python/issues/4576))
46+
* **deps-dev:** bump ruff from 0.4.8 to 0.4.9 ([#4528](https://github.com/aws-powertools/powertools-lambda-python/issues/4528))
1647
* **deps-dev:** bump aws-cdk-lib from 2.145.0 to 2.146.0 ([#4526](https://github.com/aws-powertools/powertools-lambda-python/issues/4526))
17-
* **deps-dev:** bump cfn-lint from 0.87.6 to 0.87.7 ([#4513](https://github.com/aws-powertools/powertools-lambda-python/issues/4513))
1848
* **deps-dev:** bump filelock from 3.14.0 to 3.15.1 ([#4512](https://github.com/aws-powertools/powertools-lambda-python/issues/4512))
19-
* **deps-dev:** bump cdklabs-generative-ai-cdk-constructs from 0.1.179 to 0.1.182 ([#4510](https://github.com/aws-powertools/powertools-lambda-python/issues/4510))
2049
* **deps-dev:** bump aws-cdk from 2.145.0 to 2.146.0 ([#4525](https://github.com/aws-powertools/powertools-lambda-python/issues/4525))
21-
* **deps-dev:** bump mypy-boto3-secretsmanager from 1.34.109 to 1.34.125 in the boto-typing group ([#4509](https://github.com/aws-powertools/powertools-lambda-python/issues/4509))
22-
* **deps-dev:** bump ruff from 0.4.8 to 0.4.9 ([#4528](https://github.com/aws-powertools/powertools-lambda-python/issues/4528))
50+
* **deps-dev:** bump cdklabs-generative-ai-cdk-constructs from 0.1.182 to 0.1.184 ([#4529](https://github.com/aws-powertools/powertools-lambda-python/issues/4529))
2351
* **deps-dev:** bump bandit from 1.7.8 to 1.7.9 ([#4511](https://github.com/aws-powertools/powertools-lambda-python/issues/4511))
52+
* **deps-dev:** bump cfn-lint from 0.87.6 to 0.87.7 ([#4513](https://github.com/aws-powertools/powertools-lambda-python/issues/4513))
53+
* **deps-dev:** bump cdklabs-generative-ai-cdk-constructs from 0.1.189 to 0.1.192 ([#4578](https://github.com/aws-powertools/powertools-lambda-python/issues/4578))
54+
* **deps-dev:** bump cdklabs-generative-ai-cdk-constructs from 0.1.179 to 0.1.182 ([#4510](https://github.com/aws-powertools/powertools-lambda-python/issues/4510))
55+
* **deps-dev:** bump sentry-sdk from 2.5.1 to 2.6.0 ([#4579](https://github.com/aws-powertools/powertools-lambda-python/issues/4579))
56+
* **deps-dev:** bump mypy-boto3-secretsmanager from 1.34.109 to 1.34.125 in the boto-typing group ([#4509](https://github.com/aws-powertools/powertools-lambda-python/issues/4509))
57+
* **deps-dev:** bump cdklabs-generative-ai-cdk-constructs from 0.1.184 to 0.1.188 ([#4550](https://github.com/aws-powertools/powertools-lambda-python/issues/4550))
58+
* **governance:** fix errors when creating Gitpod environment ([#4532](https://github.com/aws-powertools/powertools-lambda-python/issues/4532))
2459

2560

2661
<a name="v2.39.1"></a>

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ timeline
6767
Pre-Pull Request <br> (make pr) : Code linting
6868
: Docs linting
6969
: Static typing analysis
70-
: Tests (unit|functional|perf)
70+
: Tests (unit|functional|perf|dependencies)
7171
: Security baseline
7272
: Complexity baseline
7373
: +pre-commit checks

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ test:
3232
poetry run pytest -m "not perf" --ignore tests/e2e --cov=aws_lambda_powertools --cov-report=xml
3333
poetry run pytest --cache-clear tests/performance
3434

35+
test-dependencies:
36+
poetry run nox --error-on-external-run --reuse-venv=yes --non-interactive
37+
3538
test-pydanticv2:
3639
poetry run pytest -m "not perf" --ignore tests/e2e
3740

@@ -83,7 +86,7 @@ complexity-baseline:
8386
$(info Maintenability index)
8487
poetry run radon mi aws_lambda_powertools
8588
$(info Cyclomatic complexity index)
86-
poetry run xenon --max-absolute C --max-modules A --max-average A aws_lambda_powertools --exclude aws_lambda_powertools/shared/json_encoder.py
89+
poetry run xenon --max-absolute C --max-modules A --max-average A aws_lambda_powertools --exclude aws_lambda_powertools/shared/json_encoder.py,aws_lambda_powertools/utilities/validation/base.py
8790

8891
#
8992
# Use `poetry version <major>/<minor></patch>` for version bump

aws_lambda_powertools/utilities/validation/base.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@
33

44
import fastjsonschema # type: ignore
55

6-
from .exceptions import InvalidSchemaFormatError, SchemaValidationError
6+
from aws_lambda_powertools.utilities.validation.exceptions import InvalidSchemaFormatError, SchemaValidationError
77

88
logger = logging.getLogger(__name__)
99

1010

11-
def validate_data_against_schema(data: Union[Dict, str], schema: Dict, formats: Optional[Dict] = None):
11+
def validate_data_against_schema(
12+
data: Union[Dict, str],
13+
schema: Dict,
14+
formats: Optional[Dict] = None,
15+
handlers: Optional[Dict] = None,
16+
provider_options: Optional[Dict] = None,
17+
):
1218
"""Validate dict data against given JSON Schema
1319
1420
Parameters
@@ -19,6 +25,11 @@ def validate_data_against_schema(data: Union[Dict, str], schema: Dict, formats:
1925
JSON Schema to validate against
2026
formats: Dict
2127
Custom formats containing a key (e.g. int64) and a value expressed as regex or callback returning bool
28+
handlers: Dict
29+
Custom methods to retrieve remote schemes, keyed off of URI scheme
30+
provider_options: Dict
31+
Arguments that will be passed directly to the underlying validation call, in this case fastjsonchema.validate.
32+
For all supported arguments see: https://horejsek.github.io/python-fastjsonschema/#fastjsonschema.validate
2233
2334
Raises
2435
------
@@ -29,7 +40,9 @@ def validate_data_against_schema(data: Union[Dict, str], schema: Dict, formats:
2940
"""
3041
try:
3142
formats = formats or {}
32-
fastjsonschema.validate(definition=schema, data=data, formats=formats)
43+
handlers = handlers or {}
44+
provider_options = provider_options or {}
45+
fastjsonschema.validate(definition=schema, data=data, formats=formats, handlers=handlers, **provider_options)
3346
except (TypeError, AttributeError, fastjsonschema.JsonSchemaDefinitionException) as e:
3447
raise InvalidSchemaFormatError(f"Schema received: {schema}, Formats: {formats}. Error: {e}")
3548
except fastjsonschema.JsonSchemaValueException as e:

aws_lambda_powertools/utilities/validation/exceptions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Any, List, Optional
22

3-
from ...exceptions import InvalidEnvelopeExpressionError
3+
from aws_lambda_powertools.exceptions import InvalidEnvelopeExpressionError
44

55

66
class SchemaValidationError(Exception):

aws_lambda_powertools/utilities/validation/validator.py

+44-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import logging
22
from typing import Any, Callable, Dict, Optional, Union
33

4+
from aws_lambda_powertools.middleware_factory import lambda_handler_decorator
45
from aws_lambda_powertools.utilities import jmespath_utils
5-
6-
from ...middleware_factory import lambda_handler_decorator
7-
from .base import validate_data_against_schema
6+
from aws_lambda_powertools.utilities.validation.base import validate_data_against_schema
87

98
logger = logging.getLogger(__name__)
109

@@ -16,8 +15,12 @@ def validator(
1615
context: Any,
1716
inbound_schema: Optional[Dict] = None,
1817
inbound_formats: Optional[Dict] = None,
18+
inbound_handlers: Optional[Dict] = None,
19+
inbound_provider_options: Optional[Dict] = None,
1920
outbound_schema: Optional[Dict] = None,
2021
outbound_formats: Optional[Dict] = None,
22+
outbound_handlers: Optional[Dict] = None,
23+
outbound_provider_options: Optional[Dict] = None,
2124
envelope: str = "",
2225
jmespath_options: Optional[Dict] = None,
2326
**kwargs: Any,
@@ -44,6 +47,17 @@ def validator(
4447
Custom formats containing a key (e.g. int64) and a value expressed as regex or callback returning bool
4548
outbound_formats: Dict
4649
Custom formats containing a key (e.g. int64) and a value expressed as regex or callback returning bool
50+
inbound_handlers: Dict
51+
Custom methods to retrieve remote schemes, keyed off of URI scheme
52+
outbound_handlers: Dict
53+
Custom methods to retrieve remote schemes, keyed off of URI scheme
54+
inbound_provider_options: Dict
55+
Arguments that will be passed directly to the underlying validation call, in this case fastjsonchema.validate.
56+
For all supported arguments see: https://horejsek.github.io/python-fastjsonschema/#fastjsonschema.validate
57+
outbound_provider_options: Dict
58+
Arguments that will be passed directly to the underlying validation call, in this case fastjsonchema.validate.
59+
For all supported arguments see: https://horejsek.github.io/python-fastjsonschema/#fastjsonschema.validate
60+
4761
4862
Example
4963
-------
@@ -127,13 +141,25 @@ def handler(event, context):
127141

128142
if inbound_schema:
129143
logger.debug("Validating inbound event")
130-
validate_data_against_schema(data=event, schema=inbound_schema, formats=inbound_formats)
144+
validate_data_against_schema(
145+
data=event,
146+
schema=inbound_schema,
147+
formats=inbound_formats,
148+
handlers=inbound_handlers,
149+
provider_options=inbound_provider_options,
150+
)
131151

132152
response = handler(event, context, **kwargs)
133153

134154
if outbound_schema:
135155
logger.debug("Validating outbound event")
136-
validate_data_against_schema(data=response, schema=outbound_schema, formats=outbound_formats)
156+
validate_data_against_schema(
157+
data=response,
158+
schema=outbound_schema,
159+
formats=outbound_formats,
160+
handlers=outbound_handlers,
161+
provider_options=outbound_provider_options,
162+
)
137163

138164
return response
139165

@@ -142,6 +168,8 @@ def validate(
142168
event: Any,
143169
schema: Dict,
144170
formats: Optional[Dict] = None,
171+
handlers: Optional[Dict] = None,
172+
provider_options: Optional[Dict] = None,
145173
envelope: Optional[str] = None,
146174
jmespath_options: Optional[Dict] = None,
147175
):
@@ -161,6 +189,10 @@ def validate(
161189
Alternative JMESPath options to be included when filtering expr
162190
formats: Dict
163191
Custom formats containing a key (e.g. int64) and a value expressed as regex or callback returning bool
192+
handlers: Dict
193+
Custom methods to retrieve remote schemes, keyed off of URI scheme
194+
provider_options: Dict
195+
Arguments that will be passed directly to the underlying validate call
164196
165197
Example
166198
-------
@@ -229,4 +261,10 @@ def handler(event, context):
229261
jmespath_options=jmespath_options,
230262
)
231263

232-
validate_data_against_schema(data=event, schema=schema, formats=formats)
264+
validate_data_against_schema(
265+
data=event,
266+
schema=schema,
267+
formats=formats,
268+
handlers=handlers,
269+
provider_options=provider_options,
270+
)

docs/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# v9.1.18
2-
FROM squidfunk/mkdocs-material@sha256:96abcbb1bb6d4d79a6a142fe88150b3862b2b297fe45e6656b154d978b1787eb
2+
FROM squidfunk/mkdocs-material@sha256:257eca88da7f42242cd05e8cebf6d10ebd079edc207b089ad3f4f1ad107b0348
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

docs/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ There are many ways you can help us gain future investments to improve everyone'
398398

399399
Add your company name and logo on our [landing page](https://powertools.aws.dev).
400400

401-
[:octicons-arrow-right-24: GitHub Issue template]((https://github.com/aws-powertools/powertools-lambda-python/issues/new?assignees=&labels=customer-reference&template=support_powertools.yml&title=%5BSupport+Lambda+Powertools%5D%3A+%3Cyour+organization+name%3E){target="_blank"})
401+
[:octicons-arrow-right-24: GitHub Issue template](https://github.com/aws-powertools/powertools-lambda-python/issues/new?assignees=&labels=customer-reference&template=support_powertools.yml&title=%5BSupport+Lambda+Powertools%5D%3A+%3Cyour+organization+name%3E){target="_blank"}
402402

403403
- :mega:{ .lg .middle } __Share your work__
404404

docs/utilities/validation.md

+32-2
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ Here is a handy table with built-in envelopes along with their JMESPath expressi
147147
| **`API_GATEWAY_HTTP`** | `powertools_json(body)` |
148148
| **`API_GATEWAY_REST`** | `powertools_json(body)` |
149149
| **`CLOUDWATCH_EVENTS_SCHEDULED`** | `detail` |
150-
| **`CLOUDWATCH_LOGS`** | `awslogs.powertools_base64_gzip(data) | powertools_json(@).logEvents[*]` |
150+
| **`CLOUDWATCH_LOGS`** | `awslogs.powertools_base64_gzip(data)` or `powertools_json(@).logEvents[*]` |
151151
| **`EVENTBRIDGE`** | `detail` |
152152
| **`KINESIS_DATA_STREAM`** | `Records[*].kinesis.powertools_json(powertools_base64(data))` |
153-
| **`SNS`** | `Records[0].Sns.Message | powertools_json(@)` |
153+
| **`SNS`** | `Records[0].Sns.Message` or `powertools_json(@)` |
154154
| **`SQS`** | `Records[*].powertools_json(body)` |
155155

156156
## Advanced
@@ -199,3 +199,33 @@ You can use our built-in [JMESPath functions](./jmespath_functions.md){target="_
199199

200200
???+ info
201201
We use these for [built-in envelopes](#built-in-envelopes) to easily to decode and unwrap events from sources like Kinesis, CloudWatch Logs, etc.
202+
203+
### Validating with external references
204+
205+
JSON Schema [allows schemas to reference other schemas](https://json-schema.org/understanding-json-schema/structuring#dollarref) using the `$ref` keyword with a URI value. By default, `fastjsonschema` will make a HTTP request to resolve this URI.
206+
207+
You can use `handlers` parameter to have full control over how references schemas are fetched. This is useful when you might want to optimize caching, reducing HTTP calls, or fetching them from non-HTTP endpoints.
208+
209+
=== "custom_handlers.py"
210+
211+
```python hl_lines="1 7 8 11"
212+
--8<-- "examples/validation/src/custom_handlers.py"
213+
```
214+
215+
=== "custom_handlers_parent_schema"
216+
217+
```python hl_lines="1 7"
218+
--8<-- "examples/validation/src/custom_handlers_schema.py"
219+
```
220+
221+
=== "custom_handlers_child_schema"
222+
223+
```python hl_lines="12"
224+
--8<-- "examples/validation/src/custom_handlers_schema.py"
225+
```
226+
227+
=== "custom_handlers_payload.json"
228+
229+
```json hl_lines="2"
230+
--8<-- "examples/validation/src/custom_handlers_payload.json"
231+
```

0 commit comments

Comments
 (0)