fix(alerts): bound changelog upgrade range by target version#899
Open
rayair250-droid wants to merge 1 commit into
Open
fix(alerts): bound changelog upgrade range by target version#899rayair250-droid wants to merge 1 commit into
rayair250-droid wants to merge 1 commit into
Conversation
In fetch_changelog, the condition
if version_check or spec_check and parsed_version <= to_version_parsed:
parses as 'version_check or (spec_check and ...)' because 'and' binds tighter
than 'or', so the parsed_version <= to_version_parsed upper bound only guarded
the spec_check branch. When from_version is set, every release newer than
from_version was added to the changelog regardless of the target version,
contradicting the function's own comment (1.2 -> 1.3 should include 1.2.1 but
not later releases). Parenthesize so the target-version bound applies to both
branches. Added a regression test.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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
fetch_changelogis meant to collect only the releases within an upgrade range (per its own comment: "update from 1.2 to 1.3 includes a changelog for 1.2.1 but not for 0.4"). The filter has an operator-precedence bug:Since
andbinds tighter thanor, this parses as:so the
parsed_version <= to_version_parsedupper bound only guards thespec_checkbranch. Whenfrom_versionis set,version_checkis true for every release newer thanfrom_version, so releases past the targetto_versionare wrongly included.Reproduction (
from=1.2,to=1.3, releases0.4/1.2.1/1.3/2.0):['2.0', '1.3', '1.2.1']—2.0is beyond the target['1.3', '1.2.1']✅Fix
Parenthesize so the target-version bound applies to both branches:
to_versionis a required argument (always parsed), so the bound is always defined; whenfrom_versionisNone,version_checkis falsy and behavior is unchanged.Test
Added
test_fetch_changelog_bounds_upgrade_range_by_target_version(mockshttpx.get). It fails on the current code and passes after the fix;tests/alerts/test_utils.pystays green (14 passed).