Skip to content

Version comparison bug: 0.10.0.1 incorrectly compared as less than 0.9.0.1 #3887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
db-lyon opened this issue Mar 6, 2025 · 1 comment
Labels

Comments

@db-lyon
Copy link

db-lyon commented Mar 6, 2025

Describe the bug

When promoting a package version and creating a GitHub release, CumulusCI incorrectly compares version numbers when one version has a double-digit component. For example, version 0.10.0.1 is being treated as less than 0.9.0.1 due to string-based comparison of version components.

  • Version 0.10.0.1 should be correctly recognized as newer than 0.9.0.1

  • System treats 0.10.0.1 as older than 0.9.0.1 due to string-based comparison

Reproduction steps

Steps to reproduce:

  1. Have a package with version 0.10.0.1 in beta
  2. Try to promote it using cci task run promote_package_version
  3. The system attempts to create a release but fails because it thinks 0.9.0.1 is newer than 0.10.0.1

Your CumulusCI and Python versions

CCI: 3.90.0
PY: 3.10.16

Operating System

Windows, Github Actions, Mac

Windows environment

PowerShell

CumulusCI installation method

pip

Error Gist

No response

Additional information

While the error occurs in github_release, I believe the issue stems from the PromotePackageVersion class. It uses Python's LooseVersion class from distutils.version (copied into cumulusci/utils/version_strings.py), which does string-based comparisons of version components.

When comparing 0.10.0.1 and 0.9.0.1, the comparison is happening on the string level, where "9" is lexicographically greater than "10" because the comparison starts with "9" vs "1".

Here's the portion of code I believe to be relevant:

class LooseVersion(Version):
    component_re = re.compile(r"(\d+ | [a-z]+ | \.)", re.VERBOSE)

    def parse(self, vstring):
        self.vstring = vstring
        components = [x for x in self.component_re.split(vstring) if x and x != "."]
        for i, obj in enumerate(components):
            try:
                components[i] = int(obj)
            except ValueError:
                pass
        self.version = components
@db-lyon db-lyon added the bug label Mar 6, 2025
@db-lyon
Copy link
Author

db-lyon commented Mar 6, 2025

Current workaround is to extract the SubscriberPackageVersionId (04t) directly from my github release and update all my github actions to pass it through.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant