Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Serialization of CognitoMigrateUserEvent throws #2166

Open
Labels
bugThis issue is a bug. pending-releaseThis issue will be fixed by an approved PR that hasn't been released yet. xsEffort estimation: tiny
@ThomasEg

Description

Describe the bug

Having an event handler for user migration in Cognito:

[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))]
...
public void CognitoMigrateUserHandler(CognitoMigrateUserEvent cognitoEvent, ILambdaContext context)
{
 ...
}

Throws an exception during serialization of CognitoMigrateUserEvent:

Amazon.Lambda.Serialization.SystemTextJson.JsonSerializerException: 
Error converting the Lambda event JSON payload to type Amazon.Lambda.CognitoEvents.CognitoMigrateUserEvent: 
The JSON value could not be converted to System.Boolean. 
Path: $.response.forceAliasCreation | LineNumber: 0 | BytePositionInLine: 401.

The data sent from cognito was:

{
 "version": "1",
 "triggerSource": "UserMigration_Authentication",
 "region": "...",
 "userPoolId": "...",
 "userName": "...",
 "callerContext": {
 "awsSdkVersion": "...",
 "clientId": "..."
 },
 "request": {
 "password": "...",
 "validationData": null,
 "userAttributes": null
 },
 "response": {
 "userAttributes": null,
 "forceAliasCreation": null,
 "enableSMSMFA": null,
 "finalUserStatus": null,
 "messageAction": null,
 "desiredDeliveryMediums": null
 }
}

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

I expect it to serialize correctly and then call the method.

Current Behavior

It throws a deserialization exception.

Reproduction Steps

Setup a Cognito UserPool to have a Migrate user trigger with this target:

[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))]
...
public void CognitoMigrateUserHandler(CognitoMigrateUserEvent cognitoEvent, ILambdaContext context)
{
}

Possible Solution

My guess is that the types of the properties in the response-object needs to be nullable.

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

Amazon.Lambda.CognitoEvents: 4.0.0
Amazon.Lambda.Serialization.SystemTextJson:2.4.4

Targeted .NET Platform

.NET 8

Operating System and version

Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug. pending-releaseThis issue will be fixed by an approved PR that hasn't been released yet. xsEffort estimation: tiny

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /