Crash the SDK on startup if mixed versions have been detected#4277
Merged
Crash the SDK on startup if mixed versions have been detected#4277
Conversation
Contributor
|
Member
Author
|
Need to create the linked docs page and explain common causes and how to fix this. |
Contributor
🚨 Detected changes in high risk code 🚨High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:
|
7 tasks
Contributor
🚨 Detected changes in high risk code 🚨High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:
|
Contributor
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| aba15a8 | 405.40 ms | 427.65 ms | 22.25 ms |
| a3e6b58 | 412.50 ms | 417.29 ms | 4.79 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| aba15a8 | 1.58 MiB | 2.22 MiB | 654.92 KiB |
| a3e6b58 | 1.58 MiB | 2.22 MiB | 654.87 KiB |
…-versions-android
lcian
reviewed
Mar 24, 2025
| Platform.isAndroid() | ||
| ? "https://docs.sentry.io/platforms/android/troubleshooting/mixed-versions" | ||
| : "https://docs.sentry.io/platforms/java/troubleshooting/mixed-versions"; | ||
| throw new IllegalStateException( |
Member
There was a problem hiding this comment.
I hope people won't put a try-catch around this 😄
romtsn
reviewed
Mar 27, 2025
romtsn
approved these changes
Mar 27, 2025
Co-authored-by: Roman Zavarnitsyn <rom4ek93@gmail.com>
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.
📜 Description
We check the versions of loaded Sentry dependencies. If there is a mismatch between them we now throw an exception on
Sentry.init/SentryAndroid.init. If we do not throw early the application may crash soon thereafter or at some random point depending on features used and versions mixed. We opt for the controlled exception here vs. having crashes that are hard to understand later.NOTE:
This detection at startup will only work for new releases, so mixing
8.6.0(assuming this PR lands there) and8.1.0will not be detected at startup as theMANIFEST.MFfiles with version are only present in new releases. For Android registering the packages and their version instaticblocks is also new.💡 Motivation and Context
Fixes #4132
💚 How did you test it?
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
Here's a sample exception when starting up Spring Boot 3:
Here's a sample crash for Android:
To test this you may need to change the version in
gradle.propertiesto a SNAPSHOT use./gradlew publishToMavenLocal -x test, then revertgradle.propertiesand use both the version with and without SNAPSHOT to cause the mixed version detection to kick in.