harrisoncramer/gitlab.nvim

Unable to resolve discussions or add comments

aravind2612krishna opened this issue · 4 comments

Bug Description

When trying to resolve discussions or add comments, I get the following message:
gitlab.nvim: Could not resolve discussion: PUT https://gitlab.com//api/v4/projects/38490095/merge_requests/4107/discussions/07d3ef73d48677f2f0aba882a828e3990950d74e: 308 failed to parse unknown error format:

When looking at the log, I see this

-- REQUEST --
PUT //api/v4/projects/38490095/merge_requests/4107/discussions/07d3ef73d48677f2f0aba882a828e3990950d74e HTTP/1.1
Host: gitlab.com
Accept: application/json
Content-Type: application/json
Private-Token: REDACTED
User-Agent: go-gitlab

{"resolved":true}

-- RESPONSE --
HTTP/2.0 308 Permanent Redirect
Content-Length: 0
Cf-Cache-Status: DYNAMIC
Cf-Ray: 859089ad5a4c3c01-BLR
Date: Wed, 21 Feb 2024 16:59:05 GMT
Location: https://gitlab.com/api/v4/projects/38490095/merge_requests/4107/discussions/07d3ef73d48677f2f0aba882a828e3990950d74e
Nel: {"success_fraction":0.01,"report_to":"cf-nel","max_age":604800}
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=uOCEafFRV2iYemuq85Z6Xi09eY%2FJQMl0w4qwimPkI%2FwLGQaeWdymqziB3q5GxNiqokzDfDUcmV2ht%2F6%2FvfDyzEbsA72vgWrq7%2FjjGjCfPORuwj0s3YqMNF3njSo%3D"}],"group":"cf-nel","max_age":604800}
Server: cloudflare
Set-Cookie: _cfuvid=VWZAa5B1AviLlzUR2C7os6ryj.wn9Vqj63h3UiHyzGg-1708534745452-0.0-604800000; path=/; domain=.gitlab.com; HttpOnly; Secure; SameSite=None
Strict-Transport-Security: max-age=31536000
Vary: Accept-Encoding
X-Content-Type-Options: nosniff

Gitlab link : https://docs.gitlab.com/charts/troubleshooting/#308-permanent-redirect-causing-a-redirect-loop
tells me this might be due to redirection loop of http to https.
I'm not exactly sure what to do here.

Funnily enough if I have

gitlab_url=https://gitlab.com

instead of

gitlab_url=https://gitlab.com/

this error goes away.
I think the extra slash at the end is causing some redirects? not sure.

Hey @aravind2612krishna,

Thanks for filing this issue. Just to confirm, does removing the trailing slash solve your issue? If so, I can modify the code to just strip that suffix if that solves this issue...

Hi @harrisoncramer I can confirm that removing the trailing slash prevents redirects and prevents the issue! I think redirects might also be caused by http instead of https, or other reasons.

Great, thank you! I'll fix this in the next release by automatically trimming trailing slashes if they exist. Closing this now.