feat!: make Scope.Environment non-nullable - #5587
Draft
jamescrosswell wants to merge 1 commit into
Draft
jamescrosswell wants to merge 1 commit into
jamescrosswell wants to merge 1 commit into
Conversation
When no environment has been set on the scope, the getter now falls back to the environment resolved from the options (options, SENTRY_ENVIRONMENT, then the default), so it never returns null. Closes #5388 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## version7 #5587 +/- ##
===========================================
Coverage ? 74.73%
===========================================
Files ? 515
Lines ? 18902
Branches ? 3689
===========================================
Hits ? 14126
Misses ? 3896
Partials ? 880 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Scope.Environmentis now declared asstringrather thanstring?.#5365 made the setter revert
nulltoSentryOptions.Environment, but the property could still returnnull: a scope whose environment was never set had a null backing field, andSentryOptions.Environmentis itself nullable. To make the non-nullable declaration truthful:SettingLocator.GetEnvironment()(options →SENTRY_ENVIRONMENT→production/debug), the same value theEnricheralready stamps on events.null([AllowNull], so it still satisfiesIEventLike.Environment) and resets to that resolved default.Scope.Applycopies only an explicitly set environment between scopes. Otherwise the non-null getter would make??=never copy onto a cloned scope.Notes for review
version7.Applyto an event now writes the resolved default environment from the scope rather than leaving it for theEnricher. The value is identical.Populate_RouteData_SetToScopesnapshot now includesEnvironment: production, since serializing a scope reads the resolved value.Apply_Environment_Nullasserted a target scope's environment staysnull, which is no longer possible. It now asserts the options fallback.Closes #5388
🤖 Generated with Claude Code