-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Sync version fails when two version end up with the same slug #4846
Comments
@humitos These lines can be modified in this way def slugify(self, content):
if not content:
return ''
hashed = abs(hash(content)) % (10 ** 8)
slugified = content.lower()
slugified = self.invalid_chars_re.sub(self.placeholder, slugified)
slugified = self.leading_punctuation_re.sub('', slugified)
slugified += f'-{hashed}'
if not slugified:
return self.fallback_slug
return slugified Result: >>> VersionSlugField(populate_from='').slugify('example/')
'example--81377426'
>>> VersionSlugField(populate_from='').slugify('/example/')
'example--24251688'
>>> VersionSlugField(populate_from='').slugify('example-')
'example--14556457'
>>> VersionSlugField(populate_from='').slugify('abcd')
'abcd-19060746' |
Interesting, our tests didn't catch that |
@stsewd When i test the test cases manually, they give the wrong result (as described in the issue) >>> VersionSlugField(populate_from='').slugify('1!0')
'1-0'
>>> VersionSlugField(populate_from='').slugify('1%0')
'1-0'
>>> VersionSlugField(populate_from='').slugify('1?0')
'1-0' |
We actually call to |
We can't generate slugs like this ones because all the URLs will become very ugly. Example, https://example.readthedocs.io/en/abcd-19060746/ (version) or https://abcd-19060746.readthedocs.io/en/latest/ (project). |
I can't replicate even with the same verbose name from sentry version = Version.objects.create(
verbose_name='raven/fix-start',
project=self.pip
)
self.assertEqual(version.slug, 'raven-fix-start')
version = Version.objects.create(
verbose_name='raven/fix-start',
project=self.pip
)
self.assertEqual(version.slug, 'raven-fix-start_a') |
I don't think the problem is in the sluggify step |
Here is the real problem Investigating But it doesn't make sense anyway, slug should be unique in each project :/ |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
We still need to investigate more here, bot. Replication is needed. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Still valid, maybe a race condition in some part of the code |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Still valid bot. |
@stsewd If I understand correctly, we only call |
When
sync_versions
is called if there are twoverbose_name
that endup with the sameslug
this code breaks:https://github.com/rtfd/readthedocs.org/blob/ba7623d2ff83b2c88cecbbe55800317f46116d0d/readthedocs/restapi/utils.py#L76-L82
As example,
Sentry: https://sentry.io/read-the-docs/readthedocscom/issues/746103998/
The text was updated successfully, but these errors were encountered: