Conan installs are downloading the wrong package
Summary
When a user is working with a Conan recipe that has more than one package, running conan install ...
will sometimes result in the incorrect package being downloaded.
Steps to reproduce
(How one can reproduce the issue - this is very important)
Example Project
(If possible, please create an example project here on GitLab.com that exhibits the problematic behavior, and link to it here in the bug report)
(If you are using an older version of GitLab, this will also determine whether the bug is fixed in a more recent version)
What is the current bug behavior?
When a Conan recipe has more than one package, the first uploaded package is always returned when running conan install
regardless of options specified
What is the expected correct behavior?
When a Conan recipe has more than one package, the correct package is downloaded based on the specified options when running conan install
Relevant logs and/or screenshots
$ conan create -s build_type=Release . Hello/0.1@sabrams+my-package-registry/stable
$ conan upload Hello/0.1@sabrams+my-package-registry/stable -r=gitlab --all
$ conan create -s build_type=Debug . Hello/0.1@sabrams+my-package-registry/stable
$ conan upload Hello/0.1@sabrams+my-package-registry/stable -r=gitlab --all
$ conan remove Hello/0.1@sabrams+my-package-registry/stable
$ conan install Hello/0.1@sabrams+my-package-registry/stable -r=gitlab -s build_type=Release
// downloads the Release package
$ conan install Hello/0.1@sabrams+my-package-registry/stable -r=gitlab -s build_type=Debug
// downloads the Release package
Output of checks
This bug happens on GitLab.com
Possible fixes
A package is downloaded using a url like https://example.gitlab.com/api/v4/packages/conan/v1/files/Hello/0.1/example+conan-package/stable/0/package/9iwee55j72c4ciw96abaa83716fff54274afenc2/0/conan_package.tgz
The has is used to identify which package file is downloaded when there are more than one for the recipe Hello/0.1@example+conan-package/stable
. Currently, the PackageFileFinder finds the incoming file by name (in this case conan_package.tgz
) and by conan_file_type
, which is a recipe file or package file (export or package in conan lingo). In this example, we would filter by package_type
, however, if more than one conan_package.tgz
exists, we need to use the incoming conan_package_reference
(conan's package id) to know which file is being requested.
We need to add a filter to the package finder for conan_package_reference
and pass the incoming param into the finder from the API endpoint.
It's possible there's more needed to fix this, but this is the first change that needs to be made and tested.
While working though this, it should be verified that the conan_package_reference
value is being utilized properly in the other endpoints as well.