Skip to content

Cleanup configuration interface and make it fail gracefully #2800

Open

Description

@crespire

Issue Description

On server startup, when Sentry configuration may not be fully initialized, it seems that there are spots where Sentry.configuration may be nil.

This is very similar to other previous issues I've encountered around Sentry.configuration initialization: #2782 #2386

We should generally guard against non-initialized Sentry.configuration calls by ensuring that Sentry is initialized.

Currently, the method just exits early https://github.com/getsentry/sentry-ruby/blob/e219832b57c5aa32e41be4462dbe421c8c58bc67/sentry-ruby/lib/sentry-ruby.rb#L164C1-L167C8

Could it be changed such that if we are not initialized, we actually initialize Sentry? I feel this would prevent a whole class of NoMethod no nil errors I've personally run into.

Reproduction Steps

During app boot (after a new deploy for example), we occasionally run into this type of error.

Expected Behavior

Sentry does not cause a 500.

Actual Behavior

Sentry causes a 500 with no backtrace.

Ruby Version

3.4.4

SDK Version

6.1.1

Integration and Its Version

Rails 8.0.2

Sentry Config

Default

Activity

  1. linear commented on Nov 27, 2025

    @linear
  2. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Nov 27, 2025
  3. sl0thentr0py commented on Dec 1, 2025

    @sl0thentr0py
    Member

    I agree that this issue has gotten out of hand but to fix this is not so trivial and requires some core refactoring.

    Could it be changed such that if we are not initialized, we actually initialize Sentry?

    No, we cannot do that because that's not how the SDK design is supposed to be, that would defeat the purpose of having an initialize at all. But we could have a fallback configuration always, just that it could potentially cause weird behavior if not done properly.

    Sentry is supposed to be initialized extremely early in your app startup process, could you try moving it (prefixing the initializer with 01_, for instance) so that it runs first?

    Alternatively, can you tell me which particular check fails in your case so I can fix it?

  4. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Dec 1, 2025
  5. self-assigned this
    on Dec 1, 2025
  6. moved this to Waiting for: Community in GitHub Issues with 👀 3on Dec 1, 2025
  7. crespire commented on Dec 2, 2025

    @crespire
    Author

    I can try to manipulate the loading order, let me see and I'll report back.

  8. 63 remaining items

  9. sl0thentr0py commented on Dec 15, 2025

    @sl0thentr0py
    Member

    thx for the update @crespire!

    exposed an order of operations

    yes this is indeed correct, but unfortunately we cannot impose an order of at_exits, especially with puma here since it's lower level than us. Even if you place Sentry's initializer first, puma will always run first since it spawns the workers.

    I have a plan to make the configuration fetcher fail more gracefully and clean that interface with all usages, will ship that soon.

  10. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Dec 15, 2025
  11. changed the title [-]`undefined method 'send_default_pii' for nil`[/-] [+]Cleanup configuration interface and make it fail gracefully[/+] on Dec 15, 2025
  12. crespire commented on Dec 16, 2025

    @crespire
    Author

    Happy to report that it seems the issue has subsided after fixing the Redis connection issues, along with the signal passing fix.

  13. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Dec 16, 2025
  14. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions