[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
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

Error in request to create release #192

Open
renatocassino opened this issue Dec 17, 2020 · 10 comments
Open

Error in request to create release #192

renatocassino opened this issue Dec 17, 2020 · 10 comments

Comments

@renatocassino
Copy link
renatocassino commented Dec 17, 2020

Hello everyone

I'm receiving an error when I run the semantic release in last step. The code can create the tag, but after this, there is a request to /release that I'm receiving a 400 error code

[3:27:32 PM] [semantic-release] [@semantic-release/changelog] › ℹ  Create /tmp/build/group/project-name/CHANGELOG.md
[3:27:32 PM] [semantic-release] › ✔  Completed step "prepare" of plugin "@semantic-release/changelog"
[3:27:33 PM] [semantic-release] › ✔  Created tag v1.3.1
[3:27:33 PM] [semantic-release] › ℹ  Start step "publish" of plugin "@semantic-release/gitlab"
[3:27:33 PM] [semantic-release] › ✖  Failed step "publish" of plugin "@semantic-release/gitlab"
[3:27:33 PM] [semantic-release] › ✖  An error occurred while running semantic-release: HTTPError: Response code 400 (Bad Request)
    at EventEmitter.<anonymous> (/usr/local/lib/node_modules/@semantic-release/gitlab/node_modules/got/dist/source/as-promise.js:118:31)
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  pluginName: '@semantic-release/gitlab'
}
HTTPError: Response code 400 (Bad Request)
    at EventEmitter.<anonymous> (/usr/local/lib/node_modules/@semantic-release/gitlab/node_modules/got/dist/source/as-promise.js:118:31)
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  pluginName: '@semantic-release/gitlab'
}

I start to investigate the problem in code and I put a debug with error message in API:

2020-12-17T16:59:53.675Z semantic-release:gitlab error in request: Response code 400 (Bad Request)
2020-12-17T16:59:53.675Z semantic-release:gitlab {"error":"name is missing"}

Is required a field called name in json data send with GOT.

gitlab/lib/publish.js

Lines 73 to 87 in f8957c3

json: {
/* eslint-disable camelcase */
tag_name: gitTag,
description: notes && notes.trim() ? notes : gitTag,
assets: {
links: assetsList.map(({label, alt, url}) => {
return {
name: label || alt,
url: urlJoin(gitlabUrl, repoId, url),
};
}),
},
/* eslint-enable camelcase */
},
});

There is no field called name in this file

I changed and add a name with any value and I received a 201 code.

Is this a bug, different version or I made something wrong?

Thanks for this

@nfriend
Copy link
Contributor
nfriend commented Dec 18, 2020

Thanks for this detailed report @tacnoman!

It's interesting, because the name field is optional in GitLab's Release API: https://docs.gitlab.com/ee/api/releases/#create-a-release 🤔

Is it possible that one of the asset's names is coming through as null/undefined? The name property is required on each asset link object.

In the code you linked to, I see the asset name is being populated like this:

name: label || alt, 

Perhaps these are both falsy for some reason 🤔

Assuming you are including assets with your release, could you try adding a label in your configuration file as described here?

Even if this does work, this sounds like a bug to me.

nfriend pushed a commit to nfriend/gitlab that referenced this issue Dec 18, 2020
@nfriend
Copy link
Contributor
nfriend commented Dec 18, 2020

@tacnoman I put together a quick branch in my fork that logs the JSON being sent to the GitLab API. (Here's the commit.)

If you replace your this line in your package.json:

"@semantic-release/gitlab": "^6.0.8"

with this:

"@semantic-release/gitlab": "nfriend/gitlab#debugging-issues-192"

and rerun npm install and your deploy, you should see the JSON printed in your logs. If this works for you, would you mind posting the JSON here?

(Disclaimer: I haven't tested this, so it's possible it might not work 😅)

@ginozhan
Copy link
ginozhan commented Dec 21, 2020

I got the same problem. And I try to set name in publish.js and it works at localhost.

@ldc2726
Copy link
ldc2726 commented May 21, 2021

I got the same problem. code 400

@ldc2726
Copy link
ldc2726 commented May 21, 2021

image
I tried to add the attribute "name" to the body, and the result was successful. I hope to optimize it as soon as possible, I think it may be a bug, thank you

@linxux
Copy link
linxux commented May 25, 2021

Meet the same issue.
And the Gitlab version is: 13.6.1

@ldc2726
Copy link
ldc2726 commented May 26, 2021

It should be similar to my question, and I have submitted a PR and it is waiting for review
#239

@linxux
Copy link
linxux commented Jun 11, 2021

Any update?

@renatocassino
Copy link
Author

I solved creating a new file with name and in pipeline after install I replace the file

Release:
    ......
    script:
        - cp ./publish.js /usr/local/lib/node_modules/@semantic-release/gitlab/lib/publish.js
        - DEBUG=semantic-release:gitlab npx semantic-release

I copied the publish.js to my project folder and added a parameter name, like this:

//...... line 75
     json: {
        /* eslint-disable camelcase */
        tag_name: gitTag,
        name: `Bump tag: ${gitTag}`, // Added this line
        description: notes && notes.trim() ? notes : gitTag,
        assets: {
// ......

@fgreinacher
Copy link
Contributor

@renatocassino @merlosy I am successfully using this plugin with our self-hosted GitLab instance. Can you share more details of your setup to help understand what could be the reason for your issues?

Possibly interesting information:

  • Your semantic-release config
  • Version and flavor of your GitLab instance
  • Your build/release pipeline

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

6 participants