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

Fix issue with PR build hostname parsing #8700

Merged
merged 1 commit into from Nov 22, 2021
Merged

Conversation

agjohnson
Copy link
Contributor

@agjohnson agjohnson commented Nov 20, 2021

Given a hostname slug--bug--1.org.readthedocs.build, the current
parsing code will give a project slug of slug and a version slug of
bug--1. This was a valid slug creation pattern for a short while,
though we have changed the behavior of the slugging to not produce slugs
with consecutive dashes.

rsplit here searches for the right most instance of double slugs

Fixes #8699

Given a hostname `slug--bug--1.org.readthedocs.build`, the current
parsing code will give a project slug of `slug` and a version slug of
`bug--1`. This was a valid slug creation pattern for a short while,
though we have changed the behavior of the slugging to not produce slugs
with consecutive dashes.

rsplit here searches for the right most instance of double slugs
@agjohnson agjohnson requested a review from a team as a code owner November 20, 2021 00:23
Copy link
Member

@stsewd stsewd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to add a test for this, around here

@override_settings(
RTD_EXTERNAL_VERSION_DOMAIN='dev.readthedocs.build',
)
def test_external_version_serving(self):
fixture.get(
Version,
verbose_name='10',
slug='10',
type=EXTERNAL,
active=True,
project=self.project,
)
url = '/awesome.html'
host = 'project--10.dev.readthedocs.build'
resp = self.client.get(url, HTTP_HOST=host)
self.assertEqual(
resp['x-accel-redirect'], '/proxito/media/external/html/project/10/awesome.html',
)
# Invalid tests

Also, do you have the problematic project that caused this? So we can QA after deploy.

@agjohnson
Copy link
Contributor Author

Yeah, I wanted to write a quick test, but ran into issues running the test suite.

This was a commercial project that hit the issue by the way, I'll ping you on the issue.

@agjohnson
Copy link
Contributor Author

Also, I might not return to this until later in my afternoon. Feel free to take the wheel here on the test case if you'd like to get this merged sooner!

@stsewd stsewd merged commit 218ff71 into master Nov 22, 2021
@stsewd stsewd deleted the agj/bug-pr-build-slug branch November 22, 2021 22:55
@stsewd
Copy link
Member

stsewd commented Nov 22, 2021

I'll add a test for this tomorrow

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 this pull request may close these issues.

Project slugs with multiple dashes can't load PR builds
2 participants