Dependency#find_package_id and Dependency.update_missing_package_ids resolve dependency package records by ecosystem only:
Dependency#find_package_id uses Registry.find_by_ecosystem(ecosystem)
Dependency.update_missing_package_ids picks the first registry for the dependency ecosystem, ordered by packages_count
This can link dependencies to the wrong package record when an ecosystem has multiple registries. Maven is the clearest case because the seed data includes several Maven registries and package names can overlap between registries.
Example failure mode:
- A version from
maven.google.com has a dependency on com.example:library.
Dependency.update_missing_package_ids picks repo1.maven.org because it is the first/largest Maven registry.
- If
repo1.maven.org also has com.example:library, the dependency gets package_id for the wrong registry.
- Once
package_id is set, later backfills skip it because the dependency is no longer without_package.
The dependency already has enough context to resolve this correctly through its owning version/package:
dependency.version.package.registry
Using that registry would keep dependency links scoped to the registry where the dependent version came from.
Relevant code:
- app/models/dependency.rb#find_package_id
- app/models/dependency.rb#update_missing_package_ids
Dependency#find_package_idandDependency.update_missing_package_idsresolve dependency package records by ecosystem only:Dependency#find_package_idusesRegistry.find_by_ecosystem(ecosystem)Dependency.update_missing_package_idspicks the first registry for the dependency ecosystem, ordered bypackages_countThis can link dependencies to the wrong package record when an ecosystem has multiple registries. Maven is the clearest case because the seed data includes several Maven registries and package names can overlap between registries.
Example failure mode:
maven.google.comhas a dependency oncom.example:library.Dependency.update_missing_package_idspicksrepo1.maven.orgbecause it is the first/largest Maven registry.repo1.maven.orgalso hascom.example:library, the dependency getspackage_idfor the wrong registry.package_idis set, later backfills skip it because the dependency is no longerwithout_package.The dependency already has enough context to resolve this correctly through its owning version/package:
Using that registry would keep dependency links scoped to the registry where the dependent version came from.
Relevant code: