Skip to content

feat: Allow integrations to define control flow exceptions#6425

Merged
sentrivana merged 4 commits into
masterfrom
ivana/control-flow-exceptions
May 27, 2026
Merged

feat: Allow integrations to define control flow exceptions#6425
sentrivana merged 4 commits into
masterfrom
ivana/control-flow-exceptions

Conversation

@sentrivana
Copy link
Copy Markdown
Contributor

@sentrivana sentrivana commented May 27, 2026

Description

Some frameworks we're integrating with use specific exception types for control flow. If we encounter them, we should not set the status of the current span to error.

Implement a global ignore list that each integration can populate with control flow exceptions known to it, so that whenever a span finishes, it has access to the list and can decide whether the exception that occurred constitutes an error or not.

Issues

Reminders

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 27, 2026

Codecov Results 📊

282 passed | Total: 282 | Pass Rate: 100% | Execution Time: 45.40s

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 14769 uncovered lines.
✅ Project coverage is 34.91%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
sentry_sdk/utils.py 100.00% ⚠️ 1 partials
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    34.91%    34.91%        —%
==========================================
  Files          190       190         —
  Lines        22689     22689         —
  Branches      7742      7742         —
==========================================
+ Hits          7920      7920         —
- Misses       14769     14769         —
- Partials       832       832         —

Generated by Codecov Action

Comment thread sentry_sdk/integrations/aiohttp.py Outdated
Copy link
Copy Markdown
Contributor

@sentry-warden sentry-warden Bot left a comment

Choose a reason for hiding this comment

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

No tests cover the new control-flow exception mechanism

There are no tests validating that register_control_flow_exception / should_be_treated_as_error suppress span-error status for registered exceptions, nor that AioHttpIntegration correctly exempts HTTPException — please add coverage for this new behavior.

Evidence
  • grep across tests/ finds zero matches for control_flow, register_control_flow_exception, or should_be_treated_as_error.
  • tests/integrations/aiohttp/test_aiohttp.py contains no references to HTTPException span-status behaviour.
  • should_be_treated_as_error is called in both sentry_sdk/traces.py:335 and sentry_sdk/tracing.py:398 to set span status, making the untested path critical.

Identified by Warden code-review

Comment thread sentry_sdk/integrations/aiohttp.py Outdated
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 27, 2026

PY-2492

@sentrivana sentrivana marked this pull request as ready for review May 27, 2026 07:57
@sentrivana sentrivana requested a review from a team as a code owner May 27, 2026 07:57
Copy link
Copy Markdown
Contributor

@alexander-alderman-webb alexander-alderman-webb left a comment

Choose a reason for hiding this comment

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

Nice not increasing API surface!

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b81e07a. Configure here.

Comment thread sentry_sdk/integrations/aiohttp.py Outdated
@sentrivana sentrivana enabled auto-merge (squash) May 27, 2026 08:30
@sentrivana sentrivana disabled auto-merge May 27, 2026 08:31
@sentrivana sentrivana enabled auto-merge (squash) May 27, 2026 08:32
@sentrivana sentrivana merged commit 05432ab into master May 27, 2026
156 checks passed
@sentrivana sentrivana deleted the ivana/control-flow-exceptions branch May 27, 2026 08:45
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.

Handle control flow exceptions when assigning span status

2 participants