-
Notifications
You must be signed in to change notification settings - Fork 403
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
Using parser with envelopes.ApiGatewayEnvelope #531
Comments
Thanks for opening your first issue here! We'll come back to you as soon as we can. |
Hey @walmsles, thanks for flagging it! Could you give an example of an event that this isn't true so we can flag the official aws docs too? Happy to accept a PR to make this optional, or work on this right after a Mypy fix I'm working |
Hey have submitted a PR for this (just now :-)). My PR is consistent with sample events here The event samples (above and below) are also consistent with output from: sam local generate-event apigateway aws-proxy Event from API GW: {
"resource": "/test",
"path": "/test",
"httpMethod": "POST",
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br",
"CloudFront-Forwarded-Proto": "https",
"CloudFront-Is-Desktop-Viewer": "true",
"CloudFront-Is-Mobile-Viewer": "false",
"CloudFront-Is-SmartTV-Viewer": "false",
"CloudFront-Is-Tablet-Viewer": "false",
"CloudFront-Viewer-Country": "AU",
"Content-Type": "application/json",
"Host": "nlioqcygg3.execute-api.ap-southeast-2.amazonaws.com",
"Postman-Token": "0d2f11a9-ba6d-49bc-9c1b-795b435592cc",
"User-Agent": "PostmanRuntime/7.28.0",
"Via": "1.1 c0abed86b33ff7ae86d6e529296ac06e.cloudfront.net (CloudFront)",
"X-Amz-Cf-Id": "r3RE7FPFa1B0oq9LlMkCOMKbPUwU5fdD9Zvx6l1GFGExhpgKS8FCXQ==",
"X-Amzn-Trace-Id": "Root=1-60f286cd-1f3632430b6bbd507a246206",
"X-Forwarded-For": "124.170.115.3, 130.176.156.116",
"X-Forwarded-Port": "443",
"X-Forwarded-Proto": "https"
},
"multiValueHeaders": {
"Accept": [
"*/*"
],
"Accept-Encoding": [
"gzip, deflate, br"
],
"CloudFront-Forwarded-Proto": [
"https"
],
"CloudFront-Is-Desktop-Viewer": [
"true"
],
"CloudFront-Is-Mobile-Viewer": [
"false"
],
"CloudFront-Is-SmartTV-Viewer": [
"false"
],
"CloudFront-Is-Tablet-Viewer": [
"false"
],
"CloudFront-Viewer-Country": [
"AU"
],
"Content-Type": [
"application/json"
],
"Host": [
"nlioqcygg3.execute-api.ap-southeast-2.amazonaws.com"
],
"Postman-Token": [
"0d2f11a9-ba6d-49bc-9c1b-795b435592cc"
],
"User-Agent": [
"PostmanRuntime/7.28.0"
],
"Via": [
"1.1 c0abed86b33ff7ae86d6e529296ac06e.cloudfront.net (CloudFront)"
],
"X-Amz-Cf-Id": [
"r3RE7FPFa1B0oq9LlMkCOMKbPUwU5fdD9Zvx6l1GFGExhpgKS8FCXQ=="
],
"X-Amzn-Trace-Id": [
"Root=1-60f286cd-1f3632430b6bbd507a246206"
],
"X-Forwarded-For": [
"124.170.115.3, 130.176.156.116"
],
"X-Forwarded-Port": [
"443"
],
"X-Forwarded-Proto": [
"https"
]
},
"queryStringParameters": null,
"multiValueQueryStringParameters": null,
"pathParameters": null,
"stageVariables": null,
"requestContext": {
"resourceId": "w845zr",
"resourcePath": "/test",
"httpMethod": "POST",
"extendedRequestId": "CmoAGFq7SwMFQ4A=",
"requestTime": "17/Jul/2021:07:29:17 +0000",
"path": "/dev/test",
"accountId": "674048636348",
"protocol": "HTTP/1.1",
"stage": "dev",
"domainPrefix": "nlioqcygg3",
"requestTimeEpoch": 1626506957232,
"requestId": "e227c43b-0957-4354-9f78-b0874f771630",
"identity": {
"cognitoIdentityPoolId": null,
"accountId": null,
"cognitoIdentityId": null,
"caller": null,
"sourceIp": "124.170.115.3",
"principalOrgId": null,
"accessKey": null,
"cognitoAuthenticationType": null,
"cognitoAuthenticationProvider": null,
"userArn": null,
"userAgent": "PostmanRuntime/7.28.0",
"user": null
},
"domainName": "nlioqcygg3.execute-api.ap-southeast-2.amazonaws.com",
"apiId": "nlioqcygg3"
},
"body": "{\n \"data\": \"test message\"\n}",
"isBase64Encoded": false
},
"timestamp": "2021-07-17 07:29:17,259+0000",
"service": "service_undefined",
"xray_trace_id": "1-60f286cd-1f3632430b6bbd507a246206"
} |
Staged for next week's release - Friday the latest. Let me know if this is impacting production and I can bring it forward |
All good, not urgent at all. Thanks 👍 |
hey @walmsles - This is now fixed in 1.18.0 More details in the release notes: https://github.com/awslabs/aws-lambda-powertools-python/releases/tag/v1.18.0 |
Using parser() to parse Event for API Gateway Lambda.
APIGatewayProxyEventModel has version as mandatory attribute
APIGatewayEventRequestContext has authorizer as mandatory attribute
These are not present in ALL Lambda events from API Gateway via Lambda Proxy integration.
What were you trying to accomplish?
Trying to parse payload as a Model according to documentation on parser
Expected Behavior
To correctly parse the API Gateway Event passed to Lambda without throwing an exception
Current Behavior
Validation exception is thrown for missing fields.
Possible Solution
Steps to Reproduce (for bugs)
Environment
The text was updated successfully, but these errors were encountered: