From 42a88927e591e622cea9f82e238e14670b2ae8c5 Mon Sep 17 00:00:00 2001 From: Keshav Priyadarshi Date: Wed, 6 Sep 2023 16:26:02 +0530 Subject: [PATCH] Handle invalid constraints sequence exception - issue https://github.com/nexB/univers/issues/118 Signed-off-by: Keshav Priyadarshi --- packagedb/api.py | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/packagedb/api.py b/packagedb/api.py index 77bc9d94..6a5aec96 100644 --- a/packagedb/api.py +++ b/packagedb/api.py @@ -749,18 +749,23 @@ def resolve_versions(parsed_purl, vers): all_versions = get_all_versions(parsed_purl) or [] - return [ - str( - PackageURL( - type=parsed_purl.type, - namespace=parsed_purl.namespace, - name=parsed_purl.name, - version=version.string, - ) - ) - for version in all_versions - if version in version_range - ] + result = [] + + for version in all_versions: + try: + if version in version_range: + package_url = PackageURL( + type=parsed_purl.type, + namespace=parsed_purl.namespace, + name=parsed_purl.name, + version=version.string, + ) + result.append(str(package_url)) + except Exception: + # Skip the ``Invalid constraints sequence`` Exception + pass + + return result def get_all_versions(purl: PackageURL): """