Skip to content

Fix addAction crash when called without optional attributes#218

Merged
kodiakhq[bot] merged 6 commits intohyperdxio:mainfrom
matsilva:fix/add-action-optional-attributes
Mar 19, 2026
Merged

Fix addAction crash when called without optional attributes#218
kodiakhq[bot] merged 6 commits intohyperdxio:mainfrom
matsilva:fix/add-action-optional-attributes

Conversation

@matsilva
Copy link
Copy Markdown
Contributor

Summary

  • addAction(name) crashes when the optional attributes argument is omitted because span.setAttributes(undefined) calls Object.keys() on undefined internally
  • Guard the setAttributes call so it only runs when attributes is defined
  • Add tests covering both cases (with and without attributes)

Test plan

  • Existing unit tests pass
  • New test: addAction('name') without attributes does not throw and produces a span
  • New test: addAction('name', { key: 'value' }) produces a span with the expected attribute

Guard setAttributes call so it's only invoked when attributes is defined,
preventing Object.keys(undefined) crash in OpenTelemetry internals.
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 15, 2026

🦋 Changeset detected

Latest commit: 3d19bb5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@hyperdx/otel-web Patch
@hyperdx/browser Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@teeohhem
Copy link
Copy Markdown
Contributor

Thank you for the fix!

@kodiakhq kodiakhq bot merged commit b940c5c into hyperdxio:main Mar 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants