Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/serverless/api-gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function normalizeHeaders(event, lowerCaseKey = false) {
const headers = event.multiValueHeaders ?? event.headers

if (!headers) {
return
return {}
}

return Object.fromEntries(
Expand Down
14 changes: 14 additions & 0 deletions test/unit/serverless/api-gateway-v2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,17 @@ tap.test('should capture request headers', (t) => {
t.end()
}
})

tap.test('should not crash when headers are non-existent', (t) => {
const { lambda, event, functionContext, responseBody } = t.context
delete event.headers

const wrappedHandler = lambda.patchLambdaHandler((event, context, callback) => {
callback(null, responseBody)
})

t.doesNotThrow(() => {
wrappedHandler(event, functionContext, () => {})
})
t.end()
})