Skip to content

fix: Makes two properties optional on MigrateUserResponse. #663

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

Merged

Conversation

mark-keaton
Copy link
Contributor

@mark-keaton mark-keaton commented Jun 15, 2023

Issue #, if available:
No issue available

Description of changes:
Makes two properties Optional on CognitoEventUserPoolsMigrateUserResponse:

  • desired_delivery_mediums
  • force_alias_creation

How I diagnosed:
My Cognito Lambda was panicking when trying to deserialize the Lambda Event:

ERROR Lambda runtime invoke{requestId="..." xrayTraceId="Root=...;Parent=...;Sampled=0"}: Error("invalid type: null, expected a boolean", line: 1, column: 420)

I used Python to print the Event, and I found that all of the fields on the CognitoEventUserPoolsMigrateUserResponse were null:

{
  "version": "1",
  "triggerSource": "UserMigration_Authentication",
  "region": "us-east-1",
  "userPoolId": "us-east-1_123abc",
  "userName": "test@test.test",
  "callerContext": {
    "awsSdkVersion": "aws-sdk-unknown-unknown",
    "clientId": "123abc"
  },
  "request": {
    "password": "Testtest",
    "validationData": {
      "custom": "property"
    },
    "userAttributes": null
  },
  "response": {
    "userAttributes": null,
    "forceAliasCreation": null,
    "enableSMSMFA": null,
    "finalUserStatus": null,
    "messageAction": null,
    "desiredDeliveryMediums": null
  }
}

So I believe the deserialization was failing on forceAliasCreation. Then when I ran this event locally, it also failed to deserialize desiredDeliveryMediums.

  • I confirm that my contribution is made under the terms of the Apache 2.0 license.
  • I confirm that I've made a best effort attempt to update all relevant documentation.

Copy link

@christopherwxyz christopherwxyz left a comment

Choose a reason for hiding this comment

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

The modified code includes the following changes:

  1. desired_delivery_mediums field is modified to Option<Vec<String>>. The Option type is added, allowing the field to be Some if present or None if absent.
  2. force_alias_creation field is modified to Option<bool>. Similar to desired_delivery_mediums, the Option type is added, making it optional.

By adding the Option type to both fields, the code allows these fields to be omitted or set to None when constructing an instance of the CognitoEventUserPoolsMigrateUserResponse struct. This change provides flexibility in handling scenarios where these fields might not always be present or need to be explicitly set to None.

@mark-keaton mark-keaton force-pushed the fix/cognito_migrate_user_response branch from 5c3cdfd to 670dffb Compare June 15, 2023 21:44
@mark-keaton mark-keaton requested a review from calavera June 15, 2023 21:45
@calavera calavera merged commit b2451e9 into awslabs:main Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants