Skip to content

fix(alerts): bound changelog upgrade range by target version#899

Open
rayair250-droid wants to merge 1 commit into
pyupio:mainfrom
rayair250-droid:fix/changelog-upgrade-range-precedence
Open

fix(alerts): bound changelog upgrade range by target version#899
rayair250-droid wants to merge 1 commit into
pyupio:mainfrom
rayair250-droid:fix/changelog-upgrade-range-precedence

Conversation

@rayair250-droid

Copy link
Copy Markdown

Summary

fetch_changelog is 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:

if version_check or spec_check and parsed_version <= to_version_parsed:

Since and binds tighter than or, this parses as:

if version_check or (spec_check and parsed_version <= to_version_parsed):

so the parsed_version <= to_version_parsed upper bound only guards the spec_check branch. When from_version is set, version_check is true for every release newer than from_version, so releases past the target to_version are wrongly included.

Reproduction (from=1.2, to=1.3, releases 0.4/1.2.1/1.3/2.0):

  • before: ['2.0', '1.3', '1.2.1']2.0 is beyond the target
  • after: ['1.3', '1.2.1']

Fix

Parenthesize so the target-version bound applies to both branches:

if (version_check or spec_check) and parsed_version <= to_version_parsed:

to_version is a required argument (always parsed), so the bound is always defined; when from_version is None, version_check is falsy and behavior is unchanged.

Test

Added test_fetch_changelog_bounds_upgrade_range_by_target_version (mocks httpx.get). It fails on the current code and passes after the fix; tests/alerts/test_utils.py stays green (14 passed).

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.
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0145c943-aebd-4c54-a60d-669ba5dacec6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant