Skip to content

fix(datadog): Encode metadata error value before embedding in error field - #174

Merged
AndrewDryga merged 1 commit into
Nebo15:masterfrom
doughsay:cd/encode-error-metadata-upstream
Aug 5, 2026
Merged

fix(datadog): Encode metadata error value before embedding in error field#174
AndrewDryga merged 1 commit into
Nebo15:masterfrom
doughsay:cd/encode-error-metadata-upstream

Conversation

@doughsay

Copy link
Copy Markdown
Contributor

format_error/4 embeds the raw metadata :error value into the log line, bypassing RedactorEncoder. A non-JSON-encodable term (e.g. an {:error, reason} tuple) then crashes the encoder.

This fix runs the value through encode/2 (which also applies redactors), matching how every other part of the line is built.

…ield

format_error/4 embedded the raw metadata :error value into the log line,
bypassing RedactorEncoder. A non-JSON-encodable term (e.g. an {:error,
reason} tuple) then crashed the encoder, and because maybe_merge is
left-biased the encoded copy of the metadata could not overwrite it. The
formatter crash surfaces as "FORMATTER CRASH: ..." fallback lines and the
original log event is lost entirely.

Run the value through encode/2 (which also applies redactors), matching
how every other part of the line is built.

@AndrewDryga AndrewDryga left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you ❤️

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 100.0% (+0.3%) from 99.737% — doughsay:cd/encode-error-metadata-upstream into Nebo15:master

@AndrewDryga
AndrewDryga merged commit 97f2ed5 into Nebo15:master Aug 5, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants