Repository navigation
fix(parser): accept real Cognito trigger events - #8762
leandrodamascena merged 2 commits into
Conversation
The Cognito trigger models rejected events that Cognito sends in common flows: CUSTOM_CHALLENGE in the auth challenge session, the other documented trigger sources for pre sign-up, post confirmation and the custom email and SMS senders, and a null answerCorrect or clientId. This is the same fix as powertools-lambda-typescript#5777.
leandrodamascena
left a comment
There was a problem hiding this comment.
Thanks @Manishram-ai! Since you couldn't run it against a live pool, I did: a user pool with a logging Lambda, AdminCreateUser and a full CUSTOM_AUTH round with one wrong and one right answer. Nine real events, develop parses 3 of them, your branch parses all 9, and the failures on develop are exactly the ones in your issue. One correction for the record: on AdminCreateUser Cognito sends callerContext.clientId as the string CLIENT_ID_NOT_APPLICABLE, not null. Keeping it optional is fine, it just isn't for that reason. Goes out in 3.41.0, no need to rebase, you'll be in the release notes.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #8762 +/- ##
========================================
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. 🚀 New features to boost your workflow:
|



Issue number:
closes #8761
Summary
Changes
CognitoChallengeResultModel.challengeNameacceptsCUSTOM_CHALLENGE, the first challenge type in the define auth challenge docs.triggerSourcedocumented for their trigger. The lists come from the trigger sources reference and the custom email and custom SMS sender pages. The trigger sources reference spells the SMS sourcesCustomSmsSender_*, but the custom SMS sender page and the API table useCustomSMSSender_*, which matches the existing literal, so I kept that spelling.answerCorrectin the verify auth challenge response andcallerContext.clientIdare optional, because Cognito sendsnullfor both. The function setsanswerCorrect, and admin API calls such asAdminConfirmSignUphave no client ID.CUSTOM_CHALLENGEin the define and create auth challenge sessions, and the twonullvalues. Each one starts from the existing fixture and changes one field.This is the same fix as aws-powertools/powertools-lambda-typescript#5777. Python's
sessionhas no minimum length and its custom sender models don't requireresponse, so those two parts of the TypeScript change weren't needed here.User experience
Today a custom auth flow can't be parsed past its first custom challenge, verify auth challenge events fail on
answerCorrect, and pre sign-up, post confirmation and custom sender events from admin, federated, forgot password and resend code flows fail with aValidationError. With this change they parse, and handlers can branch ontriggerSourceandchallengeNamethe way the Cognito docs describe.Verification
developand pass with this change.tests/unit/parser,tests/functional/parserandtests/unit/data_classes: 449 passed (Python 3.12).ruff format --checkandruff checkare clean on the changed files, and mypy shows no errors incognito.py.CUSTOM_CHALLENGEcome from the Cognito docs, and the twonullvalues come from the events captured from a live user pool in Bug: Cognito trigger schemas reject real events from common flows powertools-lambda-typescript#5770.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.