Repository navigation
Description
Description
In MAUI, a setting present in appsettings.json overrides the same setting passed to UseSentry(options => ...). It should be the other way around: configuration supplies the defaults, and code the app runs overrides them.
UseSentry registers the options callback before the setup that binds the Sentry configuration section:
SentryMauiAppBuilderExtensions.cs#L49—services.Configure(configureOptions)SentryMauiAppBuilderExtensions.cs#L56—services.AddSingleton<IConfigureOptions<SentryMauiOptions>, SentryMauiOptionsSetup>()
OptionsFactory<T> runs IConfigureOptions<T> in registration order, so the binding runs last and wins. BindableSentryMauiOptions.ApplyTo only assigns keys that are actually present in configuration, so this only bites when the same setting appears in both places.
Measured on version7 (2f21e3f), with Sentry:Release and Sentry:Environment in configuration and a UseSentry callback setting Release:
| Integration | Release (set in both) |
Environment (configuration only) |
|---|---|---|
| ASP.NET Core | from-code |
from-configuration |
| MAUI | from-configuration |
from-configuration |
ASP.NET Core gets this right because its UseSentry registers the configuration setups inside ConfigureLogging and the user callback last.
Fix
Register SentryMauiOptionsSetup before services.Configure(configureOptions). Cover both directions with tests: the callback wins where the two overlap, and configuration still applies to settings the callback doesn't touch. Note that the existing CanUseSentry_WithConfiguration* tests use Services.Configure<SentryMauiOptions>(delegate) rather than an IConfiguration section, so they don't exercise this.
Why next major
A MAUI app that currently relies on appsettings.json winning would see its effective settings change.
See also
- The same inversion in Blazor WebAssembly, fixed in feat(mel)!: the Microsoft.Extensions.Logging integration no longer initializes the SDK #5595 (
ae4236397) because that PR restructured the Blazor options anyway. Blazor was the worse case: it applied platform-required defaults (DetectStartupTime,RequestBodyCompressionLevel,IsGlobalModeEnabled) inside the same callback delegate, so a configuration key could reintroduce thePlatformNotSupportedExceptionthose defaults exist to avoid. MAUI has no equivalent defaults at stake — just the precedence oddity. - Spotted while reviewing Don't initialise the Sdk from logging integrations #5245 / Don't initialise the Sdk from logging integrations #5245.
Activity
linear-code commentedon Oct 1, 2026
NET-838
fix(maui)!: options set in UseSentry now take precedence over appsett…