Unrecognizable lambda output in Cognito Pre authentication lambda trigger #1731
Unanswered
StephaneLeveugle
asked this question in
Support
Replies: 1 comment 2 replies
-
Hi! Unfortunately this is a problem that exists with PHP regardless of Lambda or not, Cognito, etc. You have to use |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description:
Note: this issue is focused on pre authentication lambda trigger but I suppose it can happen everywhere AWS expects an object and receives an array
It is currently impossible to use the Pre authentication lambda trigger out of the box
It seems related to this issue #710, even though the event was a different one the logic behind it is the same
After some investigation the root cause seems to be PHP's array and how it behaves with json_encode
This is the payload received, which we should return as is if we accept the authentication
After converting the json to a PHP array and reencoding it to JSON to send to AWS the output becomes
which AWS considers an invalid lambda output with good reason
How to reproduce:
A basic lambda that just returns the event like this should allow every authentication
However it fails for everyone with
Unrecognizable lambda output
To fix it manually we can set the impacted fields to a Map or stdClass, which will result to the correct output when json encoded, example:
Thank you :)
Beta Was this translation helpful? Give feedback.
All reactions