gitlab icon indicating copy to clipboard operation
gitlab copied to clipboard

Multiple assets without labels/filepaths causes collisions (HTTP Error 400, "Links have duplicate values")

Open JoshuaLeivers opened this issue 1 year ago • 2 comments

When providing an asset without a label or filepath specified, it seemingly always uses the name "release" with the relative URL of "undefined". This means that if multiple assets do not have a label/filepath, they will collide, and the GitLab API will return a HTTP 400 (Bad Request) with the following error:

HTTPError: Response code 400 (Validation failed: Links have duplicate values (release) for #<Release:0x**************> scope, Links have duplicate values (https://gitlab.***/api/v4/projects/NAMESPACE%2FPROJECT/packages/generic/release/VERSION/undefined) for #<Release:**************> scope)

The body of the HTTP request involved looks something like this:

{
  "tag_name": "VERSION",
  "description": "DESCRIPTION",
  "assets": {
    "links": [
      {
        "name": "release",
        "url": "https://gitlab.***/api/v4/projects/NAMESPACE%2FPROJECT/packages/generic/release/VERSION/undefined",
        "link_type":"package"
      },
      {
        "name": "metadata.json",
        "url": "https://gitlab.***/api/v4/projects/NAMESPACE%2FPROJECT/packages/generic/release/VERSION/metadata.json",
        "link_type": "package",
        "filepath":"/modules/PROJECT/metadata.json"
      },
      {
        "name": "source.json",
        "url":"https://gitlab.***/api/v4/projects/NAMESPACE%2FPROJECT/packages/generic/release/VERSION/source.json",
        "link_type": "package",
        "filepath": "/modules/PROJECT/VERSION/source.json"
      },
      {
        "name": "PROJECT-VERSION.tar.gz",
        "url": "https://gitlab.***/api/v4/projects/NAMESPACE%2FPROJECT/packages/generic/release/VERSION/PROJECT-VERSION.tar.gz",
        "link_type": "package",
        "filepath":"/src.tar.gz"
      },
      {
        "name": "MODULE.bazel",
        "url": "https://gitlab.***/api/v4/projects/NAMESPACE%2FPROJECT/packages/generic/release/VERSION/MODULE.bazel",
        "link_type": "package",
        "filepath":"/modules/PROJECT/VERSION/MODULE.bazel"
      },
      {
        "name": "release",
        "url": "https://gitlab.***/api/v4/projects/NAMESPACE%2FPROJECT/packages/generic/release/VERSION/undefined",
        "link_type": "package"
      }
    ]
  }
}

Most of the above are unrelated, but the two assets with the name "release" are of note. The relevant config is specified here - note the icon.svg and dist/**/* assets which do not have labels nor filepaths and are the only assets not accounted for correctly in the above error.

I am unsure if just specifying a label or a filepath will fix this - as a temporary workaround, we have specified both in later versions of the config. However, there does appear to be an issue here.

JoshuaLeivers avatar May 21 '24 11:05 JoshuaLeivers

I think this is the same error as https://github.com/semantic-release/gitlab/issues/265, correct?

fgreinacher avatar May 21 '24 14:05 fgreinacher

I think this is the same error as #265, correct?

It may be the same root cause, yes.

JoshuaLeivers avatar May 21 '24 16:05 JoshuaLeivers

Thanks for the feedback, I'll close this one then. Please follow along progress over there.

fgreinacher avatar May 24 '24 06:05 fgreinacher