Skip to content

Revert unintentional changes to Shell breadcrumb tests

cd8b52b
Select commit
Loading
Failed to load commit list.
Open

feat: Automatic trace instrumentation for MAUI #5138

Revert unintentional changes to Shell breadcrumb tests
cd8b52b
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden completed Apr 22, 2026 in 18m 11s

5 issues

High

Test will fail: Hub.GetSpan() not mocked, causing StartNavigationSpan to return null - `test/Sentry.Maui.Tests/MauiEventsBinderTests.Shell.cs:209-215`

The test OnShellOnNavigated_FinishesNavSpan is missing the _fixture.Hub.GetSpan().Returns(mockTransaction) setup that other similar tests in this file have (see lines 70, 92, 109). Without this mock, StartNavigationSpan checks if (_hub.GetSpan() is not { IsFinished: false } parentSpan) and returns null immediately. This causes the Assert.NotNull(navSpan) assertion to fail, and subsequent assertions on navSpan.Description and navSpan.Received(1).Finish() will also fail.

Also found at:

  • test/Sentry.Maui.Tests/MauiEventsBinderTests.Shell.cs:128-148

Medium

Test asserts on wrong Scope object, potentially masking bugs - `test/Sentry.Maui.Tests/MauiEventsBinderTests.Button.cs:285`

The test StartUiTransaction_TransactionOnScope_NotBoundToScope creates a new local scope and configures the Hub mock to use it via SubstituteConfigureScope(scope) at line 269. However, the assertion at line 285 checks _fixture.Scope.Transaction instead of the local scope.Transaction. Since SubstituteConfigureScope overwrites the mock to use the new scope, the assertion is checking the original fixture scope that is no longer connected to the Hub's ConfigureScope behavior. This test may pass even if the implementation is broken because it's not checking the correct scope object.

Navigation span never finished when resolved route is null - `src/Sentry.Maui/Internal/MauiEventsBinder.cs:582-585`

In OnShellOnNavigated, when e.Current?.Location is null and EnableAutoTransactions is true, the method returns early at line 584 without calling FinishNavigationSpan(). However, OnShellOnNavigating would have already started a navigation span via StartNavigationSpan(). This leaves the span in an unfinished state, causing a resource leak where the span remains open until some other event (like another navigation, window stop, or button click) happens to close it.

Also found at:

  • test/Sentry.Maui.Tests/MauiEventsBinderTests.Shell.cs:127-146
  • test/Sentry.Maui.Tests/MauiEventsBinderTests.Shell.cs:215

Low

Error log never executes due to null-conditional on HubAdapter.GetSentryOptions() - `src/Sentry/SentrySdk.cs:215`

When UseHub is called with a HubAdapter, the code attempts to log an error via hub.GetSentryOptions()?.LogError(...). However, GetSentryOptions() on HubAdapter delegates to SentrySdk.CurrentOptions, which calls CurrentHub.GetSentryOptions(). At this point, CurrentHub is still DisabledHub.Instance (or the previous hub), and DisabledHub returns null for GetSentryOptions(). This means the error message will never be logged, making the diagnostic message dead code.

Also found at:

  • src/Sentry/TransactionTracer.cs:332-338
Test method name contains accidental double underscore typo - `test/Sentry.Maui.Tests/MauiEventsBinderTests.Window.cs:182`

The test method name was changed from Window_PopCanceled_AddsBreadcrumb to Window_PopCanceled__AddsBreadcrumb, introducing a double underscore (__) which is inconsistent with all other test methods in the file that use single underscores as separators. This is likely an accidental typo rather than an intentional change.

4 skills analyzed
Skill Findings Duration Cost
code-review 2 5m 44s $7.81
find-bugs 3 14m 1s $15.18
gha-security-review 0 17m 25s $2.31
security-review 0 15m 23s $2.97

Duration: 52m 33s · Tokens: 18.9M in / 204.3k out · Cost: $28.32 (+extraction: $0.03, +merge: $0.00, +fix_gate: $0.02, +dedup: $0.01)