Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sdk-trace-base): avoid keeping non-string status.message on Span#setStatus() #4999

Conversation

pichlermarc
Copy link
Member

@pichlermarc pichlermarc commented Sep 18, 2024

Which problem is this PR solving?

See #4998, Span#setStatus() is commonly used in catch blocks to set the span status SpanStatusCode.ERROR. While doing so, it's an easy mistake to make to also pass the Error as the message, which expects a string, as TypeScript will no complain as you assign any to string.

Therefore this PR adds a validation step to ensure we don't pass on the incorrect type downstream, which can cause OTLP/JSON export requests to be rejected.

Fixes #4998
See also renovatebot/renovate#31459

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Added unit test

@pichlermarc pichlermarc marked this pull request as ready for review September 18, 2024 11:22
@pichlermarc pichlermarc requested a review from a team September 18, 2024 11:22
Copy link
Member

@dyladan dyladan left a comment

Choose a reason for hiding this comment

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

Left a comment but I'm not actually sure what the correct behavior should be. LMK what you think

@pichlermarc pichlermarc requested a review from a team September 19, 2024 10:53
@pichlermarc pichlermarc added this pull request to the merge queue Sep 23, 2024
Merged via the queue into open-telemetry:main with commit 8900cfd Sep 23, 2024
19 checks passed
@pichlermarc pichlermarc deleted the fix/avoid-non-string-span-status-message branch September 23, 2024 15:51
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.

[sdk-trace] no type validation in places where it is common to pass caught Errors
3 participants