Skip to content

fix: _set_status should not override existing span status (#3713)#4410

Open
RiyaChaturvedi37 wants to merge 8 commits intoopen-telemetry:mainfrom
RiyaChaturvedi37:fix/set-status-override
Open

fix: _set_status should not override existing span status (#3713)#4410
RiyaChaturvedi37 wants to merge 8 commits intoopen-telemetry:mainfrom
RiyaChaturvedi37:fix/set-status-override

Conversation

@RiyaChaturvedi37
Copy link
Copy Markdown
Contributor

Description

Fixes #3713

Problem

_set_status was unconditionally calling span.set_status(Status(status))
without checking if a status was already set. This caused two bugs:

  • A previously set ERROR status could be downgraded to OK
  • A previously set status description was wiped out (overridden with None)

Fix

Added a priority check before calling span.set_status:

  • Never downgrade status (ERROR → OK or ERROR → UNSET are blocked)
  • Preserve existing description if same status code and no new description provided

Tests

Added 4 new tests in test_semconv_status.py:

  • test_does_not_downgrade_error_to_ok
  • test_does_not_wipe_description_with_none
  • test_upgrades_unset_to_error
  • test_unset_to_ok

@RiyaChaturvedi37 RiyaChaturvedi37 force-pushed the fix/set-status-override branch from 3ae80cc to d712f06 Compare April 9, 2026 14:55
@RiyaChaturvedi37 RiyaChaturvedi37 force-pushed the fix/set-status-override branch from 239f47f to 7214d29 Compare April 10, 2026 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

_set_status semconv helper can override span status if already defined

2 participants