Skip to content
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

[BUG] Invalid operator '~=' for version comparison #66984

Open
2 of 9 tasks
OrangeDog opened this issue Oct 22, 2024 · 0 comments
Open
2 of 9 tasks

[BUG] Invalid operator '~=' for version comparison #66984

OrangeDog opened this issue Oct 22, 2024 · 0 comments
Labels
Bug broken, incorrect, or confusing behavior needs-triage

Comments

@OrangeDog
Copy link
Contributor

OrangeDog commented Oct 22, 2024

Description
When using the ~= version specifier with pip.installed errors are logged. The state does run successfully, though always thinks there have been changes.

Setup

  • on-prem machine
  • VM (Virtualbox, KVM, etc. please specify)
  • VM running on a cloud service, please be explicit and add details
  • container (Kubernetes, Docker, containerd, etc. please specify)
  • or a combination, please be explicit
  • jails if it is FreeBSD
  • classic packaging
  • onedir packaging
  • used bootstrap to install

Steps to Reproduce the behavior

# salt-call --local state.single pip.installed name='elasticsearch ~= 7.17.6' -linfo
[INFO] Loading fresh modules for state activity
[INFO] Running state [elasticsearch ~= 7.17.6] at time 15:47:39.466748
[INFO] Executing state pip.installed for [elasticsearch ~= 7.17.6]
[INFO] Executing command /opt/saltstack/salt/salt-pip in directory '/root'
[INFO] Executing command /opt/saltstack/salt/salt-pip in directory '/root'
[ERROR] Invalid operator '~=' for version comparison
[INFO] Executing command /opt/saltstack/salt/salt-pip in directory '/root'
[INFO] Executing command /opt/saltstack/salt/salt-pip in directory '/root'
[INFO] Executing command /opt/saltstack/salt/salt-pip in directory '/root'
[INFO] {'elasticsearch==7.17.12': 'Installed'}
[INFO] Loading fresh modules for state activity
[INFO] Completed state [elasticsearch ~= 7.17.6] at time 15:47:43.298461 (duration_in_ms=3831.713)
local:
  Name: elasticsearch ~= 7.17.6 - Function: pip.installed - Result: Changed - Started: 15:47:39.466748 - Duration: 3831.713 ms

Summary for local
------------
Succeeded: 1 (changed=1)
Failed:    0
------------
Total states run:     1
Total run time:   3.832 s

Expected behavior
All Python package version specifiers should be handled correctly, with no errors logged.

Versions Report

salt-call --versions
Salt Version:
          Salt: 3006.9

Python Version:
        Python: 3.10.14 (main, Jun 26 2024, 11:44:37) [GCC 11.2.0]

Dependency Versions:
          cffi: 1.17.1
      cherrypy: 18.6.1
  cryptography: 42.0.5
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.4
       libgit2: 1.7.1
  looseversion: 1.0.2
      M2Crypto: 0.38.0
          Mako: Not Installed
       msgpack: 1.0.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 22.0
     pycparser: 2.21
      pycrypto: Not Installed
  pycryptodome: 3.19.1
        pygit2: 1.13.3
  python-gnupg: 0.4.8
        PyYAML: 6.0.1
         PyZMQ: 23.2.0
        relenv: 0.17.0
         smmap: Not Installed
       timelib: 0.2.4
       Tornado: 4.5.3
           ZMQ: 4.3.4

System Versions:
          dist: ubuntu 24.04.1 noble
        locale: utf-8
       machine: x86_64
       release: 6.8.0-47-generic
        system: Linux
       version: Ubuntu 24.04.1 noble

Additional information
There are similar issues with other specifiers, for example:

[ERROR] Comparison of package versions "7.17.12" and "7.17.*" failed: Invalid version: '7.17.*'
Traceback (most recent call last):
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/pip_state.py", line 365, in _pep440_version_cmp
    if pkg_resources.parse_version(pkg1) < pkg_resources.parse_version(pkg2):
  File "/opt/saltstack/salt/lib/python3.10/site-packages/pkg_resources/_vendor/packaging/version.py", line 198, in __init__
    raise InvalidVersion(f"Invalid version: '{version}'")
pkg_resources.extern.packaging.version.InvalidVersion: Invalid version: '7.17.*'
@OrangeDog OrangeDog added Bug broken, incorrect, or confusing behavior needs-triage labels Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior needs-triage
Projects
None yet
Development

No branches or pull requests

1 participant