powertools-lambda-python icon indicating copy to clipboard operation
powertools-lambda-python copied to clipboard

Feature request: Add Cognito trigger models in parser utility

Open leandrodamascena opened this issue 1 year ago • 12 comments

Use case

Original issue in TypeScript: https://github.com/aws-powertools/powertools-lambda-typescript/issues/3675

We should add schemas for Cognito Lambda triggers. Lambda triggers customize the flow of user pool sign-up, authentication, etc. Details are in docs.

Solution/User Experience

Add all models

Alternative solutions


Acknowledgment

leandrodamascena avatar Mar 03 '25 13:03 leandrodamascena

I'm leaving it open for a while! If anyone wants to pick it up and work on it, please let me know and I can give some guidance.

leandrodamascena avatar Mar 03 '25 13:03 leandrodamascena

Hi @leandrodamascena , I would like to work on this, also I am working on the mentioned original issue 3675 in Typescript tools so have some basic idea.

VatsalGoel3 avatar Mar 17 '25 04:03 VatsalGoel3

Hey @VatsalGoel3! Yes, please go ahead with this implementation! If you have any questions about the Python implementation, please let me know!

I'm assigning this issue to you.

leandrodamascena avatar Mar 17 '25 09:03 leandrodamascena

Hey @VatsalGoel3! I see that you're working on this PR https://github.com/aws-powertools/powertools-lambda-typescript/pull/3729 in TypeScript and I think make sense you finish first TypeScript implementation and then we can port it to Python. I'm putting this issue in the backlog and will assign you when we merge the TS version.

Thanks

leandrodamascena avatar Mar 17 '25 15:03 leandrodamascena

@leandrodamascena, The TS version for the cognito schema issue is closed and completed now, so if you want to open this up and assign me again.

Thank you

VatsalGoel3 avatar Apr 08 '25 05:04 VatsalGoel3

Hey @VatsalGoel3! Sure!!

I'm assigning to you.

leandrodamascena avatar Apr 08 '25 14:04 leandrodamascena

Hey, @leandrodamascena sorry I could not get to this, was busy with some other work, is it still in consideration?

VatsalGoel3 avatar May 21 '25 05:05 VatsalGoel3

Hey @VatsalGoel3! Yes, pls go ahead

leandrodamascena avatar May 21 '25 06:05 leandrodamascena

@leandrodamascena, I’ve been updating the Cognito trigger Pydantic models to match our existing tests/events/*.json fixtures, but I’m still seeing test failures in several schemas:

PostConfirmation: email_verified comes through as a bool but the model expects str UserMigration: response.userAttributes is completely absent in the fixture CustomMessage / CustomEmailSender / CustomSMSSender: fields like awsSdkVersion are named awsSdk, and email_verified/phone_number_verified are bools not strings Define/Create/Verify Auth Challenge: challengeMetadata, various response fields are empty objects rather than fully populated

Before I either relax these validators or tweak the fixtures, could I get guidance on which approach you’d prefer? Should we:

  1. Loosen the Pydantic schemas (e.g. accept bool | str, alias awsSdk → awsSdkVersion, make those response sub-fields optional), or
  2. Update the JSON fixtures to always include those fields in the expected format?

VatsalGoel3 avatar May 28 '25 06:05 VatsalGoel3

Hi @VatsalGoel3 I think you can create a PR with these tests and we can discuss this in the PR. I think I need to understand better what is failing and then decide how to fix it.

WDYT?

leandrodamascena avatar May 28 '25 16:05 leandrodamascena

I made the pull request, let me know your thoughts

VatsalGoel3 avatar May 30 '25 01:05 VatsalGoel3

⚠️COMMENT VISIBILITY WARNING⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

github-actions[bot] avatar Jul 09 '25 17:07 github-actions[bot]