Skip to content

fix(parser): accept SES events without common headers or invocation type - #8768

Open
Manishram-ai wants to merge 1 commit into
aws-powertools:developfrom
Manishram-ai:fix/parser-ses-optional-fields
Open

Manishram-ai wants to merge 1 commit into
aws-powertools:developfrom
Manishram-ai:fix/parser-ses-optional-fields

Conversation

@Manishram-ai

Copy link
Copy Markdown
Contributor

Issue number:
closes #8767

Summary

Changes

  • SesReceiptAction.invocationType accepts RequestResponse as well as Event, and is optional. The SES docs list both values, and the captured event in Bug: SesSchema rejects documented SES receipt events powertools-lambda-typescript#5771 doesn't have it.
  • Every field in SesMailCommonHeaders is optional now. SES only sends the headers the email has, so an email sent only to BCC recipients has no to.
  • In the SESEvent data class, to and get_from return [] when the header is missing, like cc and bcc already do. return_path, date, message_id, subject and invocation_type return None instead of raising KeyError, so their return types change from str to str | None.
  • New tests cover both invocation types, a missing invocation type and an email with no common headers, for the parser model and the data class.

This is the same fix as aws-powertools/powertools-lambda-typescript#5772. The replyTo part of that PR was already done here in #8525.

User experience

Today, events from a Lambda action invoked with RequestResponse, and emails without a To or Subject header, fail with a ValidationError in the parser and a KeyError in the data class. With this change they parse, and the missing headers come back as None (or [] for the list headers in the data class).

Verification

  • 4 of the 5 new tests fail on develop and pass with this change. The Event case already passed.
  • tests/unit/parser and tests/unit/data_classes/required_dependencies: 366 passed (Python 3.12).
  • ruff check, ruff format --check and mypy are clean on the changed files.
  • I didn't run this against a live SES receipt rule. The field rules come from the SES docs, and the missing invocationType comes from the captured event in the TypeScript issue.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@Manishram-ai
Manishram-ai requested a review from a team as a code owner November 4, 2026 06:41
@Manishram-ai
Manishram-ai requested a review from svozza November 4, 2026 06:41
@boring-cyborg boring-cyborg Bot added the tests label Nov 4, 2026
@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 4, 2026
@sonarqubecloud

sonarqubecloud Bot commented Nov 4, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: SES parser model and data class reject emails without To or Subject, and RequestResponse actions

1 participant