Skip to content

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

Merged
leandrodamascena merged 2 commits into
aws-powertools:developfrom
Manishram-ai:fix/parser-ses-optional-fields
Nov 14, 2026
Merged

leandrodamascena merged 2 commits 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
@leandrodamascena leandrodamascena added the bug Something isn't working label Nov 14, 2026
@leandrodamascena leandrodamascena added this to the 3.41.0 milestone Nov 14, 2026
@leandrodamascena leandrodamascena added the parser Parser (Pydantic) utility label Nov 14, 2026

@leandrodamascena leandrodamascena left a comment

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.

Thanks @Manishram-ai! This one I couldn't check against a live receipt rule, inbound SES needs a verified domain with MX records and I don't have one on the test account, so I'm going with the SES docs and the real event from the TypeScript issue, which agree with you. The data class returning None instead of raising KeyError is the same call we made for SQS and Transfer Family in 3.40.0. Goes out in 3.41.0, no need to rebase, you'll be in the release notes.

@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.17%. Comparing base (84f690a) to head (b85b248).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #8768   +/-   ##
========================================
  Coverage    97.17%   97.17%           
========================================
  Files          323      323           
  Lines        16606    16606           
  Branches      1504     1504           
========================================
  Hits         16137    16137           
  Misses         328      328           
  Partials       141      141           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@leandrodamascena
leandrodamascena merged commit d07a9c2 into aws-powertools:develop Nov 14, 2026
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working parser Parser (Pydantic) utility 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

2 participants