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

Gitlab rRest api doesn't accept Project name anymore #969

Open
farabi opened this issue Dec 19, 2019 · 12 comments
Open

Gitlab rRest api doesn't accept Project name anymore #969

farabi opened this issue Dec 19, 2019 · 12 comments

Comments

@farabi
Copy link

farabi commented Dec 19, 2019

Hello.

Danger is trying to call the Gitlab rest api using the project name. while gitlab now only accepts the project ID as you can see in the documentation.

Here is the error, i get.

  • danger-swift ci
    Error: { HTTPError: Not Found
    at fn (/snapshot/danger-js/node_modules/ky/umd.js:242: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.xxxx.com/api/v4/projects/project%2Fname/merge_requests/15/changes',
    status: 404,
    statusText: 'Not Found',
    headers: [Headers] } },
    description: '404 Project Not Found' }
@nesterenkodm
Copy link

same

@orta
Copy link
Member

orta commented Dec 20, 2019

Cool, makes sense - someone want to take a look at a fix?

@farabi
Copy link
Author

farabi commented Dec 21, 2019

@orta
I will !

@farabi
Copy link
Author

farabi commented Jan 2, 2020

@orta
Dumb question, but how to compile a danger-js to use it as a danger-swift dependency ?

@HelloCore
Copy link
Member

@orta
Dumb question, but how to compile a danger-js to use it as a danger-swift dependency ?

I believe it's this command yarn run build; yarn run pkg . --output brew-distribution/danger;.
Copied from

"package": "yarn run build; yarn run pkg . --output brew-distribution/danger; zip -j brew-distribution/danger-macos.zip brew-distribution/danger; shasum -a 256 brew-distribution/danger-macos.zip",

@f-meloni
Copy link
Member

f-meloni commented Jan 2, 2020

that could not work given #958 :(

@HelloCore
Copy link
Member

@farabi The pr #970 got merged to master, you could use yarn run build; yarn run pkg . --output brew-distribution/danger; to build the binary. Also, don’t forget to run yarn install

@farabi
Copy link
Author

farabi commented Jan 20, 2020

Hello @orta @chebur

Actually gitlab does accept project name, the issue is coming from apache configuration where local gitlab is hosted.
Unless AllowEncodedSlashes is set to on. rest calls with encoded slashes will not work.
Like in my case : "https://gitlab.xxxx.com/api/v4/projects/project%2Fname/merge_requests/15/changes"

The solution i did in my fork is to add a env variable "DANGER_GITLAB_PROJECT_ID". and if it's not defined then we use the project name.

Lot of tools are using the same approach with the project id.

If its ok for you, i add a pull request about that. otherwise , we close the ticket and i will keep using my fork. farabi/tap/danger-swift

@orta
Copy link
Member

orta commented Jan 20, 2020

Seems like a good PR to me 👍

@lazy-var
Copy link

In addition to @farabi apache configuration suggestion, I needed NoDecode and nocanon parameters:

<VirtualHost *:port>
  AllowEncodedSlashes NoDecode

  <Location /example/>
    ProxyPass http://anotherserver:8080/example nocanon
  </Location>
</VirtualHost>

as explained here: https://stackoverflow.com/a/9933890

@AnthonyMastrean
Copy link

AnthonyMastrean commented Apr 2, 2020

Edit: Turns out I was observing a different API URL construction issue... #1028

@ivankatliarchuk
Copy link
Contributor

The intention is right to support project number ID, but Gitlab does support The ID or [URL-encoded path of the project](https://docs.gitlab.com/ee/api/index.html#namespaced-path-encoding). so both are working.

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

8 participants