Skip to content

Conversation

sentrivana
Copy link
Contributor

@sentrivana sentrivana commented Aug 25, 2025

Ref #4718

Does not solve the underlying issue and might leave things in an inconsistent state, but it's still preferable to letting an error bubble up to the user.

Copy link

codecov bot commented Aug 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.89%. Comparing base (f702ec9) to head (44d568e).
⚠️ Report is 5 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4719      +/-   ##
==========================================
- Coverage   84.89%   84.89%   -0.01%     
==========================================
  Files         156      156              
  Lines       16115    16116       +1     
  Branches     2741     2741              
==========================================
  Hits        13681    13681              
- Misses       1645     1650       +5     
+ Partials      789      785       -4     
Files with missing lines Coverage Δ
sentry_sdk/tracing.py 86.66% <100.00%> (+0.02%) ⬆️

... and 5 files with indirect coverage changes

@sentrivana
Copy link
Contributor Author

Fixed properly via #4720

@sentrivana sentrivana closed this Aug 26, 2025
@sentrivana sentrivana reopened this Sep 3, 2025
@sentrivana sentrivana marked this pull request as ready for review September 3, 2025 12:49
@sentrivana sentrivana requested a review from a team as a code owner September 3, 2025 12:49
scope, old_span = self._context_manager_state
del self._context_manager_state
self.finish(scope)
scope.span = old_span
Copy link

Choose a reason for hiding this comment

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

Bug: Tracing Context Corruption Due to Exception Handling

Wrapping the span's __exit__ cleanup in capture_internal_exceptions() can silently prevent the scope's active span from being restored, leaving the tracing context inconsistent. If an intermediate cleanup step fails, subsequent critical operations are skipped. Additionally, set_status is inconsistently outside this block, allowing its internal errors to surface.

Fix in Cursor Fix in Web

@sentrivana sentrivana merged commit 5f2adcf into master Sep 3, 2025
135 checks passed
@sentrivana sentrivana deleted the ivana/context_manager_state-missing-in-span-exit branch September 3, 2025 14:11
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.

2 participants