Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions resend/emails/_received_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ class _ReceivedEmailDefaultAttrs(_ReceivedEmailFromParam, BaseResponse):
"""
Reply-to addresses.
"""
received_for: List[str]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: received_for is typed as List[str] (required) while similar optional list fields (bcc, cc, reply_to) are all Optional[List[str]]. If the API omits received_for for non-forwarded emails, this will cause a KeyError or type-checking issue.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At resend/emails/_received_email.py, line 155:

<comment>`received_for` is typed as `List[str]` (required) while similar optional list fields (`bcc`, `cc`, `reply_to`) are all `Optional[List[str]]`. If the API omits `received_for` for non-forwarded emails, this will cause a KeyError or type-checking issue.</comment>

<file context>
@@ -152,6 +152,10 @@ class _ReceivedEmailDefaultAttrs(_ReceivedEmailFromParam, BaseResponse):
     """
     Reply-to addresses.
     """
+    received_for: List[str]
+    """
+    Addresses the email was received for (forwarding recipients).
</file context>

"""
Addresses the email was received for (forwarding recipients).
"""
message_id: str
"""
The message ID of the email.
Expand Down Expand Up @@ -182,6 +186,7 @@ class ReceivedEmail(_ReceivedEmailDefaultAttrs):
bcc (Optional[List[str]]): Bcc recipients.
cc (Optional[List[str]]): Cc recipients.
reply_to (Optional[List[str]]): Reply-to addresses.
received_for (List[str]): Addresses the email was received for (forwarding recipients).
message_id (str): The message ID of the email.
headers (NotRequired[Dict[str, str]]): Email headers.
attachments (List[EmailAttachment]): List of attachments.
Expand Down
2 changes: 2 additions & 0 deletions tests/receiving_async_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ async def test_receiving_get_async(self) -> None:
"to": ["recipient@example.com"],
"subject": "Test subject",
"created_at": "2024-01-01T00:00:00Z",
"received_for": ["forwarded@example.com"],
}
)

Expand All @@ -28,6 +29,7 @@ async def test_receiving_get_async(self) -> None:
)
assert email["id"] == "67d9bcdb-5a02-42d7-8da9-0d6feea18cff"
assert email["object"] == "received_email"
assert email["received_for"] == ["forwarded@example.com"]

async def test_should_get_receiving_async_raise_exception_when_no_content(
self,
Expand Down
Loading