Open ygormartins opened 1 year ago
This discussion might be relevant to what you're trying to do: https://github.com/awslabs/aws-lambda-rust-runtime/discussions/530
This discussion might be relevant to what you're trying to do: https://github.com/awslabs/aws-lambda-rust-runtime/discussions/530
This refers to AWS SAM role issues with APIGateway authorisers (had the exact same issue yesterday!)
In my case, serde was failing to serialise the event payload because some fields from both V1 and V2 types weren't present (such as http_method
from V1) and weren't marked as Option<>
.
I believe this is happening because I'm using a custom authoriser for a WebSocket API, and some fields are different from HTTP ones.
I believe there's two ways to fix this:
Option<>
for fields that aren't in both HTTP and WebSocket APIs and maybe add any missing fieldsFor now, I have created a custom struct with only the fields I'll be using in my lambda
Reporting another case related to this problem.
I've used ApiGatewayV2CustomAuthorizerV2Request
for an HTTP APIGatewayV2, payload version 2.0, and the API didn't work and the cloudwatch log of $context.authorizer.error
recorded
"The Lambda Authorizer function returned the following error: missing field
cookies
at line 1 column 1439. Check your Lambda function code and try again."
So this issue happens not only for WebSocket API but also when the field is not actually necessary for HTTP API case too. I think adding Option<>
is a better solution in short term.
@naokiri the error with cookies should be solved in 0.7.3. I believe #123 fixed it, but it was never released until today.
@calavera v0.7.3 worked. Thank you!
I'm trying to create a custom ApiGatewayV2 authorizer lambda for a WebSocket API using
ApiGatewayV2CustomAuthorizerV1Request
orApiGatewayV2CustomAuthorizerV2Request
, but the lambda fails to run in both cases. It runs themain()
function with no issues, but code inside thehandler_fn
is being completely ignored, and no error whatsoever is being thrown. I've tried using other types, such asApiGatewayCustomAuthorizerRequest
, and they work just fine, but they're incompatible with the API Gateway version and return incorrect/missing data.Sometimes it outputs an "Unknown.Runtime" error message directly in the lambda logs.
I'm using
lambda_runtime
andaws_lambda_events
, both v0.7.0. I've tried v0.7.1 and v0.7.2 and had the exact same result.Here's the code:
Here are the lambda logs:
And here's my lambda configuration:
Also, what's the difference between
ApiGatewayV2CustomAuthorizerV1Request
andApiGatewayV2CustomAuthorizerV2Request
?Thanks!