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

[BUG] Not Found error when running danger with GitLab CE without MR approvals API #1106

Open
pgrosslicht opened this issue Feb 4, 2021 · 11 comments
Labels

Comments

@pgrosslicht
Copy link

Describe the bug
Our builds have started failing with the following error since using v10.6.2:

Error:  { HTTPError: Not Found
    at fn (/root/.npm/_npx/15/lib/node_modules/danger/node_modules/ky/umd.js:266:12)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  name: 'HTTPError',
  response:
   Response {
     size: 0,
     timeout: 0,
     [Symbol(Body internals)]: { body: [PassThrough], disturbed: true, error: null },
     [Symbol(Response internals)]:
      { url:
         'https://$GITLAB/api/v4/projects/$PROJECT/merge_requests/579/approvals',
        status: 404,
        statusText: 'Not Found',
        headers: [Headers],
        counter: 0 } },
  description: '404 Not Found' }

To Reproduce
Steps to reproduce the behavior:

  1. Execute danger with selfhosted GitLab CE without MR approvals API (for example 12.8.6)
  2. Above error will occur

Expected behavior

Danger shouldn't fail, either by allowing the user to configure skipping using this approvals API or ignoring the error and carrying on without these API results. Or maybe there is a more elegant solution that I am not thinking of at the moment.

Screenshots
If applicable, add screenshots to help explain your problem.

Your Environment

software version
danger.js 10.6.2
node 10.23.2
Operating System swift:5.2 docker image (Ubuntu 18.04)
Gitlab GitLab Community Edition 12.8.6

Additional context
Also according to https://docs.gitlab.com/ee/api/merge_request_approvals.html#merge-request-level-mr-approvals this API will be moved to GitLab Premium only in 13.9, so expecting the API to exist/work might become problematic then as well.
Probably introduced in #1098.

@pgrosslicht pgrosslicht added the bug label Feb 4, 2021
@orta
Copy link
Member

orta commented Feb 5, 2021

Ah yeah, this makes sense, I guess that call will need to be failable /cc @kelvin-lemon

@iShawnWang
Copy link
Contributor

Any update here ?
Facing the same problem in GitLab Community Edition 13.0.10

@orta
Copy link
Member

orta commented Mar 29, 2021

You're welcome to take a look at fixing it 👍🏻

@mangei
Copy link

mangei commented Jun 7, 2021

The bug was introduced with #1098

Workaround: Use a version lower than 10.6.2 e.g. 10.5.4

@cangSDARM
Copy link

cangSDARM commented Nov 17, 2021

Is resolving yet? Currently in gitlab(11.9.9) and danger(10.7.1) this issue still exists.
Danger try to fetch "api/v4/projects/person%2Fproject/merge_requests/1/approvals"

@simonfelding
Copy link

wow this sucks. spent so much time trying to figure out wth was going on here. please fix, or just say gitlab is unsupported.

@orta
Copy link
Member

orta commented Jan 29, 2024

You're welcome to give it a shot

@simonfelding
Copy link

Hi @orta, I'd love to.

I can tell you exactly what the problem is. #1098 introduced the use of an enterprise edition API, which breaks danger for all community edition gitlab servers. The breaking change is that danger tries to access an url like https://git.company.com/api/v4/projects/$GROUP%2F$PROJECT/merge_requests/5 instead of https://git.company.com/api/v4/projects/$PROJECT_ID/merge_requests/5.

I think gitlab prefers the project id is used instead of the project group+name, but the enterprise edition supports group+name where community edition doesn't. Super annoying.

The Ruby version has the same issue by the way. Do you think it's lib/danger/ci_source/gitlab_ci.rb or lib/danger/request_sources/gitlab.rb in the ruby version?

I think it's just incorrect environment variables that are in use. I'm no typescript expert, but I should be able to fix it. This might just fix it too: #994

@simonfelding
Copy link

simonfelding commented Jan 29, 2024

I investigated a bit and it appears that the reason the bug was introduced to begin with is that gitlab.com doesn't use project IDs.

Is it unacceptable to just use *_PROJECT_PATH variables when it's on gitlab.com, and *_PROJECT_ID when it's not?

Nevermind, it does work just fine, I just used the wrong ID.
Proof:
https://gitlab.com/api/v4/projects/1342007/merge_requests is equal to https://gitlab.com/api/v4/projects/k0nserv%2Fdanger-test/merge_requests, but the PROJECT_PATH version of the URL is broken on self-hosted gitlab CE.

@buffcode
Copy link
Contributor

What isn't working? We are using DangerJS successfully on a GitLab CE instance since #1406 has been merged on the latest released version 11.3.1.

@simonfelding
Copy link

I'm getting a 404 with the project name in the url, but 200 with the project id in the url, so maybe this isn't actually the right issue for it. I'm working on a patch

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

No branches or pull requests

7 participants