serverless-express: integration: lambda gives "Unable to determine event source based on event."
Hi all,
When deploying using serverless with serverless-api-gateway-caching like so:
functions:
graphql:
handler: src/handler.graphqlHandler
events:
- http:
path: graphql
method: post
cors: true
integration: lambda
caching:
enabled: true
cacheKeyParameters:
- name: integration.request.header.bodyValue
mappedFrom: method.request.body
The event is structured like this:
{
body: {
...gql...
},
method: 'POST',
principalId: '',
stage: 'dev',
cognitoPoolClaims: { sub: '' },
enhancedAuthContext: {},
headers: {
Accept: '*/*',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'en-GB,en;q=0.5',
'cache-control': 'no-cache',
'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': 'GB',
'content-type': 'application/json',
dnt: '1',
Host: '...host url...',
origin: 'https://...origin url...',
pragma: 'no-cache',
Referer: 'https://...referrer url...',
'sec-gpc': '1',
'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0',
Via: '2.0 xxxxxx.cloudfront.net (CloudFront)',
'X-Amz-Cf-Id': 'xxxxxx',
'X-Amzn-Trace-Id': 'Root=xxxxxx',
'X-Forwarded-For': '...some ips...',
'X-Forwarded-Port': '443',
'X-Forwarded-Proto': 'https'
},
query: {},
path: {},
identity: {
cognitoIdentityPoolId: '',
accountId: '',
cognitoIdentityId: '',
caller: '',
sourceIp: '...ip...',
principalOrgId: '',
accessKey: '',
cognitoAuthenticationType: '',
cognitoAuthenticationProvider: '',
userArn: '',
userAgent: 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0',
user: ''
},
stageVariables: {},
requestPath: '/graphql'
}
It seems you cannot enable method.request.body cacheKeyParameters without integration: lambda which seems to mess with the event.
Should this be an event type we are able to handle or am I missing a setting to turn it in to an event that can be handled?
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 22
I had this problem with
serverless-plugin-warmup, and i need to set my payload event like this:β> Now, itβs all working well π
This should be reopened. @PeterTrotter may have had luck using
integration: lambda-proxy, but others do need to useintegration: lambdaand this issue persistsWhat trigger/event source are you using
We had the same problem.
Event:
Problem
Resolution
Basically we need to factory some methods to event object when received Async Event from
API GatewayThis is awful, because we need to manipulate event, so each change will be analyze because will could be a problem for us.
Getting the same error when using @vendia/serverless-express via apollo-server-lambda on Vercel.
Looks like
event.requestContextis missing from that https://github.com/vendia/serverless-express/blob/mainline/src/event-sources/utils.js#L75. If you removecachingdoes this work? Is this an API Gateway V1 or V2 setup?