Response payload is `null` when Lambda is invoked with Kinesis event
bram-l opened this issue · 2 comments
After adding the Datadog Layer to a simple Lambda function that processes Kinesis events it stopped returning the response payload.
Expected Behavior
The Lambda response should be returned, which is important to enable batch item failure reporting
Actual Behavior
The response is always null
Steps to Reproduce the Problem
- Create Lambda:
const handler = async () => ({
batchItemFailures: [],
});
module.exports = { handler };
- Add Datadog layer
- Trigger Lambda with Kinesis event as payload:
$ aws lambda invoke --payload '{"Records":[{"kinesis":{}}]}' --function-name $HANDLER_NAME --cli-binary-format raw-in-base64-out response.json
The output in response.json
will be null
.
The expected output can be reproduced by removing the Datadog layer.
Specifications
- Datadog Lambda Layer version: 84
- Node version: 16
Hi, I haven't been able to reproduce this specifically - can you enable debug logs and share any errors which may have caused the function to crash? You can set DD_LOG_LEVEL: debug
to enable.
Thanks!
Hi @astuyve, thanks for your suggestion! After enabling the debug mode, the problem became immediately clear. While manually testing the 'batch item failure reporting' feature I was omitting part of the kinesis event payload, which would cause the Datadog lambda layer to throw this error:
TypeError: Cannot read properties of undefined (reading 'split')
at SpanInferrer.createInferredSpanForKinesis (/opt/nodejs/node_modules/datadog-lambda-js/trace/span-inferrer.js:299:31
When checking the source code I found this was probably caused by the missing eventID
in the payload. Since that property would always be sent by Kinesis in the normal flow this should not be considered an issue.