Skip to content

Cannot redirect from old version to new version if old version is marked inactive #4598

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

Closed
wohali opened this issue Sep 1, 2018 · 4 comments
Assignees
Labels
Bug A bug
Milestone

Comments

@wohali
Copy link

wohali commented Sep 1, 2018

Details

Expected Result

Pursuant to #2444 and #4501, I should be able to add a redirect from a now-obsolete version of our documentation (2.1.1) to our current stable version (stable) by adding an Exact redirect:

/en/2.1.1/$rest -> /en/stable/

This should redirect a page such as http://docs.couchdb.org/en/2.1.1/intro/overview.html to http://docs.couchdb.org/en/stable/intro/overview.html .

Actual Result

Accessing http://docs.couchdb.org/en/2.1.1/intro/overview.html results in a Permission Denied error unless that actual version (2.1.1) is marked as an Active Version. Setting the version to be redirected as Inactive makes redirection impossible.

Setting these invalid versions to Active makes them appear in the valid version list, but clicking on them results in them being redirected to somewhere else (in our case, the stable tag) which is very confusing for end users.

@humitos I believe that redirection checks should occur before checking whether a version is marked as inactive, yes? This way, redirects for obsolete versions would not require those versions to continue to be marked as Active.

@stsewd
Copy link
Member

stsewd commented Sep 1, 2018

I think the problem is that the docs of an inactive version (the version was already built) aren't removed. In order to a redirect to work, it should be 404, so I'm not sure why the redirect now works (maybe that page doesn't exist?).

Also, I believe that there is a task that clean docs from inactive versions, so maybe you only need to wait a little (I haven't look at the code yet, I'll do it by monday or so)

@stsewd stsewd added the Support Support question label Sep 1, 2018
@wohali
Copy link
Author

wohali commented Sep 2, 2018

@stsewd The versions marked inactive had been marked inactive for months. I recently re-marked them active so the redirects would work. I even tried clicking the "clean" button to no avail.

@humitos
Copy link
Member

humitos commented Sep 4, 2018

I got confused at first read. I understand what's happening now and I think there is a bug in our redirection system.

As @stsewd mentioned, the redirects are only considered when a 404 is found (there is an issue opened that will change this when implemented #4550).

In order to a redirect to work, it should be 404, so I'm not sure why the redirect now works (maybe that page doesn't exist?).

Even the version of the redirect is active=True it has a built=False which means that after being activated no build was triggered so no docs are available for that version. In that case, when hitting a correct URL for this version as the is no docs, we get a 404 and the redirect system comes in.

That said, redirects should have nothing to do with versions being active or not. That's a bug to me and will take a look at the source code to check why that is happening.

The correct setup for your use case should be as what you expect: versions disabled and redirect working without any kind of permission issue.

@humitos humitos added Bug A bug and removed Support Support question labels Sep 4, 2018
@humitos humitos added this to the 2.7 milestone Sep 4, 2018
@humitos
Copy link
Member

humitos commented Sep 4, 2018

This logic is not accurate to me:

https://github.com/rtfd/readthedocs.org/blob/a29fea4f2ddde27bf5785841e6e29ac16fd803d4/readthedocs/core/views/serve.py#L155-L161

project.versions.public looks for public versions and active=True. In your case that returns the DoesNotExist exception and it enters to the except block. There, as the Version 2.1.1 exists it returns 401 as if the user has not permissions to read it.

I think in the except block, we should check for permissions/version active and decide if we need to return 401 or 404 instead. I will propose a PR soon with these changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug
Projects
None yet
Development

No branches or pull requests

3 participants