reviewdog / reviewdog

🐶 Automated code review tool integrated with any code analysis tools regardless of programming language

Home Page:https://medium.com/@haya14busa/reviewdog-a-code-review-dog-who-keeps-your-codebase-healthy-d957c471938b#.8xctbaw5u

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gitlab-mr-discussion fail to get diff

123Haynes opened this issue · comments

Hello,

I'm currently trying to get reviewdog to work with my local Gitlab instance.
However I get the following error:

reviewdog: fail to get diff: GET https://my.local.instance/api/v4/projects/haynes/webgoat/merge_requests/3: 404 {message: 404 Project Not Found}

This seems to be because reviewdos does not urlencode the namespace.

When I change the URL like this:
https://my.local.instance/api/v4/projects/haynes%2Fwebgoat/merge_requests/3
So when I change the / in the project path to %2F (an URL encoded /) I get the expected result

See also:
https://docs.gitlab.com/ee/api/rest/#namespaced-path-encoding

Any help with this would be greatly appreciated.

Tested with reviewdog version: 0.17.1
Gitlab Version: 16.8.1

edit:

After investigating a bit more I think this line is what's causing the issue:
https://github.com/reviewdog/reviewdog/blob/master/service/gitlab/gitlab_mr_discussion.go#L55
It probably should be projects: url.QueryEscape(owner + "/" + repo),

I didn't verify that assumption yet though.

I've created a draft PR to address this. Still need to build it locally and test it against my gitlab instance. It's been quite a while since I worked with go so I need to figure out how to release binaries again.

hmm closed the PR again after testing the changes locally. I'm not sure what's happening here.
The go-gitlab module already applies a method to urlescape the path. I don't know why that doesn't seem to trigger in my case.

oof.... i'm stupid... The error was that the user with the token was not added to the project.
The error message is still confusing because it does not fully reflect the URL that is being called in the background, but reviewdog works fine if the requirements are met.