Skip to content

Conversation

@fuguiKz
Copy link

@fuguiKz fuguiKz commented Dec 19, 2025

Resolves getsentry/sentry-dotnet#4777

Adds a basic Web.config appSettings snippet and updates the ASP.NET guide example to read the DSN from ConfigurationManager.AppSettings["SentryDsn"].

Urgency: not urgent.

@vercel
Copy link

vercel bot commented Dec 19, 2025

@fuguiKz is attempting to deploy a commit to the Sentry Team on Vercel.

A member of the Team first needs to authorize it.

_sentry = SentrySdk.Init(options =>
{
options.Dsn = "___PUBLIC_DSN___";
options.Dsn = ConfigurationManager.AppSettings["SentryDsn"];
Copy link

Choose a reason for hiding this comment

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

Bug: The documentation's code example for ASP.NET will crash the application on startup if the SentryDsn key is missing from Web.config due to an unhandled ArgumentNullException.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

The code example in the documentation for ASP.NET initialization uses options.Dsn = ConfigurationManager.AppSettings["SentryDsn"];. If the SentryDsn key is missing from Web.config, ConfigurationManager.AppSettings returns null. In Sentry SDK 4.0+, passing a null DSN to SentrySdk.Init() throws an ArgumentNullException. Because this initialization code is placed in Application_Start(), the unhandled exception will prevent the application from starting. The documentation fails to warn users that this configuration key is mandatory, making it easy for a developer following the guide to cause a startup crash.

💡 Suggested Fix

Update the documentation to include a prominent warning that the SentryDsn key in Web.config is mandatory. Alternatively, modify the code example to include null-checking before assigning the DSN to options.Dsn to prevent the SentrySdk.Init() call from throwing an exception if the key is not found.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: docs/platforms/dotnet/guides/aspnet/index.mdx#L64

Potential issue: The code example in the documentation for ASP.NET initialization uses
`options.Dsn = ConfigurationManager.AppSettings["SentryDsn"];`. If the `SentryDsn` key
is missing from `Web.config`, `ConfigurationManager.AppSettings` returns `null`. In
Sentry SDK 4.0+, passing a `null` DSN to `SentrySdk.Init()` throws an
`ArgumentNullException`. Because this initialization code is placed in
`Application_Start()`, the unhandled exception will prevent the application from
starting. The documentation fails to warn users that this configuration key is
mandatory, making it easy for a developer following the guide to cause a startup crash.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 7752030

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Web.config example to ASP.NET Quick Start guide

1 participant