Skip to content

Commit 60864f4

Browse files
author
Michael Brewer
authored
Merge branch 'awslabs:develop' into docs/1064-jmespath-functions
2 parents a112d38 + 31fe45e commit 60864f4

File tree

13 files changed

+188
-70
lines changed

13 files changed

+188
-70
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

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/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

poetry.lock

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

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ pytest-asyncio = "^0.16.0"
4949
bandit = "^1.7.1"
5050
radon = "^5.1.0"
5151
xenon = "^0.9.0"
52-
flake8-eradicate = "^1.2.0"
53-
flake8-bugbear = "^22.1.11"
52+
flake8-eradicate = "^1.2.1"
53+
flake8-bugbear = "^22.4.25"
5454
mkdocs-git-revision-date-plugin = "^0.3.2"
5555
mike = "^0.6.0"
56-
mypy = "^0.942"
56+
mypy = "^0.950"
5757
mkdocs-material = "^8.2.7"
5858

5959

tests/events/sesEvent.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
"dkimVerdict": {
7878
"status": "PASS"
7979
},
80+
"dmarcPolicy": "reject",
8081
"processingTimeMillis": 574,
8182
"action": {
8283
"type": "Lambda",

0 commit comments

Comments
 (0)