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

HTTPError: Response code 400 (Bad Request) #1146

Closed
muuvmuuv opened this issue Sep 14, 2020 · 4 comments
Closed

HTTPError: Response code 400 (Bad Request) #1146

muuvmuuv opened this issue Sep 14, 2020 · 4 comments

Comments

@muuvmuuv
Copy link

muuvmuuv commented Sep 14, 2020

Description

I am trying to create a merge request which unexpectly fails. The GitLab API is accesible and I double checked by post curl the same request.

const services = new ProjectsBundle({
    host: 'xxxxx',
    token: process.env.GITLAB_ACCESS_TOKEN,
  })
    await services.MergeRequests.create({
      projectId: project,
      sourceBranch: 'develop',
      targetBranch: 'master',
      title: `New release v${currentVersion}`,
      options: {
        description: changelog,
        removeSourceBranch: false,
        labels: 'release',
        showExpanded: true,
      },
    })

Works:

curl --request POST \
  --url 'xxxx/api/v4/projects/xx/merge_requests?access_token=xxxxxx' \
  --header 'content-type: application/json' \
  --data '{
	"id": xx,
	"source_branch": "develop",
	"target_branch": "master",
	"title": "test"
}'
HTTPError: Response code 400 (Bad Request)
    at Request.<anonymous> (///node_modules/@gitbeaker/node/node_modules/got/dist/source/as-promise/index.js:117:42)
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  code: undefined,
  timings: {
    start: 1600090164284,
    socket: 1600090164287,
    lookup: 1600090164290,
    connect: 1600090164293,
    secureConnect: 1600090164300,
    upload: 1600090164300,
    response: 1600090164329,
    end: 1600090164332,
    error: undefined,
    abort: undefined,
    phases: {
      wait: 3,
      dns: 3,
      tcp: 3,
      tls: 7,
      request: 0,
      firstByte: 29,
      download: 3,
      total: 48
    }
  },
  description: undefined
}

Steps to reproduce

Try to run the above JS maybe. Idk but this is a internal GitLab so pretty impossible.

Possible fixes

I would like to dig deeper into this but cannot see any debug or verbose option. Debugging through the sourcecode is impossible due to #1114

@jdalrymple
Copy link
Owner

This will be fixed soon. Im exposing the source in #1112 PR

@keeplz
Copy link

keeplz commented Sep 24, 2020

the same problem, i create an existed branch, but i can't get error message

though in devtools -> network i can find it, but in my code, it is "HTTPError: Response code 400 (Bad Request)"

like above

@stereonom
Copy link

stereonom commented Sep 25, 2020

when I create a MR ike this it works!

return gitlab.MergeRequests.create(
	123,
	'develop',
	'master',
	'super release',
	{
		assigneeIid: 13,
		description: 'Release all the things',
		removeSourceBranch: false,
		labels: 'release'
	}
);

Just don't wrap the options in an object 🤷🏼‍♂️

@jdalrymple
Copy link
Owner

jdalrymple commented Sep 28, 2020

The function doesnt take in an object to begin with, which would be the source of your problem hehe as @stereonom found out ^ there

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

4 participants