Add backward compatibility for Conan v1 with revision '0'
Context
In Add backward compatibility for Conan v1 with re... (!218278 - merged) we already tried to add a backward compatibility for Conan v1. However, it led to issue with Conan v2 Conan 2 Error: object of type NoneType has no l... (#587177 - closed). And the changes were reverted in Revert "Merge branch '561028-conan-server-side-... (!222323 - merged).
After the investigation it was revealed that the response with default revision needs to have time field with value.
What does this MR do and why?
Add backward compatibility for Conan v1 with revision '0'
Support Conan v1 clients that use the default revision '0' when recipe revisions are disabled. This ensures the v2 API endpoints can serve packages uploaded via Conan v1.
Changes in details
-
Modify
/v2/conans/:package_name/:package_version/:username/:channel/latestto return default recipe revision"0"when no revisions exist. Example of response:{ "revision": "0", "time": "2026-02-25T09:28:03.044Z" }The default recipe revision
"0"will be used for subsequent API requests:
-
Modify
/v2/conans/:package_name/:package_version/:username/:channel/revisions/:recipe_revision/packages/:package_reference/latestto return default package revision"0"when no revisions exist. Example of response:{ "revision": "0", "time": "2026-02-25T09:28:03.044Z" }
- Modify
/v2/conans/:package_name/:package_version/:username/:channel/revisions/:recipe_revision/searchto return references without revisions. - Change the revision regexp to accept default revision
"0".
References
Conan server side Rest API is no longer compati... (#561028)
Screenshots or screen recordings
No.
How to set up and validate locally
Prerequisites
Enabled the feature flag Feature.enable(:packages_conan_v1_revisions_backward_compatibility)
Conan v1
-
Install Conan v1 client
$ brew install conan@1 -
Make sure that revisions are disabled in the config file
$ vim ~/.conan/conan.conf [general] revisions_enabled = 0 -
Setup GitLab package registry https://docs.gitlab.com/user/packages/conan_1_repository/
$ conan remote add local http://gdk.test:3000/api/v4/projects/<PROJECT_ID>/packages/conan False $ conan user <username> -r local -p <glpat> -
Create and upload a test package
$ mkdir strawberry && cd strawberry $ conan new strawberry/1.0.0 --template=cmake_lib $ conan create . $ conan upload strawberry/1.0.0 -r local --allVerify that the package was uploaded.
-
Clean cache
$ rm -rf ~/.conan/data/strawberry -
Make sure that revisions are enabled in the config file
$ vim ~/.conan/conan.conf [general] revisions_enabled = 1 -
Prepare install
$ cd ../ # go one level back $ vim conanfile.txt # create conanfile.txt with the following content: [requires] strawberry/1.0.0 -
Install package
$ conan install . -r localThe package will be installed using the
v2endpoints.
Conan v2
-
Install Conan v2 client
$ brew install conan@2 -
Setup GitLab package registry
$ conan remote add local http://gdk.test:3000/api/v4/projects/<PROJECT_ID>/packages/conan $ conan remote login local # Enter username and password (glpat) -
Create and upload a test package
$ mkdir test && cd test $ conan new basic -d name=test -d version=1.0.0 $ conan create . $ conan upload test/1.0.0 -r localVerify that the package was uploaded.
-
Clean cache
$ rm -rf ~/.conan2/p -
Prepare install
$ cd ../ # go one level back $ vim conanfile.txt # create conanfile.txt with the following content: [requires] test/1.0.0 -
Install package
$ conan install . -r localThe package should be successfully installed
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #561028

