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

[BUG] Investigate 503 #218

Closed
3 tasks
dcastro opened this issue Nov 7, 2022 · 4 comments · Fixed by #233
Closed
3 tasks

[BUG] Investigate 503 #218

dcastro opened this issue Nov 7, 2022 · 4 comments · Fixed by #233
Assignees
Milestone

Comments

@dcastro
Copy link
Member

dcastro commented Nov 7, 2022

Description

In some of our gitlab projects, we have links such as https://gitlab.com/morley-framework/morley-infra/-/issues/new.

For some reason, when xrefcheck attempts to verify these links, it gets a 503 Service Temporarily Unavailable, which causes xrefcheck to fail. As a result, our gitlab projects ignore those links with a xrefcheck: ignore link annotation.

However, if you manually verify it using curl or using a browser, you get a 302 redirection (which would make xrefcheck pass).

To Reproduce

Steps to reproduce the behavior:

$ echo '[a](https://gitlab.com/morley-framework/morley-infra/-/issues/new)' > a.md
$ git add a.md
$ xrefcheck
Configuration file not found, using default config for GitHub repositories

=== Invalid references found ===                                                                                                                    

  ➥  In file a.md
     bad reference (external) at src:7:1-66:
       - text: "a"
       - link: https://gitlab.com/morley-framework/morley-infra/-/issues/new
       - anchor: -
     
     ⛂  Resource unavailable (503 Service Temporarily Unavailable)
     
Invalid references dumped, 1 in total.

However, if we check the same link via curl, it replies with a 302 redirect.

$ curl -I https://gitlab.com/morley-framework/morley-infra/-/issues/new
HTTP/2 302 
...
location: https://gitlab.com/users/sign_in
...

Similarly, opening the link in the browser (while not authenticated into gitlab.com) gets us redirected to https://gitlab.com/users/sign_in.

Expected behavior

Expected the link to reply with a 302 and for xrefcheck to pass.

Environment

  • xrefcheck v0.2.2
@dcastro dcastro added this to the 0.3.0 milestone Nov 7, 2022
@Martoon-00
Copy link
Member

AFAIR if I visit that page from the browser without being authenticated into any account, I will get 503 too. So this is an issue around authentication.

@dcastro
Copy link
Member Author

dcastro commented Nov 8, 2022

Just double-checked to be sure, it replies with a 302:

image

I suspect the discrepancy between xrefcheck vs curl/browser might be due to some header.

The most obvious suspect would be the User-Agent header, so I tried using curl without this header to see if I would get a 503, but nope, didn't work :/

$ curl -I https://gitlab.com/morley-framework/morley-infra/-/issues/new -H 'User-Agent:' -v                                                                                                               
...
HTTP/2 302 

@aeqz aeqz self-assigned this Nov 29, 2022
@aeqz
Copy link
Contributor

aeqz commented Nov 29, 2022

We can reproduce the xrefcheck behaviour by telling curl to follow redirects (-L):

$ curl -IL https://gitlab.com/morley-framework/morley-infra/-/issues/new                                                                                                              
...
HTTP/2 503

This is because the default HTTP configuration that is being used in the project follows automatically up to 10 redirect responses. I have tried to set the corresponding value to 0 and then xrefcheck shows a 302 response code.

Now, even with this 302 response, xrefcheck keeps reporting it as an error. Perhaps we should also change that to not consider a 302 response as an error?

@aeqz aeqz removed their assignment Nov 29, 2022
@Martoon-00
Copy link
Member

Oh, then that's exactly #25.

We have discussed this for a while, but didn't manage to make a final decision yet. Could you read that discussion and leave your thoughts, and I will reiterate over it and drop some thoughts too.

aeqz added a commit that referenced this issue Dec 7, 2022
Problem: Xrefcheck currently always follows redirect links.

Solution: We are changing its default behaviour regarding redirect links to fail and report permanent redirects, and to pass for temporary redirects. Further PRs will allow the user to configure other policies.
@aeqz aeqz self-assigned this Dec 7, 2022
aeqz added a commit that referenced this issue Dec 8, 2022
Problem: Xrefcheck currently always follows redirect links.

Solution: We are changing its default behaviour regarding redirect
links to fail and report permanent redirects, and to pass for temporary
redirects. Further PRs will allow the user to configure other policies.
aeqz added a commit that referenced this issue Dec 8, 2022
aeqz added a commit that referenced this issue Dec 8, 2022
aeqz added a commit that referenced this issue Dec 12, 2022
Problem: Xrefcheck currently always follows redirect links.

Solution: We are changing its default behaviour regarding redirect
links to fail and report permanent redirects, and to pass for temporary
redirects. Further PRs will allow the user to configure other policies.
aeqz added a commit that referenced this issue Dec 12, 2022
Problem: Xrefcheck currently always follows redirect links.

Solution: We are changing its default behaviour regarding redirect
links to fail and report permanent redirects, and to pass for temporary
redirects. Further PRs will allow the user to configure other policies.
@aeqz aeqz closed this as completed in #233 Dec 12, 2022
aeqz added a commit that referenced this issue Dec 12, 2022
…nagement

[#218] Change redirects default behaviour
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

Successfully merging a pull request may close this issue.

3 participants