I've spent a good amount of time recently trying to debug issues in goreleaser which uses go-gitlab. What I've found is that error messages go-gitlab returns include URLs which are not the URL that is being invoked. The URL is being unescaped when it shouldn't in go-gitlab's error handling code. This makes debugging difficult as it's sent me down the wrong path multiple times because the calls aren't valid.
Here's a test I'm using. The referenced repos are private and not available to anyone outside our organization. The fileName is an invalid path.
The actual URL invoked is https://gitlab.com/api/v4/projects/shipium-corp%2Fengineering%2Fhomebrew-shipium/repository/files/Formula%2Finvalid%2Er. The issue is the URL unescaping performed by the error handling code when building the error message. The repository name and the file name must be URL encoded to be valid when invoking gitlab's REST API.
There is still a remaining issue in that the query params are not appended. I haven't tackled that yet but I assume the solution is on the same path as what I included above.
I've spent a good amount of time recently trying to debug issues in goreleaser which uses go-gitlab. What I've found is that error messages go-gitlab returns include URLs which are not the URL that is being invoked. The URL is being unescaped when it shouldn't in go-gitlab's error handling code. This makes debugging difficult as it's sent me down the wrong path multiple times because the calls aren't valid.
Here's a test I'm using. The referenced repos are private and not available to anyone outside our organization. The fileName is an invalid path.
The error that is printed is:
The actual URL invoked is
https://gitlab.com/api/v4/projects/shipium-corp%2Fengineering%2Fhomebrew-shipium/repository/files/Formula%2Finvalid%2Er
. The issue is the URL unescaping performed by the error handling code when building the error message. The repository name and the file name must be URL encoded to be valid when invoking gitlab's REST API.The problematic line is the following at https://github.com/xanzy/go-gitlab/blob/8f2dbc2fcc34c8ea666b87b34899a9c84b539453/gitlab.go#L953.
I believe this should be the following instead:
With this update, the error include the appropriate URL in the error message.
There is still a remaining issue in that the query params are not appended. I haven't tackled that yet but I assume the solution is on the same path as what I included above.