Add backward compatibility for Conan v1 with revision '0'

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/latest to return default recipe revision "0" when no revisions exist.

    {
      "revision": "0",
      "time": null
    }

    The default recipe revision "0" will be used for subsequent API requests:

Screenshot_2026-01-12_at_13.38.19

  • Modify /v2/conans/:package_name/:package_version/:username/:channel/revisions/:recipe_revision/packages/:package_reference/latest to return default package revision "0" when no revisions exist.

    {
      "revision": "0",
      "time": null
    }

Screenshot_2026-01-12_at_13.52.19

  • Modify /v2/conans/:package_name/:package_version/:username/:channel/revisions/:recipe_revision/search to 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

  1. Install Conan v1 client

    $ brew install conan@1
  2. Make sure that revisions are disabled in the config file

    $ vim ~/.conan/conan.conf
    
    [general]
    revisions_enabled = 0
  3. 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>
  4. 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 --all

    Verify that the package was uploaded.

  5. Clean cache

    $ rm -rf ~/.conan/data/strawberry
  6. Make sure that revisions are enabled in the config file

    $ vim ~/.conan/conan.conf
    
    [general]
    revisions_enabled = 1
  7. Prepare install

    $ cd ../ # go one level back
    $ vim conanfile.txt # create conanfile.txt with the following content:
    [requires]
    strawberry/1.0.0
  8. Install package

    $ conan install . -r local

    The package will be installed using the v2 endpoints.

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

Edited by Dzmitry (Dima) Meshcharakou

Merge request reports

Loading