Skip to content

Commit b2e940b

Browse files
reginaldalfretleandrodamascenaclaude
authored
fix(parser): support camelCase replyTo in SesMailCommonHeaders (#8542)
* fix(parser): support camelCase replyTo alias in SesMailCommonHeaders (#8523) Signed-off-by: reginaldalfret <reginaldalfret@gmail.com> * chore(tests): apply ruff format to SES parser test Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Signed-off-by: reginaldalfret <reginaldalfret@gmail.com> Co-authored-by: Leandro Damascena <lcdama@amazon.pt> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 2f58434 commit b2e940b

2 files changed

Lines changed: 51 additions & 2 deletions

File tree

  • aws_lambda_powertools/utilities/parser/models
  • tests/unit/parser/_pydantic

‎aws_lambda_powertools/utilities/parser/models/ses.py‎

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

4-
from pydantic import BaseModel, Field
4+
from pydantic import AliasChoices, BaseModel, Field
55
from pydantic.types import PositiveInt
66

77

@@ -37,7 +37,11 @@ class SesMailCommonHeaders(BaseModel):
3737
cc: List[str] | None = None
3838
bcc: List[str] | None = None
3939
sender: List[str] | None = None
40-
reply_to: List[str] | None = Field(None, alias="reply-to")
40+
reply_to: List[str] | None = Field(
41+
None,
42+
validation_alias=AliasChoices("replyTo", "reply-to", "reply_to"),
43+
serialization_alias="replyTo",
44+
)
4145
returnPath: str
4246
messageId: str
4347
date: str

‎tests/unit/parser/_pydantic/test_ses.py‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,48 @@ def test_ses_trigger_event():
5050
assert action.type == raw_receipt["action"]["type"]
5151
assert action.functionArn == raw_receipt["action"]["functionArn"]
5252
assert action.invocationType == raw_receipt["action"]["invocationType"]
53+
54+
55+
def test_ses_reply_to_header():
56+
from aws_lambda_powertools.utilities.parser.models.ses import SesMailCommonHeaders
57+
58+
# Test with standard SES notification camelCase payload
59+
headers_camel = SesMailCommonHeaders.model_validate(
60+
{
61+
"from": ["sender@example.com"],
62+
"to": ["receiver@example.com"],
63+
"returnPath": "bounce@example.com",
64+
"messageId": "<msg-001@example.com>",
65+
"date": "Wed, 7 Oct 2026 12:34:56 -0700",
66+
"subject": "SES Subject",
67+
"replyTo": ["reply@example.com"],
68+
},
69+
)
70+
assert headers_camel.reply_to == ["reply@example.com"]
71+
assert headers_camel.model_dump(by_alias=True)["replyTo"] == ["reply@example.com"]
72+
73+
# Test backwards compatibility with hyphenated alias
74+
headers_hyphen = SesMailCommonHeaders.model_validate(
75+
{
76+
"from": ["sender@example.com"],
77+
"to": ["receiver@example.com"],
78+
"returnPath": "bounce@example.com",
79+
"messageId": "<msg-002@example.com>",
80+
"date": "Wed, 7 Oct 2026 12:34:56 -0700",
81+
"subject": "SES Subject",
82+
"reply-to": ["reply-hyphen@example.com"],
83+
},
84+
)
85+
assert headers_hyphen.reply_to == ["reply-hyphen@example.com"]
86+
87+
# Test keyword argument instantiation
88+
headers_kwarg = SesMailCommonHeaders(
89+
**{"from": ["sender@example.com"]},
90+
to=["receiver@example.com"],
91+
returnPath="bounce@example.com",
92+
messageId="<msg-003@example.com>",
93+
date="Wed, 7 Oct 2026 12:34:56 -0700",
94+
subject="SES Subject",
95+
reply_to=["reply-kwarg@example.com"],
96+
)
97+
assert headers_kwarg.reply_to == ["reply-kwarg@example.com"]

0 commit comments

Comments
 (0)