Skip to content

fix(auto-install): Use Sentry BOM version for installs#265

Merged
adinauer merged 3 commits into
mainfrom
side-quest/detect-bom-version-for-install
Jul 14, 2026
Merged

fix(auto-install): Use Sentry BOM version for installs#265
adinauer merged 3 commits into
mainfrom
side-quest/detect-bom-version-for-install

Conversation

@adinauer

@adinauer adinauer commented Jul 1, 2026

Copy link
Copy Markdown
Member

Use managed Sentry SDK versions from Maven dependency management when auto-installing Sentry dependencies.

When a project imported sentry-bom or sentry-opentelemetry-bom without declaring io.sentry:sentry, the plugin fell back to its bundled SDK version. That could install Sentry modules at a different version than the BOM selected. This now reads the managed Sentry version first and feeds it into the Sentry and integration installers, while preserving the existing behavior of using an already-resolved io.sentry:sentry dependency when present.

adinauer and others added 2 commits July 1, 2026 16:07
Detect managed Sentry SDK versions from dependency management before falling back to the plugin-bundled SDK version. This keeps auto-installed Sentry modules aligned with imported sentry-bom or sentry-opentelemetry-bom versions.

Co-Authored-By: Claude <[email protected]>
Document that auto-installed Sentry dependencies now use imported BOM versions.

Co-Authored-By: Claude <[email protected]>
Comment thread src/main/java/io/sentry/autoinstall/SentryInstaller.java Outdated
…staller

Remove the convenience install() overload that forwarded to the 3-arg
version with null. Callers now pass null for managedSentryVersion
explicitly, which is clearer about intent.

Co-Authored-By: Claude <[email protected]>

@lbloder lbloder left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@adinauer
adinauer marked this pull request as ready for review July 14, 2026 04:59
@adinauer
adinauer requested review from markushi and romtsn as code owners July 14, 2026 04:59
@adinauer
adinauer merged commit 93efe18 into main Jul 14, 2026
15 checks passed

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b9cbec6. Configure here.

originalModel.getDependencyManagement(), project, managedVersions);
}

return managedVersions.stream().findFirst().orElse(null);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BOM wins over sentry override

Medium Severity

When several Sentry-related entries appear in dependencyManagement, the resolver keeps each resolved version in a set and returns the first one inserted. If a sentry-bom import is listed before an explicit managed io.sentry:sentry version, auto-install can use the BOM version instead of the pinned core SDK version Maven would apply elsewhere.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b9cbec6. Configure here.

adinauer added a commit that referenced this pull request Jul 14, 2026
#268)

Builds on top of #265. Maven port of
getsentry/sentry-android-gradle-plugin#1350 (which itself is stacked on
the SAGP equivalent of #265,
getsentry/sentry-android-gradle-plugin#1349).

## What

Fails the build when the OpenTelemetry versions resolved for a project
are **downgraded** below what Sentry's `sentry-opentelemetry-*`
artifacts were built and tested against.

## Why

Sentry's OpenTelemetry artifacts declare the exact OpenTelemetry
versions they require. When another dependency management mechanism —
most commonly Spring Boot (via `spring-boot-starter-parent` or an
imported `spring-boot-dependencies` BOM) — forces OpenTelemetry below
those versions, it happens **silently** (the user never declares an OTel
version). Running against the mismatched versions can throw
`ClassNotFoundException` / `NoSuchMethodError` at runtime. This surfaces
the problem at build time with actionable guidance instead.

This **replaces an earlier approach that auto-installed the BOM**
(previous PR #266). In Maven a late-injected import-scope BOM is a no-op
(BOM imports are flattened during effective-model building, before
`afterProjectsRead`), and rewriting inherited `dependencyManagement` in
place is too surprising. Detecting-and-failing is the more honest
behavior — same conclusion as SAGP #1350.

## How it works

- Runs in the lifecycle participant (automatic, no execution config
needed), reusing the dependency resolution already done for
auto-install.
- Gated by a cheap check: skipped entirely unless the project uses a
`sentry-opentelemetry-*` artifact.
- Resolves each present `sentry-opentelemetry-*` artifact to determine
the OpenTelemetry versions it requires (declared dependencies + its own
dependency management), then compares against the versions actually
resolved on the project. A resolved version lower than the required
version is a downgrade.
- Only OpenTelemetry modules a `sentry-opentelemetry-*` artifact
requires are inspected, so unrelated OpenTelemetry usage is never
flagged. Unparseable versions are skipped.
- The failure message lists each downgrade and shows the exact
`<dependencyManagement>` import for `sentry-opentelemetry-bom` at the
resolved Sentry version, noting Maven's first-declaration-wins ordering
when Spring Boot is present.

## Config

Opt out with
`<skipValidateOpenTelemetryVersions>true</skipValidateOpenTelemetryVersions>`.
Adds a `SENTRY_validateOpenTelemetryVersions` telemetry tag.

## Phase / placement

Implemented in the lifecycle participant (runs before any phase,
automatically) rather than as an opt-in `validate`-phase mojo, so users
get protected by default — matching SAGP #1350's automatic, default-on
behavior.

## Open items (mirroring SAGP #1350)

- **Docs URL is a placeholder**
(`.../platforms/java/tracing/instrumentation/opentelemetry/troubleshooting/`)
and must resolve to a live page before release.
- **Default-on is a product call.** Defaulting a build-breaking check to
on will surprise existing Spring Boot users on upgrade. Either keep
default-on with a clearly-flagged behavioral-change changelog entry, or
ship opt-in first and flip later based on telemetry.

## Tests

- Unit (`OpenTelemetryVersionCheckerTest`): downgrade detection (match /
upgrade / not-resolved / alpha / unparseable), eligibility gate, and
failure-message content (mismatch line, BOM snippet, opt-out, Spring
Boot ordering note).
- Integration (`OpenTelemetryVersionCheckTestIT`): build fails on a
Spring Boot parent downgrade with the guidance message; succeeds when
not downgraded; succeeds when disabled; no-op without a Sentry
OpenTelemetry dependency.

Co-authored with Claude.

---------

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants