fix: do not set null release if SetByTracksLibrary requested#209
fix: do not set null release if SetByTracksLibrary requested#209
null release if SetByTracksLibrary requested#209Conversation
| release = when (val releaseName = dataProvider.releaseName) { | ||
| is ReleaseName.SetByApplication -> releaseName.name | ||
| ReleaseName.SetByTracksLibrary -> null | ||
| (dataProvider.releaseName as? ReleaseName.SetByApplication)?.let { |
There was a problem hiding this comment.
Hmm, couldn't you just
release = (dataProvider.releaseName as? ReleaseName.SetByApplication)?.nameThere was a problem hiding this comment.
It's the same overlook I did in #206 😅. The version you provided will assign null to release if dataProvider.releaseName is not SetByApplication. And, in result, will overwrite the value Sentry SDK automatically assigned (what we wanted).
There was a problem hiding this comment.
Aah gotcha, you don't really want the value to be set to null when the cast doesn't succeed 👍
There was a problem hiding this comment.
Yes - when dataProvider.releaseName is SetByTracksLibrary, we should do nothing with options.release
There was a problem hiding this comment.
when dataProvider.releaseName is SetByTracksLibrary
You mean isn't ? 😅
There was a problem hiding this comment.
🤔 ReleaseName can be either SetByTracksLibrary or SetByApplication.
When dataProvider.releaseName is SetByTracksLibrary we should do nothing with options.release. I think that's the correct description, matching the implementation.
There was a problem hiding this comment.
Ah, I thought you were mentioning the same type that's in the code. All clear now, thanks!
Description
This PR fixes my overlook introduced in #206 . Because
SentryOptionsinitialization happens after Sentry SDK sets the defaultreleasename, if we setnullin case ofSetByTracksLibrary, we overwrite the value Sentry prepared.I should've verified it before merge. Sorry for trouble.
Fix
In the case of
SetByTracksLibrarysimply assign nothing related to releasesVerification
Using a test project:
Before
After
nullhere is expected