Skip to content
GitLab
Next
    • Why GitLab
    • Pricing
    • Contact Sales
    • Explore
  • Why GitLab
  • Pricing
  • Contact Sales
  • Explore
  • Sign in
  • Get free trial
  • GitLab.orgGitLab.org
  • container-registry
  • Issues
  • #341

Empty Tag returned by 'v2/<REPO>/tags/list' when S3 returns 'Contents' as well as 'CommonPrefixes' on ListObjects

Typically S3 returns just CommonPrefixes when querying a directory. However, in some cases it may return the _tags directory passed as prefix as Content as well. The S3 backend will return both files and directories, so we strip the full tags directory path and return an empty string to the caller.

This in turn will cause the UI to error out when attempting to view tags because the tag name is empty:

ActionController::UrlGenerationError (No route matches {:action=>"destroy", :controller=>"projects/registry/tags", :id=>"", :namespace_id=>#<Group id:740 @dcube_core>, :project_id=>#<Project id:5296 dcube_core/python_dienst_template>, :repository_id=>#<ContainerRepository id: 1, project_id: 5296, name: "", created_at: "2019-02-27 09:06:06", updated_at: "2019-02-27 09:06:06">} missing required keys: [:id]):

Example output from S3:

{
  "Contents": [
    {
      "Key": "docker/registry/v2/repositories/group/project/production/_manifests/tags/",
      "LastModified": "2021-03-03T09:04:14+00:00",
      "ETag": "\"123abc\"",
      "Size": 0,
      "StorageClass": "STANDARD",
      "Owner": {
        "DisplayName": "abc123",
        "ID": "12345"
      }
    }
  ],
  "CommonPrefixes": [
    {
      "Prefix": "docker/registry/v2/repositories/group/project/production/_manifests/tags/tag1/"
    },
    {
      "Prefix": "docker/registry/v2/repositories/group/project/production/_manifests/tags/tag2/"
    },
    {
      "Prefix": "docker/registry/v2/repositories/group/project/production/_manifests/tags/tag3/"
    }
  ]
}

/cc @hswimelar

Edited Apr 10, 2021 by Will Chandler
Assignee
Assign to
Time tracking