Skip to content

canonical_convert still assumes it will find something, resulting in AttributeError: 'NoneType' object has no attribute 'group' #1639

Closed
@wyattearp

Description

@wyattearp

I was testing out the latest code and ran into the same issue on the 3.0 release as the current head ca1de05. The code assumes that the regex match will return something correctly, which isn't always the case.

Line will still fail like issue #1300 and #1519 are intended to fix:

parsed_version = parse_version(pv.group(0))

I patched it (poorly) in my code to do the following:

try:
    parsed_version = parse_version(pv.group(0))
except AttributeError:
    parsed_version = parse_version("99.99.99")
    self.logger.warn(
        f"error parsing {product_info.vendor}.{product_info.product} v{product_info.version} - manual inspection required"
    )

Likely there should be a configuration option on what happens if there's an error matching regular expressions, something like a "fail safe" and set the version to lowest possible value, which likely will create a lot of false positives, or "fail scary" which just drops a warning and tells the user to do manual inspection like I have above.

I'm happy to create a PR, but I'm not sure what the best approach should really be for this - thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions