Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing DSN causes exception rather than silently doing nothing #9290

Open
HughWarrington opened this issue Feb 29, 2024 · 3 comments
Open
Assignees
Labels
Platform: .NET Team: Web Backend SDKs team-web-sdk-backend Type: Content Issues about the contents of our docs

Comments

@HughWarrington
Copy link

Core or SDK?

Core Sentry product

Which part? Which one?

.NET SDK 4.1.2

Description

This says

The DSN tells the SDK where to send the events. If this value is not provided, the SDK will try to read it from the SENTRY_DSN environment variable. If that variable also does not exist, the SDK will just not send any events.

I have found this not to be the case.

I copied the code example on that page, and it works fine.

If I set SENTRY_DSN variable in my environment, and remove the explicit options.Dsn = ... from the code, it still works fine, using the DSN from the env var.

If I remove the explicit options.Dsn = ... from the code and do not set any environment variable, I get an unhandled ArgumentNullException and my application crashes at startup. It does not fall back to the 'just do nothing' behaviour that is documented.

I'm not sure if this is a documentation problem, or a bug in the SDK. I see someone has reported a bug here and there is a possible fix here, but it sounds like the fix might already be in the version I was using?

Suggested Solution

It would suit me best if the code behaves exactly as documented. Failing that, the docs should match the code behaviour so I can work out what to do in my situation.

@getsantry
Copy link
Contributor

getsantry bot commented Feb 29, 2024

Assigning to @getsentry/support for routing ⏲️

@HughWarrington
Copy link
Author

I guess this page would need to be updated too since it says the same thing.

@HughWarrington
Copy link
Author

On further reading, I think there is a workaround here. That works for me.

I think the docs should say something like "If you are configuring Sentry via code and you want to read the DSN from the environment, you must explicitly set options.Dsn = ""; once you have done this, the DSN will be read from the SENTRY_DSN environment variable. If that variable is unset or empty, Sentry will silently do nothing."

@bitsandfoxes bitsandfoxes self-assigned this Mar 1, 2024
@stephanie-anderson stephanie-anderson added Type: Content Issues about the contents of our docs Platform: .NET Team: Web Backend SDKs team-web-sdk-backend labels Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: .NET Team: Web Backend SDKs team-web-sdk-backend Type: Content Issues about the contents of our docs
Projects
None yet
Development

No branches or pull requests

3 participants