SanderRonde / VSCode-Gerrit

Gerrit plugin for VSCode
https://marketplace.visualstudio.com/items?itemName=SanderRonde.vscode--gerrit
MIT License
31 stars 17 forks source link

Invalid Response #37

Closed ghost closed 1 year ago

ghost commented 1 year ago

After plugging in the settings information; logs are showing the following:

Invalid response
GET request to "https://git.xxx/a/changes
GET request to "https://git.xxx/a/accounts/self"
GET request to "https://git.xxx/a/changes

Invalid response
HTTPError: Response code 404 (Not Found) 404 [object Object] Not found: xxx

Additionally if I put in the login url rather than the base url of our gerrit server, it prints the html of the login page in the logs. Any ideas here?

SanderRonde commented 1 year ago

The url you should use here is the url of the web version since it uses the HTTP API. Does it work if you try that?

ghost commented 1 year ago

Thank you for responding.

Unfortunately no, I receive the same fetching issues.

SanderRonde commented 1 year ago

What happens if you try it in your browser? So going to https://git.xxx/config/server/version? Does it find the version JSON?

ghost commented 1 year ago

Yes it does, reports 3.7.0

I am using ssh auth, but I added an http password for my account. Could that be causing issues? I noticed that was a previously stated issue.

What is odd is when I follow the link in the logs and use it in the web, it works. It fetches a change from one of our default repos.

SanderRonde commented 1 year ago

This extension only communicates using the HTTP API. This might just mean that your credentials aren't configured correctly. When using it on web it'll just use your browser's authentication token (in the cookies) and so it works. Just ensure your username and password are properly set.

ghost commented 1 year ago

They are, unfortunately.

SanderRonde commented 1 year ago

Can you maybe test the username/password combination in something like Postman? As authentication the API requires the Authorization token to be set to Basic: ${base64encode(username + ':' + password)}. Then try querying something like https://git.xxx/a/changes/ (note the trailing slash that must be there). Then we can rule out whether it's the extension itself or somehow the API connection.

ghost commented 1 year ago

Will get back to you on this.

ghost commented 1 year ago

Maybe I just don't understand how this works, but it is querying /a/changes/xx/detail/ which does not exist. When I go to that page in the browser nothing happens.

HTTPError: Response code 400 (Bad Request) 400 [object Object] Unrecognized value: ignored

Failed to fetch changes with filters for panel "CCed on" Status code = 400 response body = "Unrecognized value: ignored

SanderRonde commented 1 year ago

When you say nothing happens do you mean you get an error 404 or something? A URL of that form should work in the browser just fine and should have you download some JSON (again double check the trailing slash). Every GET request in the logs should also work fine in the browser. If it doesn't work, there's likely something wrong with either the target URL or maybe somehow the REST API was disabled (not sure if that's even possible). So is the following correct?:

Because that would make me lean towards the REST API somehow being disabled. I'm wondering what happens when you visit https://{url}/a/config/server/version.

The error 400 should be fixed in the latest version of the extension (1.2.11). This is related to a filter that was deprecated in Gerrit 3.7.0.

ghost commented 1 year ago

That is correct:

/config/server/version works and returns json /a/config/server/version returns Not Found

SanderRonde commented 1 year ago

Ah so I guess authenticated REST requests are disabled on your server instance then. I'm not entirely sure as to what's causing it since I'm not a gerrit expert but it might be the auth.gitBasicAuthPolicy setting in the config. That says something about the REST API. Could it be that?

ghost commented 1 year ago

Will check with my admin.

ghost commented 1 year ago

Unfortunately due to the plugin we are using, we can't use this as intended.

https://github.com/davido/gerrit-oauth-provider/issues/84

I appreciate your time. I am going to close this out.

SanderRonde commented 1 year ago

Ah that's unfortunate. Glad you were able to figure out what caused the issue though :)