Skip to content

Conversation

@srest2021
Copy link
Member

@srest2021 srest2021 commented Nov 13, 2025

relates to REPLAY-803

depends on getsentry/sentry-release-parser#49 (tests will fail until this gets released 😅 )

Per the semver spec:

Build metadata MUST be ignored when determining version precedence. Thus two versions that differ only in the build metadata, have the same precedence.

When detecting regressions here and here, we call relay_compare_versions which uses the build code. However, we do not order by build code or number throughout the vast majority of the codebase when ordering, determining the greatest semver release, etc. For example, get_semver_releases orders by major, minor, patch, and prerelease. This gives us a bit of inconsistency when we do things like resolve an issue in the next release. We pick the next release to resolve by without using build code, but detect regressions with build code. So if the greatest semver in a project is 2.0+10 but 2.0+8 gets arbitrarily picked as the next release to resolve by, we could later detect a regression in 2.0+9 even though 2.0+9 < 2.0+10.

Let's add a new rust function relay_compare_versions_no_build_code that considers two versions differing only in the build code as equal. We also add an arg use_build_code to the compare_version python function with the default set to True. We can then turn off use_build_code when detecting regressions.

@linear
Copy link

linear bot commented Nov 13, 2025

@srest2021 srest2021 marked this pull request as ready for review November 13, 2025 21:49
@srest2021 srest2021 requested a review from a team as a code owner November 13, 2025 21:49
@srest2021 srest2021 changed the title fix(releases): Don't use build code or number when comparing release versions fix(releases): Add new compare versions function that doesn't use build code Nov 13, 2025
@srest2021 srest2021 changed the title fix(releases): Add new compare versions function that doesn't use build code feat(releases): Support comparing versions without build codes Nov 13, 2025
@srest2021 srest2021 changed the title feat(releases): Support comparing versions without build codes feat(releases): Support comparing release versions without build code Nov 13, 2025
) -> i32 {
let ver_a = sentry_release_parser::Version::parse(unsafe { (*a).as_str() })?;
let ver_b = sentry_release_parser::Version::parse(unsafe { (*b).as_str() })?;
match cmp_no_build_code(&ver_a, &ver_b) {
Copy link
Member

Choose a reason for hiding this comment

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

We could call as_semver on the versions here, and then call cmp_precedence on the semver::Version, which does what you describe in the PR description:

Compare the major, minor, patch, and pre-release value of two versions, disregarding build metadata. Versions that differ only in build metadata are considered equal. This comparison is what the SemVer spec refers to as “precedence”.

https://docs.rs/semver/latest/semver/struct.Version.html#method.cmp_precedence

This would require enabling the semver feature in the release parser dependency:

sentry-release-parser = { workspace = true, features = ["serde"] }

Copy link
Member Author

@srest2021 srest2021 Nov 14, 2025

Choose a reason for hiding this comment

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

@jjbayer Ah I see cmp_precedence is available for semver 1.0.27 (latest version) but sentry-release-parser uses semver 0.9.0 😭 I think that function was introduced after 0.9.0, I am getting this error:

Compiling relay-cabi v0.9.19 (/Users/sofiarest/code/relay/relay-cabi)
error[E0599]: no method named cmp_precedence found for struct semver::version::Version in the current scope

Copy link
Member Author

Choose a reason for hiding this comment

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

Adding a feature flag to release-parser that allows semver 1.0 and cmp_precedence: getsentry/sentry-release-parser#49

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.

3 participants