Skip to content

Commit 2a77841

Browse files
committed
Merge branch 'develop' into boto
* develop: (33 commits) fix(docs): remove Slack link (aws-powertools#1210) docs(roadmap): add new roadmap section (aws-powertools#1204) fix(batch): missing space in BatchProcessingError message (aws-powertools#1201) fix(batch): docstring fix for success_handler() record parameter (aws-powertools#1202) chore(deps): bump email-validator from 1.1.3 to 1.2.1 (aws-powertools#1199) docs(layer): upgrade to 1.25.10 chore: include regression in changelog chore: bump to 1.25.10 feat(parameters): add clear_cache method for providers (aws-powertools#1194) chore(ci): changelog pre-generation to fetch tags from origin revert(parser): Add missing fields for SESEvent (aws-powertools#1027) (aws-powertools#1190) fix(parser): Add missing fields for SESEvent (aws-powertools#1027) fix(data-classes): Add missing SES fields and (aws-powertools#1045) fix(event_handler): exception_handler to handle ServiceError exceptions (aws-powertools#1160) chore(deps-dev): bump flake8-bugbear from 22.1.11 to 22.4.25 (aws-powertools#1156) chore(deps-dev): bump mypy from 0.942 to 0.950 (aws-powertools#1162) chore(deps-dev): bump flake8-eradicate from 1.2.0 to 1.2.1 (aws-powertools#1158) chore(deps): bump github/codeql-action from 1 to 2 (aws-powertools#1154) chore(ci): post release on tagged issues too fix(event_handler): Allow for event_source support (aws-powertools#1159) ...
2 parents ccc378b + 0777858 commit 2a77841

File tree

25 files changed

+574
-135
lines changed

25 files changed

+574
-135
lines changed

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ updates:
1717
commit-message:
1818
prefix: chore
1919
include: scope
20+
ignore:
21+
# 2022-04-23: Ignoring boto3 changes until we need to care about them.
22+
- dependency-name: "boto3"
23+
2024

2125
# - package-ecosystem: "pip"
2226
# directory: "/"

.github/mergify.yml

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
1-
queue_rules:
2-
- name: default
3-
conditions:
4-
# Conditions to get out of the queue (= merged)
5-
- check-success=Semantic Pull Request
6-
- "#approved-reviews-by>=1"
7-
- -title~=(WIP|wip)
8-
- -label~="do-not-merge"
9-
- "#changes-requested-reviews-by=0"
1+
## Temporarily disabled after Mergify breaking changes
2+
## might move to custom GitHub Actions altogether
3+
# queue_rules:
4+
# - name: default
5+
# conditions:
6+
# # Conditions to get out of the queue (= merged)
7+
# - check-success=Semantic Pull Request
8+
# - "#approved-reviews-by>=1"
9+
# - -title~=(WIP|wip)
10+
# - -label~="do-not-merge"
11+
# - "#changes-requested-reviews-by=0"
1012

11-
pull_request_rules:
12-
- name: automatic merge for Dependabot pull requests
13-
conditions:
14-
- author~=^dependabot(|-preview)\[bot\]$
15-
actions:
16-
queue:
17-
name: default
18-
method: squash
19-
commit_message: title+body
13+
# pull_request_rules:
14+
# - name: automatic merge for Dependabot pull requests
15+
# conditions:
16+
# - author~=^dependabot(|-preview)\[bot\]$
17+
# actions:
18+
# queue:
19+
# name: default
20+
# method: squash
21+
# commit_message: title+body
2022

21-
- name: Automatic merge ⬇️ on approval ✔
22-
conditions:
23-
- base!=master
24-
- "#approved-reviews-by>=2"
25-
actions:
26-
queue:
27-
name: default
28-
method: squash
29-
commit_message: title+body
23+
# - name: Automatic merge ⬇️ on approval ✔
24+
# conditions:
25+
# - base!=master
26+
# - "#approved-reviews-by>=2"
27+
# actions:
28+
# queue:
29+
# name: default
30+
# method: squash
31+
# commit_message: title+body

.github/workflows/codeql-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424

2525
# Initializes the CodeQL tools for scanning.
2626
- name: Initialize CodeQL
27-
uses: github/codeql-action/init@v1
27+
uses: github/codeql-action/init@v2
2828
with:
2929
languages: ${{ matrix.language }}
3030
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -33,4 +33,4 @@ jobs:
3333
# queries: ./path/to/local/query, your-org/your-repo/queries@main
3434

3535
- name: Perform CodeQL Analysis
36-
uses: github/codeql-action/analyze@v1
36+
uses: github/codeql-action/analyze@v2

.github/workflows/post_release.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const fetchIssues = async ({
1515
gh_client,
1616
org,
1717
repository,
18-
state = "open",
18+
state = "all",
1919
label = STAGED_LABEL,
2020
}) => {
2121

.github/workflows/python_build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
- name: Complexity baseline
4040
run: make complexity-baseline
4141
- name: Upload coverage to Codecov
42-
uses: codecov/codecov-action@v3.0.0
42+
uses: codecov/codecov-action@v3.1.0
4343
with:
4444
file: ./coverage.xml
4545
# flags: unittests

CHANGELOG.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,69 @@ All notable changes to this project will be documented in this file.
44

55
This project follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format for changes and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## 1.25.10 - 2022-04-29
8+
9+
### Bug Fixes
10+
11+
* **data-classes:** Add missing SES fields and ([#1045](https://github.com/awslabs/aws-lambda-powertools-python/issues/1045))
12+
* **deps:** Ignore boto3 changes until needed ([#1151](https://github.com/awslabs/aws-lambda-powertools-python/issues/1151))
13+
* **deps-dev:** remove jmespath due to dev deps conflict ([#1148](https://github.com/awslabs/aws-lambda-powertools-python/issues/1148))
14+
* **event_handler:** exception_handler to handle ServiceError exceptions ([#1160](https://github.com/awslabs/aws-lambda-powertools-python/issues/1160))
15+
* **event_handler:** Allow for event_source support ([#1159](https://github.com/awslabs/aws-lambda-powertools-python/issues/1159))
16+
* **parser:** Add missing fields for SESEvent ([#1027](https://github.com/awslabs/aws-lambda-powertools-python/issues/1027))
17+
18+
### Documentation
19+
20+
* **layer:** upgrade to 1.25.9
21+
22+
### Features
23+
24+
* **parameters:** add clear_cache method for providers ([#1194](https://github.com/awslabs/aws-lambda-powertools-python/issues/1194))
25+
26+
### Maintenance
27+
28+
* **ci:** changelog pre-generation to fetch tags from origin
29+
* **ci:** post release on tagged issues too
30+
* **ci:** disable mergify configuration after breaking changes ([#1188](https://github.com/awslabs/aws-lambda-powertools-python/issues/1188))
31+
* **deps:** bump codecov/codecov-action from 3.0.0 to 3.1.0 ([#1143](https://github.com/awslabs/aws-lambda-powertools-python/issues/1143))
32+
* **deps:** bump github/codeql-action from 1 to 2 ([#1154](https://github.com/awslabs/aws-lambda-powertools-python/issues/1154))
33+
* **deps-dev:** bump flake8-bugbear from 22.1.11 to 22.4.25 ([#1156](https://github.com/awslabs/aws-lambda-powertools-python/issues/1156))
34+
* **deps-dev:** bump flake8-eradicate from 1.2.0 to 1.2.1 ([#1158](https://github.com/awslabs/aws-lambda-powertools-python/issues/1158))
35+
* **deps-dev:** bump mkdocs-git-revision-date-plugin ([#1146](https://github.com/awslabs/aws-lambda-powertools-python/issues/1146))
36+
* **deps-dev:** bump mypy from 0.942 to 0.950 ([#1162](https://github.com/awslabs/aws-lambda-powertools-python/issues/1162))
37+
* **deps-dev:** bump xenon from 0.8.0 to 0.9.0 ([#1145](https://github.com/awslabs/aws-lambda-powertools-python/issues/1145))
38+
* **deps-dev:** bump mypy from 0.931 to 0.942 ([#1133](https://github.com/awslabs/aws-lambda-powertools-python/issues/1133))
39+
40+
### Regression
41+
42+
* **parser:** Add missing fields for SESEvent ([#1027](https://github.com/awslabs/aws-lambda-powertools-python/issues/1027)) ([#1190](https://github.com/awslabs/aws-lambda-powertools-python/issues/1190))
43+
44+
## 1.25.9 - 2022-04-21
45+
46+
### Bug Fixes
47+
48+
* **deps**: correct py36 marker for jmespath
49+
## 1.25.8 - 2022-04-21
50+
51+
### Bug Fixes
52+
53+
* **governance:** removed ambiguous quotes from labels
54+
* **deps:** update jmespath marker to support 1.0 and py3.6 ([#1139](https://github.com/awslabs/aws-lambda-powertools-python/issues/1139))
55+
* **governance:** update label in names in issues
56+
57+
### Documentation
58+
59+
* **install:** instructions to reduce pydantic package size ([#1077](https://github.com/awslabs/aws-lambda-powertools-python/issues/1077))
60+
* **layer:** remove link from clipboard button ([#1135](https://github.com/awslabs/aws-lambda-powertools-python/issues/1135))
61+
* **layer:** update to 1.25.7
62+
63+
### Maintenance
64+
65+
* **deps:** bump codecov/codecov-action from 2.1.0 to 3.0.0 ([#1102](https://github.com/awslabs/aws-lambda-powertools-python/issues/1102))
66+
* **deps:** bump actions/upload-artifact from 2 to 3 ([#1103](https://github.com/awslabs/aws-lambda-powertools-python/issues/1103))
67+
* **deps-dev:** bump mkdocs-material from 8.2.4 to 8.2.7 ([#1131](https://github.com/awslabs/aws-lambda-powertools-python/issues/1131))
68+
* **deps-dev:** bump pytest from 6.2.5 to 7.0.1 ([#1063](https://github.com/awslabs/aws-lambda-powertools-python/issues/1063))
69+
770
## 1.25.7 - 2022-04-08
871

972
### Bug Fixes

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ release: pr
8484
$(MAKE) release-prod
8585

8686
changelog:
87-
git fetch --tags
87+
git fetch --tags origin
8888
@echo "[+] Pre-generating CHANGELOG for tag: $$(git describe --abbrev=0 --tag)"
8989
docker run -v "${PWD}":/workdir quay.io/git-chglog/git-chglog $$(git describe --abbrev=0 --tag).. > TMP_CHANGELOG.md
9090

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# AWS Lambda Powertools (Python)
1+
# AWS Lambda Powertools for Python
22

33
![Build](https://github.com/awslabs/aws-lambda-powertools/workflows/Powertools%20Python/badge.svg?branch=master)
44
[![codecov.io](https://codecov.io/github/awslabs/aws-lambda-powertools-python/branch/develop/graphs/badge.svg)](https://app.codecov.io/gh/awslabs/aws-lambda-powertools-python)
55
![PythonSupport](https://img.shields.io/static/v1?label=python&message=3.6%20|%203.7|%203.8|%203.9&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)
66

77
A suite of Python utilities for AWS Lambda functions to ease adopting best practices such as tracing, structured logging, custom metrics, and more. (AWS Lambda Powertools [Java](https://github.com/awslabs/aws-lambda-powertools-java) and [Typescript](https://github.com/awslabs/aws-lambda-powertools-typescript) is also available).
88

9-
**[📜Documentation](https://awslabs.github.io/aws-lambda-powertools-python/)** | **[🐍PyPi](https://pypi.org/project/aws-lambda-powertools/)** | **[Roadmap](https://github.com/awslabs/aws-lambda-powertools-roadmap/projects/1)** | **[Detailed blog post](https://aws.amazon.com/blogs/opensource/simplifying-serverless-best-practices-with-lambda-powertools/)**
9+
**[📜Documentation](https://awslabs.github.io/aws-lambda-powertools-python/)** | **[🐍PyPi](https://pypi.org/project/aws-lambda-powertools/)** | **[Roadmap](https://awslabs.github.io/aws-lambda-powertools-python/latest/roadmap/)** | **[Detailed blog post](https://aws.amazon.com/blogs/opensource/simplifying-serverless-best-practices-with-lambda-powertools/)**
1010

1111
> **An AWS Developer Acceleration (DevAx) initiative by Specialist Solution Architects | [email protected]**
1212
@@ -47,9 +47,11 @@ With [pip](https://pip.pypa.io/en/latest/index.html) installed, run: ``pip insta
4747
* Powertools idea [DAZN Powertools](https://github.com/getndazn/dazn-lambda-powertools/)
4848

4949
## Connect
50+
5051

51-
* **AWS Developers Slack**: `#lambda-powertools` - **[Invite, if you don't have an account](https://join.slack.com/t/awsdevelopers/shared_invite/zt-yryddays-C9fkWrmguDv0h2EEDzCqvw)**
52-
* **Email**: [email protected]
52+
## Security disclosures
53+
54+
If you think you’ve found a potential security issue, please do not post it in the Issues. Instead, please follow the instructions [here](https://aws.amazon.com/security/vulnerability-reporting/) or [email AWS security directly](mailto:[email protected]).
5355

5456
## License
5557

aws_lambda_powertools/event_handler/api_gateway.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,11 @@ def resolve(self, event, context) -> Dict[str, Any]:
491491
dict
492492
Returns the dict response
493493
"""
494+
if isinstance(event, BaseProxyEvent):
495+
warnings.warn(
496+
"You don't need to serialize event to Event Source Data Class when using Event Handler; see issue #1152"
497+
)
498+
event = event.raw_event
494499
if self._debug:
495500
print(self._json_dump(event), end="")
496501
BaseRouter.current_event = self._to_proxy_event(event)
@@ -651,7 +656,10 @@ def _lookup_exception_handler(self, exp_type: Type) -> Optional[Callable]:
651656
def _call_exception_handler(self, exp: Exception, route: Route) -> Optional[ResponseBuilder]:
652657
handler = self._lookup_exception_handler(type(exp))
653658
if handler:
654-
return ResponseBuilder(handler(exp), route)
659+
try:
660+
return ResponseBuilder(handler(exp), route)
661+
except ServiceError as service_error:
662+
exp = service_error
655663

656664
if isinstance(exp, ServiceError):
657665
return ResponseBuilder(

aws_lambda_powertools/utilities/batch/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def success_handler(self, record, result: Any) -> SuccessResponse:
116116
Parameters
117117
----------
118118
record: Any
119-
record that failed processing
119+
record that succeeded processing
120120
result: Any
121121
result from record handler
122122
@@ -380,7 +380,7 @@ def _clean(self):
380380

381381
if self._entire_batch_failed():
382382
raise BatchProcessingError(
383-
msg=f"All records failed processing. {len(self.exceptions)} individual errors logged"
383+
msg=f"All records failed processing. {len(self.exceptions)} individual errors logged "
384384
f"separately below.",
385385
child_exceptions=self.exceptions,
386386
)

aws_lambda_powertools/utilities/batch/sqs.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ def _clean(self) -> Optional[List]:
135135
return None
136136

137137
queue_url = self._get_queue_url()
138+
if queue_url is None:
139+
logger.debug("No queue url found")
140+
return None
141+
138142
entries_to_remove = self._get_entries_to_clean()
139143
# Batch delete up to 10 messages at a time (SQS limit)
140144
max_workers = math.ceil(len(entries_to_remove) / self.max_message_batch)

aws_lambda_powertools/utilities/data_classes/ses_event.py

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Iterator, List
1+
from typing import Iterator, List, Optional
22

33
from aws_lambda_powertools.utilities.data_classes.common import DictWrapper
44

@@ -26,7 +26,7 @@ def get_from(self) -> List[str]:
2626
return self["from"]
2727

2828
@property
29-
def date(self) -> List[str]:
29+
def date(self) -> str:
3030
"""The date and time when Amazon SES received the message."""
3131
return self["date"]
3232

@@ -45,6 +45,26 @@ def subject(self) -> str:
4545
"""The value of the Subject header for the email."""
4646
return str(self["subject"])
4747

48+
@property
49+
def cc(self) -> Optional[List[str]]:
50+
"""The values in the CC header of the email."""
51+
return self.get("cc")
52+
53+
@property
54+
def bcc(self) -> Optional[List[str]]:
55+
"""The values in the BCC header of the email."""
56+
return self.get("bcc")
57+
58+
@property
59+
def sender(self) -> Optional[List[str]]:
60+
"""The values in the Sender header of the email."""
61+
return self.get("sender")
62+
63+
@property
64+
def reply_to(self) -> Optional[List[str]]:
65+
"""The values in the replyTo header of the email."""
66+
return self.get("replyTo")
67+
4868

4969
class SESMail(DictWrapper):
5070
@property
@@ -94,6 +114,9 @@ def common_headers(self) -> SESMailCommonHeaders:
94114
class SESReceiptStatus(DictWrapper):
95115
@property
96116
def status(self) -> str:
117+
"""Receipt status
118+
Possible values: 'PASS', 'FAIL', 'GRAY', 'PROCESSING_FAILED', 'DISABLED'
119+
"""
97120
return str(self["status"])
98121

99122

@@ -107,6 +130,12 @@ def get_type(self) -> str:
107130
# Note: this name conflicts with existing python builtins
108131
return self["type"]
109132

133+
@property
134+
def topic_arn(self) -> Optional[str]:
135+
"""String that contains the Amazon Resource Name (ARN) of the Amazon SNS topic to which the
136+
notification was published."""
137+
return self.get("topicArn")
138+
110139
@property
111140
def function_arn(self) -> str:
112141
"""String that contains the ARN of the Lambda function that was triggered.
@@ -154,12 +183,24 @@ def spf_verdict(self) -> SESReceiptStatus:
154183
"""Object that indicates whether the Sender Policy Framework (SPF) check passed."""
155184
return SESReceiptStatus(self["spfVerdict"])
156185

186+
@property
187+
def dkim_verdict(self) -> SESReceiptStatus:
188+
"""Object that indicates whether the DomainKeys Identified Mail (DKIM) check passed"""
189+
return SESReceiptStatus(self["dkimVerdict"])
190+
157191
@property
158192
def dmarc_verdict(self) -> SESReceiptStatus:
159193
"""Object that indicates whether the Domain-based Message Authentication,
160194
Reporting & Conformance (DMARC) check passed."""
161195
return SESReceiptStatus(self["dmarcVerdict"])
162196

197+
@property
198+
def dmarc_policy(self) -> Optional[str]:
199+
"""Indicates the Domain-based Message Authentication, Reporting & Conformance (DMARC) settings for
200+
the sending domain. This field only appears if the message fails DMARC authentication.
201+
Possible values for this field are: none, quarantine, reject"""
202+
return self.get("dmarcPolicy")
203+
163204
@property
164205
def action(self) -> SESReceiptAction:
165206
"""Object that encapsulates information about the action that was executed."""

aws_lambda_powertools/utilities/idempotency/persistence/dynamodb.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(
2222
self,
2323
table_name: str,
2424
key_attr: str = "id",
25-
static_pk_value: str = f"idempotency#{os.getenv(constants.LAMBDA_FUNCTION_NAME_ENV, '')}",
25+
static_pk_value: Optional[str] = None,
2626
sort_key_attr: Optional[str] = None,
2727
expiry_attr: str = "expiration",
2828
status_attr: str = "status",
@@ -76,6 +76,9 @@ def __init__(
7676
if sort_key_attr == key_attr:
7777
raise ValueError(f"key_attr [{key_attr}] and sort_key_attr [{sort_key_attr}] cannot be the same!")
7878

79+
if static_pk_value is None:
80+
static_pk_value = f"idempotency#{os.getenv(constants.LAMBDA_FUNCTION_NAME_ENV, '')}"
81+
7982
self._table = None
8083
self.table_name = table_name
8184
self.key_attr = key_attr

aws_lambda_powertools/utilities/parameters/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""
66

77
from .appconfig import AppConfigProvider, get_app_config
8-
from .base import BaseProvider
8+
from .base import BaseProvider, clear_caches
99
from .dynamodb import DynamoDBProvider
1010
from .exceptions import GetParameterError, TransformParameterError
1111
from .secrets import SecretsProvider, get_secret
@@ -23,4 +23,5 @@
2323
"get_parameter",
2424
"get_parameters",
2525
"get_secret",
26+
"clear_caches",
2627
]

0 commit comments

Comments
 (0)