Skip to content

fix: Keep the transaction when TransactionNameProvider throws - #5941

Merged
jamescrosswell merged 1 commit into
mainfrom
fix/5718-transaction-name-provider-fallback
Nov 16, 2026
Merged

jamescrosswell merged 1 commit into
mainfrom
fix/5718-transaction-name-provider-fallback

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Fixes #5718

Repro: getsentry/repro#95

Cause: SentryTracingMiddleware calls the TransactionNameProvider inside its finally block, before transaction.Finish(). When the provider throws, the exception escapes the finally, so the transaction is never finished (and dropped), and the request fails (or the original request exception gets replaced).

Fix: Catch and log exceptions from the provider. When there is no route-derived name, name the transaction <unlabeled transaction> (source Custom) instead of falling back to the URL path, which may contain PII. With PreferTransactionNameProvider and a resolved route, a throwing provider is treated like one returning null: the route name is kept.

No public API change.

via @dingsdax.

--

View Session [Sentry]

A throwing TransactionNameProvider escaped the finally block of SentryTracingMiddleware, so the transaction was never finished and the request failed. Catch and log the exception. Without a route name, name the transaction '<unlabeled transaction>' instead of falling back to the URL path, which may contain PII.

Fixes #5718

Co-Authored-By: Johannes Daxboeck <114897+dingsdax@users.noreply.github.com>
@sentry-junior
sentry-junior Bot requested a review from dingsdax November 16, 2026 09:45
@sentry-junior sentry-junior Bot added the junior-automation:repro PR from the Junior SDK repro flow label Nov 16, 2026
@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 16, 2026
@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.46%. Comparing base (b9a48d2) to head (a882f5d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5941      +/-   ##
==========================================
+ Coverage   77.43%   77.46%   +0.02%     
==========================================
  Files         546      546              
  Lines       20053    20069      +16     
  Branches     3962     3963       +1     
==========================================
+ Hits        15529    15547      +18     
+ Misses       3659     3658       -1     
+ Partials      865      864       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jamescrosswell jamescrosswell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

junior-automation:repro PR from the Junior SDK repro flow risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fall back to an unlabeled transaction when provider fails

2 participants