-
Notifications
You must be signed in to change notification settings - Fork 361
Data did not match any variant of untagged enum LambdaRequest when testing from API Gateway in the AWS Console #367
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
Comments
Hey @ionionascu! Thanks for creating this! I was able to reproduce that a null headers value result in an error. I've created a PR that should address that issue -> #371 |
Hi @nmoutschen. Sorry for the delay in testing the changes. I have checked the current master (which includes #371) and I still see an error reported in the AWS API Gateway's test console. The problem is caused by #[test]
fn test() {
const PAYLOAD: &str = r#"{
"resource": "/test",
"path": "/test",
"httpMethod": "GET",
"headers": null,
"multiValueHeaders": null,
"queryStringParameters": null,
"multiValueQueryStringParameters": null,
"pathParameters": null,
"stageVariables": null,
"requestContext": {
"resourceId": "test",
"resourcePath": "/test",
"operationName": "test",
"httpMethod": "GET",
"extendedRequestId": "test",
"requestTime": "21/Dec/2021:12:30:16 +0000",
"path": "/test",
"accountId": "123",
"protocol": "HTTP/1.1",
"stage": "test",
"domainPrefix": "test",
"requestTimeEpoch": 1640089816496,
"requestId": "123",
"identity": {
"cognitoIdentityPoolId": null,
"cognitoIdentityId": null,
"apiKey": "test",
"principalOrgId": null,
"cognitoAuthenticationType": null,
"userArn": "arn",
"apiKeyId": "test",
"userAgent": "test",
"accountId": "123",
"caller": "test",
"sourceIp": "test",
"accessKey": "123",
"cognitoAuthenticationProvider": null,
"user": "test"
},
"domainName": "test",
"apiId": "test"
},
"body": null,
"isBase64Encoded": false
}"#;
let val: lambda_http::request::LambdaRequest = serde_json::from_str(PAYLOAD).unwrap();
println!("{:?}", val);
} |
@ionionascu I've created PR #387, which just do the same thing as @nmoutschen did in #371 but for multi-value headers too. I've run your test locally and it now passes. |
I have the same problem in 0.4.1... Will this bug be fixed in next release? |
#387 is merged to main branch so I think we can assume it will be included in the next release. |
Thank you @mbergkvist, @nmoutschen . I have tested with the latest code on master and everything looks good. I will close this issue. |
I have a Rust lambda that is accessed through an API Gateway with proxy integration. When I test the API Gateway's method directly in the AWS Console without passing any headers (or no query parameters), I get an error from the Lambda:
Error: Error("data did not match any variant of untagged enum LambdaRequest", line: 0, column: 0)
This seems to be caused by the fact that in the API Gateway JSON request, the
headers
,multiValueHeaders
,queryStringParameters
andmultiValueQueryStringParameters
elements are passed asnull
(I do not remember seeing this error before so it may be that this used to be passed as an empty object,{}
).Using a modified sample request JSON from a different issue, I can reproduce the error with this test:
I tested with the current master branch (commit
576f6013dd188de08928dd503170b525bc17c26e
), which contains the changes from another issue similar to this one (#365).The text was updated successfully, but these errors were encountered: