CodeGenieApp / CodeGenieApp/serverless-express

integration: lambda gives "Unable to determine event source based on event."

Open
#416 23 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
5.3k
Forks
676
PR merge metrics
No merged PRs in 30d

Description

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?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.