Fix dependency graph error for invalid version constraints
When a dependency has an invalid version constraint like '>=' (without a version number), the resolver now treats it as a wildcard and returns the latest available version instead of failing with 'Dependency not found'. This handles malformed metadata that may have been stored from PyPI packages.
This commit is contained in:
@@ -358,7 +358,15 @@ def _resolve_version_constraint(
|
||||
try:
|
||||
specifier = SpecifierSet(constraint)
|
||||
except InvalidSpecifier:
|
||||
# Invalid constraint, try as exact version
|
||||
# Invalid constraint (e.g., ">=" without version) - treat as wildcard
|
||||
# This can happen with malformed metadata from PyPI packages
|
||||
latest = db.query(PackageVersion).filter(
|
||||
PackageVersion.package_id == package.id,
|
||||
).order_by(PackageVersion.created_at.desc()).first()
|
||||
if latest:
|
||||
artifact = db.query(Artifact).filter(Artifact.id == latest.artifact_id).first()
|
||||
if artifact:
|
||||
return (artifact.id, latest.version, artifact.size)
|
||||
return None
|
||||
|
||||
# Get all versions for this package
|
||||
|
||||
Reference in New Issue
Block a user