Skip to content

Error sending span with newlines in error #203

@sheacloud

Description

@sheacloud

Expected Behavior

Returning an error from the Lambda handler function should successfully send a corresponding trace/span to DataDog, regardless of the error message contents

Actual Behavior

If the error returned by the Lambda handler function contains illegal HTTP header characters (namely newline characters), then this library fails to send the corresponding End Invocation span to the lambda extension, as it puts the error message into an HTTP header as-is. This results in the span never being sent to DataDog

Steps to Reproduce the Problem

  1. Return an error from a Lambda function that contains a newline character

Specifications

  • Datadog Go Lambda package version: v1.23.0
  • Go version: go1.24.3

Stacktrace

(From my Lambda function logs)

2025/06/28 21:39:40 {"status":"error","message":"datadog: could not send end invocation payload to the extension: Post \"http://localhost:8124/lambda/end-invocation\": net/http: invalid header field value for \"X-Datadog-Invocation-Error-Msg\""}

I took a glance at the datadog-lambda-extension code and notice that it appears to be attempting to base64 decode this header, so I tested updating this library to base64 encode this error message and that appears to have fixed the issue - sheacloud@0d92837

Let me know if this sounds correct and if I should open up a PR for this change

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions