Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not create release if patterns matches multiple files with the same name. #265

Open
EvanCarroll opened this issue Jul 27, 2021 · 2 comments

Comments

@EvanCarroll
Copy link

EvanCarroll commented Jul 27, 2021

I'm getting this error,

[12:29:11 PM] [semantic-release] [@semantic-release/gitlab] › ✖  An error occurred while making a request to the GitLab release API:
HTTPError: Response code 400 (Bad Request)
    at EventEmitter.<anonymous> (/home/ecarroll/n/lib/node_modules/@semantic-release/gitlab/node_modules/got/dist/source/as-promise.js:118:31)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
[12:29:11 PM] [semantic-release] › ✖  Failed step "publish" of plugin "@semantic-release/gitlab"
[12:29:11 PM] [semantic-release] › ✖  An error occurred while running semantic-release: HTTPError: Response code 400 (Bad Request)
    at EventEmitter.<anonymous> (/home/ecarroll/n/lib/node_modules/@semantic-release/gitlab/node_modules/got/dist/source/as-promise.js:118:31)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5) {
  pluginName: '@semantic-release/gitlab'
}
HTTPError: Response code 400 (Bad Request)
    at EventEmitter.<anonymous> (/home/ecarroll/n/lib/node_modules/@semantic-release/gitlab/node_modules/got/dist/source/as-promise.js:118:31)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5) {
  pluginName: '@semantic-release/gitlab'
}%

This error comes right after a release PUSH. Currently it's silently failing failing I opened this ticket to fix the silent failing: #264

{
  responseType: 'text',
  body: '{"message":"Validation failed: Links have duplicate values (acme-angular-validators.js) for #\\u003cRelease:0x00007f0702a43908\\u003e scope"}'
}

You can see here that the problem is that GitLab errors with 400 (Bad Request) because it's upload multiple files (in different directories) to the release API.

dist/acme/angular-validators/fesm2015/acme-angular-validators.js
dist/acme/angular-validators/esm2015/acme-angular-validators.js

I believe the solution for this should be to add the paths to the file's basename, relatively to the pkgRoot.

@EvanCarroll EvanCarroll changed the title Can not create release if ** matches multiple files with the same name. Can not create release if patterns matches multiple files with the same name. Jul 27, 2021
@EvanCarroll
Copy link
Author

EvanCarroll commented Jul 28, 2021

This is the same issue as #158

Note:

  • It's not solved.
  • the workaround "Found another even simpler workaround: remove the label property for any patterns that match more than one file. In this case, this module will fall back to creating each item with its label set to the file's name." doesn't work if the file name is not unique.

In order to fix this, I've patched it such that the label of the file in the release isn't just the basename, but the relative path to the pkgRoot.

EvanCarroll added a commit to EvanCarroll/gitlab that referenced this issue Jul 29, 2021
Previously GitLab lables were just the basename for files uploaded as
part of the release. This is problematic because GitLab doesn't allow
conflicting labels -- a condition that could be caused by uploading a
release with two files by the same name in different directories. This
would generate a 409 Conflict error.

This changes the labels for files uploaded as part of a release to the
name relative to pkgRoot, or the package.

A project may look like this

  pkg
  pkg \ foo \ baz
  pkg \ bar \ baz

This would previously result in two conflicting labels of 'baz'. Now you
would have {"foo/baz", "bar/baz"} with no conflict.

GitHub issues: semantic-release#265, semantic-release#158
EvanCarroll added a commit to EvanCarroll/gitlab that referenced this issue Sep 24, 2021
Previously GitLab lables were just the basename for files uploaded as
part of the release. This is problematic because GitLab doesn't allow
conflicting labels -- a condition that could be caused by uploading a
release with two files by the same name in different directories. This
would generate a 409 Conflict error.

This changes the labels for files uploaded as part of a release to the
name relative to pkgRoot, or the package.

A project may look like this

  pkg
  pkg \ foo \ baz
  pkg \ bar \ baz

This would previously result in two conflicting labels of 'baz'. Now you
would have {"foo/baz", "bar/baz"} with no conflict.

GitHub issues: semantic-release#265, semantic-release#158
@dimooze
Copy link

dimooze commented Jan 11, 2022

Hi ! Thanks for this lib :)

I'am also experiencing the same issue as @EvanCarroll. I have a bunch of index.js / index.d.ts / index.js.map in my build and so i have duplicated names in my publish with this kind of json to post:

{
  "tag_name": "v2.0.0",
  "description": "...",
  "assets": {
    "links": [
      {
        "name": "index.js.map",
        "url": "https://gitlab.com/myproject/uploads/d5b00462bb05eeb33004ac2898040868/index.js.map"
      },
      {
        "name": "index.d.ts",
        "url": "https://gitlab.com/myproject/uploads/a88f950454e5b647a62be66dcd919140/index.d.ts"
      },
      {
        "name": "index.js.map",
        "url": "https://gitlab.com/myproject/uploads/edd80896ff97a2cf4233cd9ef47a7983/index.js.map"
      },
      ....
    ]
  }

Resulting in an error Validation failed: Links have duplicate values.

I've seen the PR from @EvanCarroll 267 that could manage to have unique label / name.
Is is possible to review his PR or if you have any other suggestions I could work on a PR too !

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants