Skip to content
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

CognitoUserPoolVerifyAuthChallengeResponseEvent.RequestchallengeAnswer property is of incorrect type #355

Open
sdaletalentful opened this issue Jul 14, 2022 · 6 comments
Assignees
Labels
events-v4 To be pulled into aws-lambda-java-event v4

Comments

@sdaletalentful
Copy link

The challengeAnswer property is defined as a Map<String, String> (source).

However, the AWS documentation here states that challengeAnswer will be a string.

Using the CognitoUserPoolVerifyAuthChallengeResponseEvent class as-is results in Jackson serialization errors. For instance:

An error occurred during JSON parsing: java.lang.RuntimeException
java.lang.RuntimeException: An error occurred during JSON parsing
Caused by: java.io.UncheckedIOException: com.amazonaws.lambda.thirdparty.com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `java.util.LinkedHashMap` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('1234')
 at [Source: (ByteArrayInputStream); line: 1, column: 642] (through reference chain: com.amazonaws.services.lambda.runtime.events.CognitoUserPoolVerifyAuthChallengeResponseEvent["request"]->com.amazonaws.services.lambda.runtime.events.CognitoUserPoolVerifyAuthChallengeResponseEvent$Request["challengeAnswer"])
	at com.amazonaws.services.lambda.runtime.serialization.factories.JacksonFactory$InternalSerializer.fromJson(JacksonFactory.java:184)
Caused by: com.amazonaws.lambda.thirdparty.com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `java.util.LinkedHashMap` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('1234')
 at [Source: (ByteArrayInputStream); line: 1, column: 642] (through reference chain: com.amazonaws.services.lambda.runtime.events.CognitoUserPoolVerifyAuthChallengeResponseEvent["request"]->com.amazonaws.services.lambda.runtime.events.CognitoUserPoolVerifyAuthChallengeResponseEvent$Request["challengeAnswer"])
	at com.amazonaws.lambda.thirdparty.com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:63)
	at com.amazonaws.lambda.thirdparty.com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1432)
	at com.amazonaws.lambda.thirdparty.com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1062)
	at com.amazonaws.lambda.thirdparty.com.fasterxml.jackson.databind.deser.ValueInstantiator._createFromStringFallbacks(ValueInstantiator.java:371)
	at com.amazonaws.lambda.thirdparty.com.fasterxml.jackson.databind.deser.ValueInstantiator.createFromString(ValueInstantiator.java:258)
	at com.amazonaws.lambda.thirdparty.com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:357)
	at com.amazonaws.lambda.thirdparty.com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:29)
	at com.amazonaws.lambda.thirdparty.com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
	at com.amazonaws.lambda.thirdparty.com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
	at com.amazonaws.lambda.thirdparty.com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
	at com.amazonaws.lambda.thirdparty.com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
	at com.amazonaws.lambda.thirdparty.com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
	at com.amazonaws.lambda.thirdparty.com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
	at com.amazonaws.lambda.thirdparty.com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:1719)
	at com.amazonaws.lambda.thirdparty.com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1228)
	at com.amazonaws.services.lambda.runtime.serialization.factories.JacksonFactory$InternalSerializer.fromJson(JacksonFactory.java:182)
@msailes
Copy link
Collaborator

msailes commented Jul 14, 2022

Hi @sdaletalentful,

Thanks for reporting the issue.

Mark

@msailes msailes added events-v4 To be pulled into aws-lambda-java-event v4 labels Jul 15, 2022
@benjaminkomen
Copy link

I noticed the same thing.. So I'll have to define my own class to map the json to

@pieterreuse
Copy link

Affected me too. Was useful to me to see that this is an issue with events-v3 and not my code.
Defining my own class fixed my issue.

@smirnoal
Copy link
Contributor

Do you mind creating a PR to fix this?

@pieterreuse
Copy link

@smirnoal looks like there already is one: #356
However seems like it'd be interesting to some people (including myself) if that commit was also included in the v3 branch.

@smirnoal
Copy link
Contributor

yeah, should be easy cherry-pick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
events-v4 To be pulled into aws-lambda-java-event v4
Projects
None yet
Development

No branches or pull requests

5 participants