-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Unresolver: strict validation for external versions and other fixes #9534
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
Conversation
- At first I was thinking to add this validation outside the unresolver, but I think it makes sense to be in the unresolver. - This also has a fix for partial subproject matches. - Instead of returning the query and the fragment separately, just return the parsed URL, I think it can useful to have the full path without having to call urllib.parse again. - Just return the extracted external version from unresolve_domain, so we don't have to parse the subdomain again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a good change, but I do worry a bit about some of the response magic that I don't fully understand here, and what it's handling.
version = None | ||
filename = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we do something more than set these to None
here? Is raising an exception better, rather than having the caller need to know what None
means on these fields?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting version to None
will be interpreted as like the version wasn't found, but we could return None, or raise an exception, since those URLs will be generated by manually changing the URL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about this as well, and I'm not sure what's my position here.
I'd like to raise exceptions for all these cases were we return None
for not found things. However, I'm not sure it's possible for all the cases because IIRC there are other places were project, None, None
is useful to continue moving forward.
If that's not the case and I'm confused here, I'm 👍🏼 on standardizing this and always raise a detailed exception for each case that we can clearly handle from outside.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think the case that I'm referring to is the 404 pages (see https://github.com/readthedocs/readthedocs.org/pull/9534/files#diff-3f2b884fdd4752fe36587aee4530694e7a4ff10a8f4523a7b0bc25e9d2f11e11R162)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, basically this would be interpreted as a 404, like if the version wouldn't exist.
I think this is close once we fix up the conflicts 👍 Also would be useful to have a @humitos review as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is getting better 👍🏼
I think it's not ready to get merged yet, but it's pretty close. I left some comments that I'd like to see considered. Some of these comments are related with the review I've done in #9500 (review)
I'm not opposed to move forward without refactoring all the naming and others, but I'd really appreciate if we do that work now that we are all of us with this code in mind.
version = None | ||
filename = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about this as well, and I'm not sure what's my position here.
I'd like to raise exceptions for all these cases were we return None
for not found things. However, I'm not sure it's possible for all the cases because IIRC there are other places were project, None, None
is useful to continue moving forward.
If that's not the case and I'm confused here, I'm 👍🏼 on standardizing this and always raise a detailed exception for each case that we can clearly handle from outside.
version = None | ||
filename = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think the case that I'm referring to is the 404 pages (see https://github.com/readthedocs/readthedocs.org/pull/9534/files#diff-3f2b884fdd4752fe36587aee4530694e7a4ff10a8f4523a7b0bc25e9d2f11e11R162)
I have updated this PR with some of comments from the review from There are a couple I didn't address, since I'm -0. Renames
Dataclass instead of a tuple
I started the implementation using 3 dataclasses, Others
We are calling it parent project (#9500 (comment)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @stsewd for considering my comments from the other PR as well. I think we can move forward with this PR and merge it. I didn't see anything blocking it at this point. As you said, there are things about naming and refactoring that we can do in another PR. The core logic is done 👍🏼
outside the unresolver, but I think it makes
sense to be in the unresolver.
separately, just return the parsed URL, I think
it can useful to have the full path without
having to call urllib.parse again.
from unresolve_domain, so we don't have to parse the
subdomain again.
This is on top of #9500.
📚 Documentation previews 📚
docs
): https://docs--9534.org.readthedocs.build/en/9534/dev
): https://dev--9534.org.readthedocs.build/en/9534/