Repository navigation
fix: Keep the transaction when TransactionNameProvider throws - #5941
Merged
Merged
Conversation
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
Bot
requested review from
jamescrosswell and
ric-oliv
as code owners
November 16, 2026 09:45
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
jamescrosswell
deleted the
fix/5718-transaction-name-provider-fallback
branch
November 16, 2026 21:13
27 tasks done
This was referenced Nov 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5718
Repro: getsentry/repro#95
Cause:
SentryTracingMiddlewarecalls theTransactionNameProviderinside itsfinallyblock, beforetransaction.Finish(). When the provider throws, the exception escapes thefinally, 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>(sourceCustom) instead of falling back to the URL path, which may contain PII. WithPreferTransactionNameProviderand a resolved route, a throwing provider is treated like one returningnull: the route name is kept.No public API change.
via @dingsdax.
--
View Session [Sentry]