Skip to content

Fix addAction crash when called without optional attributes#218

Open
matsilva wants to merge 1 commit intohyperdxio:mainfrom
matsilva:fix/add-action-optional-attributes
Open

Fix addAction crash when called without optional attributes#218
matsilva wants to merge 1 commit intohyperdxio:mainfrom
matsilva:fix/add-action-optional-attributes

Conversation

@matsilva
Copy link

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

changeset-bot bot commented Feb 15, 2026

🦋 Changeset detected

Latest commit: 8eb924c

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

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.

1 participant