Skip to content

VerifyAuthChallengeResponse Cognito event fails to deserialize when response.answerCorrect is null #825

@mawallace

Description

@mawallace

I wrote a set of Cognito Lambda triggers for a custom auth flow, using the event types provided in this library. When using the auth flow in a web app, I encountered the following error:

VerifyAuthChallengeResponse failed with error failed to deserialize the incoming data into the function's payload type: [response.answerCorrect] response.answerCorrect: invalid type: null, expected a boolean at line 1 column 582
.
AmplifyError@http://localhost:3000/static/js/bundle.js:68099:10
AuthError@http://localhost:3000/static/js/bundle.js:60434:10
@http://localhost:3000/static/js/bundle.js:62959:77

It seems like the Cognito is sending an event for the VerifyAuthChallengeResponse trigger with response.answerCorrect explicitly set to null (not just missing).

I patched in this repository and added deserialize_nullish_boolean (which is used for other fields in the module) to the answer_correct field, like below:

/// `CognitoEventUserPoolsVerifyAuthChallengeResponse` defines verify auth challenge response parameters
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CognitoEventUserPoolsVerifyAuthChallengeResponse {
    #[serde(default, deserialize_with = "deserialize_nullish_boolean")]
    pub answer_correct: bool,
}

This resolved the issue.

If this makes sense to the maintainers, I'm happy to submit a pull request with this change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions