Skip to content

feat(parser): Added Cognito trigger schemas #6737

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

VatsalGoel3
Copy link
Contributor

@VatsalGoel3 VatsalGoel3 commented May 29, 2025

Issue number: #6203

Summary

Changes

This PR adds full support for all Amazon Cognito User Pool Lambda Triggers as part of the Parser (Pydantic) utility. These include schemas for:

  1. PreSignUp
  2. PostConfirmation
  3. PreAuthentication
  4. PostAuthentication
  5. PreTokenGeneration
  6. MigrateUser
  7. CustomMessage
  8. CustomEmailSender
  9. CustomSMSSender
  10. DefineAuthChallenge
  11. CreateAuthChallenge
  12. VerifyAuthChallenge

Each schema includes:

  • Strict Pydantic models with field aliases
  • Unit tests based on sample event payloads
  • Event fixture JSON files
  • Centralized export in __init__.py

User experience

Before:

  • Developers had to manually validate and parse Cognito Lambda events.
  • No native schema validation via @parser for Cognito triggers.

After:

  • Full schema validation for all supported Cognito Lambda events.
  • Type-safe access to event fields via @parser(model=CognitoXxxEventModel).

Checklist

Is this a breaking change?

RFC issue number: N/A

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

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


⚠️ Current blocker

Some schemas are currently failing validation in tests due to discrepancies in the sample fixture files:

  • email_verified, phone_number_verified appear as bool in test events but the schema expects str
  • Some optional nested fields are missing or provided as empty objects in test files
  • Aliases like awsSdk vs awsSdkVersion cause mismatches

Would you prefer:

  1. Loosening the validators and accepting bool | str, with appropriate aliases?
  2. Or should we update the JSON test fixtures to match stricter validation?

@VatsalGoel3 VatsalGoel3 requested a review from a team as a code owner May 29, 2025 06:48
@VatsalGoel3 VatsalGoel3 requested a review from anafalcao May 29, 2025 06:48
@boring-cyborg boring-cyborg bot added documentation Improvements or additions to documentation tests labels May 29, 2025
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 29, 2025
@github-actions github-actions bot added feature New feature or functionality and removed documentation Improvements or additions to documentation labels May 29, 2025
@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Jun 2, 2025
@leandrodamascena leandrodamascena linked an issue Jun 2, 2025 that may be closed by this pull request
2 tasks
Copy link
Contributor

@leandrodamascena leandrodamascena left a comment

Choose a reason for hiding this comment

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

Hey @VatsalGoel3 can you pls run make format and push a commit again? Ruff is complaining about some files.

Copy link

sonarqubecloud bot commented Jun 6, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation feature New feature or functionality 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.

Feature request: Add Cognito trigger models in parser utility
2 participants