readthedocs.org: Sync version fails when two version end up with the same slug

When sync_versions is called if there are two verbose_name that endup with the same slug this code breaks:

https://github.com/rtfd/readthedocs.org/blob/ba7623d2ff83b2c88cecbbe55800317f46116d0d/readthedocs/restapi/utils.py#L76-L82

As example,

In [11]: VersionSlugField(populate_from='').slugify('example/')                                                                                                                               
Out[11]: 'example-'

In [12]: VersionSlugField(populate_from='').slugify('/example/')                                                                                                                              
Out[12]: 'example-'

In [13]: VersionSlugField(populate_from='').slugify('example-')                                                                                                                               
Out[13]: 'example-'

Sentry: https://sentry.io/read-the-docs/readthedocscom/issues/746103998/

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Comments: 15 (12 by maintainers)

Most upvoted comments

VersionSlugField(populate_from=‘’).slugify(‘abcd’) ‘abcd-19060746’

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).