Render error to user if base path reserved [WHIT-2884]#10914
Merged
patrickpatrickpatrick merged 2 commits intoJan 13, 2026
Conversation
3611a8f to
9de162c
Compare
Base automatically changed from
avoid-accidentally-overwriting-base-path
to
main
December 9, 2025 09:59
f02d8a6 to
4383c4b
Compare
a396a17 to
025310d
Compare
5ddabe7 to
7e59046
Compare
519163d to
ae69cf1
Compare
ae69cf1 to
8b7de83
Compare
ChrisBAshton
commented
Jan 8, 2026
Contributor
Author
ChrisBAshton
left a comment
There was a problem hiding this comment.
Thanks for nudging this towards the finish line, @patrickpatrickpatrick ! Some comments below.
ChrisBAshton
commented
Jan 8, 2026
ChrisBAshton
commented
Jan 8, 2026
f2f3246 to
5088778
Compare
6ad354d to
14c4330
Compare
ChrisBAshton
commented
Jan 9, 2026
14c4330 to
73f513b
Compare
ChrisBAshton
commented
Jan 12, 2026
Contributor
Author
ChrisBAshton
left a comment
There was a problem hiding this comment.
LGTM 👍 one possible optimisation below.
I raised the PR, so can't approve it - so feel free to go ahead and merge it @patrickpatrickpatrick !
| end | ||
|
|
||
| def self.ensure_base_path_is_associated_with_this_content_id!(base_path, content_id) | ||
| def self.ensure_base_path_is_associated_with_this_content_id!(instance, content) |
Contributor
Author
There was a problem hiding this comment.
This can be simplified further I think? To just take instance? (And then use instance.base_path instead of content[:base_path]...?)
Contributor
There was a problem hiding this comment.
I'm not sure, since content[:base_path] comes from the presenter of the instance and there's at least one instance of that being derived from presenter and not from the model.
The user attempts to create a document with the same base path as a published edition then destroy the newly saved edition. This is required as the edition is saved before the conflict check. If the edition is not destroyed then the user can still edit and attempt to save and/or force publish the conflicting new edition.
Instead of presenting a server error to the user if they try and create an edition that has the base path of another published edition, the error is now presented to the user.
73f513b to
85d0577
Compare
patrickpatrickpatrick
approved these changes
Jan 13, 2026
ChrisBAshton
added a commit
that referenced
this pull request
Jan 20, 2026
Reverts #10914. The PR did more than originally intended. 1. In #10912, we added a check to ensure that the generated base path of a document didn't already exist in Publishing API under a different content ID. We raised an exception in such cases. This was to accommodate the one or two cases where Whitehall has somehow produced a document that already exists under the same route in Publishing API, e.g. a 'legacy' News Article from several years ago, conflicting with a 'StandardEdition' News Article created recently. All such cases are resolved now. 2. In #10914, we intended to capture the exception and display it to the user, to offer a slightly more user friendly experience. However, the scope of the PR grew to include uniqueness checks on the *title* as well as the base path. We didn't anticipate any issues at the time. 3. There are over 12k documents in Whitehall that have clashing titles (or rather, have slugs that clash but for the fact that FriendlyId auto-increments the slug, e.g. `foo` and `foo--2`). The validation added in #10914 meant that already-published documents whose titles/slugs clash with other documents (when the 'sequence' suffix is dropped) could not have new drafts created. This has led to several support tickets. 4. We've been attempting to 'fix forward' this behaviour in #11003, to add the validation constraints *only* on 'first draft' editions, but there is a fair bit of complexity to consider. In the short term, therefore, we've decided to roll back the changes from #10914, to allow us a bit of breathing room to look at the problem again more holistically.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
When trying to create a document that has an already reserved base path, catch the error and render an error with the title field on the new document form.
Further details
Why
Continues the work of #10912, now presenting an error to the user on the form instead of rendering a server error and removing the contents of the form.
Visual Differences
On attempting to create a new draft with the same base path:
This application is owned by the Whitehall Experience team. Please let us know in #govuk-whitehall-experience-tech when you raise any PRs.
Follow these steps if you are doing a Rails upgrade.