Skip to content

MAUI: appsettings.json overrides options set in UseSentry #5657

Closed

Description

@jamescrosswell

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:

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

Activity

  1. linear-code commented on Oct 1, 2026

    @linear-code
  2. added
    Bug
    .NET
    Breaking Change
    Next Major
    on Oct 1, 2026
  3. added a commit that references this issue on Oct 5, 2026
    f1d32b3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

.NETBreaking ChangeBugNext Major

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions