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

package version parameter does not work for extended version numbers #161

Open
internetb opened this issue Oct 6, 2023 · 1 comment
Open
Labels
bug Something isn't working

Comments

@internetb
Copy link

Describe the bug

`% python3 pcs_images_packages_read.py --package_id curl:8 --version_comparison lt

Testing Compute API Access ... done.

Searching for Package: (curl) Version: (8) Exact Match Name: (False) Version Comparison Operator: (lt)

Getting CI Images ...
Traceback (most recent call last):
File "/Users/username/git/prismacloud-api-python/scripts/pcs_images_packages_read.py", line 255, in
ci_images_with_package = parse_images(ci_images, search_all_packages, args.package_type, args.exact_match_name, search_package_name, args.version_comparison, search_package_version)
File "/Users/username/git/prismacloud-api-python/scripts/pcs_images_packages_read.py", line 171, in parse_images
if package_version_matches(search_comparison_operator, search_version, package['version']):
File "/Users/username/git/prismacloud-api-python/scripts/pcs_images_packages_read.py", line 82, in package_version_matches
package_semver = version.parse(package_version)
File "/Users/username/Library/Python/3.9/lib/python/site-packages/packaging/version.py", line 52, in parse
return Version(version)
File "/Users/username/Library/Python/3.9/lib/python/site-packages/packaging/version.py", line 197, in init
raise InvalidVersion(f"Invalid version: '{version}'")
packaging.version.InvalidVersion: Invalid version: '7.61.1-25.el8_7.1'
`

It seems like using the :version capability breaks if you have any versions of the package with extended version numbers. I'm not certain of the breakpoint, but it seems like either the dash (-), or the underscore (_) might be the cause.

Expected behavior

Correctly parses the version number and returns results

Current behavior

Script crashes with above InvalidVersion error.

Possible solution

Improve parsing of versions.

Steps to reproduce

Provided above, assuming you have extended versions of the app in question.

Your Environment

  • git commit used (latest): 30ac4b6
  • Python Version used: Python 3.9.6
  • Operating System and version (desktop or mobile): MacOS 13.6 (22G120)
@internetb internetb added the bug Something isn't working label Oct 6, 2023
@welcome-to-palo-alto-networks
Copy link

🎉 Thanks for opening your first issue here! Welcome to the community!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant