-
-
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
Design doc for changing version's slug #6273
Conversation
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.
The document looks good.
I'm not approving it yet because I want to think a little more about this and read other people's thoughts as well.
For now, I'm mentioning a problem in the solution proposed when changing the slug: delete and re-build.
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 feels really complex, which is the reason I have wanted to not allow this in the past. I don't think we should build an incredibly complex system for handling renaming of the slug. We should either let users shoot themselves in the foot, or not allow it. I tend to err on the side of not allowing it, and having them ask us when they want it.
This is the same conclusion we came to last time, and I still haven't heard a good reason for why we should allow users to rename things instead of just emailing support.
We need to check that the new slug is compatible with our current code. | ||
|
||
We can't allow users to change the slug of machine created versions, | ||
because those have a special meaning in our code (like ``stable`` and ``latest``). |
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.
What about if a user pushes a branch named latest
and then changes the slug of that?
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.
We already allow users to create a latest
branch that isn't machine created, the behavior is like any other branch.
readthedocs.org/readthedocs/rtd_tests/tests/test_sync_versions.py
Lines 527 to 587 in b61663b
def test_machine_attr_when_user_define_latest_tag_and_delete_it(self): | |
"""The user creates a tag named ``latest`` on an existing repo, when | |
syncing the versions, the RTD's ``latest`` is lost (set to | |
machine=False) and doesn't update automatically anymore, when the tag is | |
deleted on the user repository, the RTD's ``latest`` is back (set to | |
machine=True).""" | |
version_post_data = { | |
'branches': [ | |
{ | |
'identifier': 'origin/master', | |
'verbose_name': 'master', | |
}, | |
], | |
'tags': [ | |
# User new stable | |
{ | |
'identifier': '1abc2def3', | |
'verbose_name': 'latest', | |
}, | |
], | |
} | |
resp = self.client.post( | |
reverse('project-sync-versions', args=[self.pip.pk]), | |
data=json.dumps(version_post_data), | |
content_type='application/json', | |
) | |
self.assertEqual(resp.status_code, 200) | |
# The tag is the new latest | |
version_latest = self.pip.versions.get(slug='latest') | |
self.assertEqual( | |
'1abc2def3', | |
version_latest.identifier, | |
) | |
# Deleting the tag should return the RTD's latest | |
version_post_data = { | |
'branches': [ | |
{ | |
'identifier': 'origin/master', | |
'verbose_name': 'master', | |
}, | |
], | |
'tags': [], | |
} | |
resp = self.client.post( | |
reverse('project-sync-versions', args=[self.pip.pk]), | |
data=json.dumps(version_post_data), | |
content_type='application/json', | |
) | |
self.assertEqual(resp.status_code, 200) | |
# The latest isn't stuck with the previous commit | |
version_latest = self.pip.versions.get(slug='latest') | |
self.assertEqual( | |
'master', | |
version_latest.identifier, | |
) | |
self.assertTrue(version_latest.machine) |
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.
Right, but won't that break places where we expect a latest
slug on a project?
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 don't think so, the only parts where this has a special meaning is when we do a sync for versions and when sorting. So it would be sorted first (like a machine created version), but probably that's what users want.
As you mentioned, does the usage of an I don't have a clear idea of all the places in code that we're using version objects right now. |
It solves the problem with having the docs offline for a time, yes (there is a solution for this in the design doc too). But it introduces more changes, we would need to check the current logic where we use the slug and use the alias (or/and the slug) instead. Also, using an alias doesn't solve the problem to show a different name on the footer or change the order the version is sorted, if we want to solve that with the alias, we'll need to change more code. Also, the only special cases for the slug are |
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. |
Closing in favor of https://github.com/readthedocs/meta/discussions/147 |
Basically what I had in my old design doc #6273 - When changing the slug, we check that it's a valid one (lowercase, only number, etc), in case the slug is not valid, we suggest a valid slug based on the invalid one. Why not just transform the value to a valid slug? Changing the slug is a breaking operation, we want to avoid surprises for the user, if they set a slug to "foo/bar", and then the actual slug is "foo-bar", that's unexpected. - `project` is used as s hidden field, following the same pattern we already have for other forms (this way all normal validations like the unique constraint work instead of getting a 500). - Editing the slug is disabled for machine created versions (stable, latest). - I'm not restricting the usage of latest or stable, since those will be non-machine created, similar to what a user does already if they name a version stable/latest. - If a version was active and its slug was changed, the resources attached to the old slug are removed before triggering a new build. - Cache is always purged after deleting resources from the version. I was playing with using the "pattern" attribute for the input, so it validates the slug before submitting the form.  But I think showing the error with the suggested slug works better, maybe we can port that to JS instead as a future improvement.  ### Decisions - Expose this as a feature flag first, or just document it right away? ### TODO - Allow changing the slug using the API. - Suggest a redirect from the old slug to the new one. The idea implemented here comes from this comment: readthedocs/meta#147 (reply in thread) ref readthedocs/meta#147
Related to #6204 #4505 #5318