Allow Welsh-language mainstream URLs [WHIT-3436]#11442
Conversation
80db2fe to
7bc045a
Compare
f368fb0 to
1cabc1c
Compare
b72739f to
adc8991
Compare
ChrisBAshton
left a comment
There was a problem hiding this comment.
Looks broadly fine - document collections need a bit more love in general anyway - but we do have an opportunity to simplify with Content Store calls and dropping Publishing API calls 🤞
|
I assume we're willing to live with any lag between publishing-api pushing the latest content to the content store? Worst that would happen is the user would see the same error as now. |
…on groups The Publishing API's lookup_content_id endpoint does not index translated (Welsh) base paths, causing a false "must reference a GOV.UK page" error when users tried to add Welsh mainstream URLs to a document collection. Fall back to the Content Store when both Publishing API lookups return no content ID, as the Content Store resolves content items by any translated base path. If the Content Store also returns a 404, the original error is still raised. Adds Services.content_store using GdsApi::ContentStore, and updates tests to cover the Welsh URL case and to stub the Content Store in the existing "not found" test.
cd24aef to
29d5029
Compare
ChrisBAshton
left a comment
There was a problem hiding this comment.
Hi Alex - the code broadly looks good, just some tidying up to do before merge. Thanks
|
|
||
| test "should be invalid when Publishing API is down" do | ||
| stub_publishing_api_isnt_available | ||
| Services.content_store.stubs(:content_item).raises(GdsApi::HTTPIntermittentServerError.new(503)) |
There was a problem hiding this comment.
Test name needs updating
| /app/assets/builds/* | ||
| !/app/assets/builds/.keep | ||
|
|
||
| console_history.txt |
There was a problem hiding this comment.
This appears to have slipped in?
| Services.content_store.stubs(:content_item).with("/foo/subpage").returns( | ||
| "content_id" => content_id, | ||
| "title" => "Foo Bar", | ||
| "base_path" => "/foo", |
There was a problem hiding this comment.
Should this not be /foo/subpage?
|
|
||
| test "should be invalid when Publishing API returns a 404" do | ||
| stub_any_publishing_api_call_to_return_not_found | ||
| Services.content_store.stubs(:content_item).raises(GdsApi::ContentStore::ItemNotFound.new(404)) |
There was a problem hiding this comment.
Test name needs updating
| ) | ||
| end | ||
|
|
||
| test "should be valid without a GOV.UK url that Publishing API knows" do |
There was a problem hiding this comment.
Test name needs updating
| setup do | ||
| @content_id = SecureRandom.uuid | ||
| stub_publishing_api_has_lookups("/test" => @content_id) | ||
| stub_publishing_api_has_item( |
There was a problem hiding this comment.
Do these Publishing API stubs need to exist any more?
| assert url.errors.full_messages.include?("Url must reference a GOV.UK page") | ||
| end | ||
|
|
||
| test "should be valid when a Welsh-language GOV.UK URL is used that is not in the Publishing API path reservations" do |
There was a problem hiding this comment.
test name needs updating
There was a problem hiding this comment.
also I don't really understand the relevance of the second half of the test name 🤔
| assert url.valid? | ||
| end | ||
|
|
||
| test "should be valid when a Welsh-language GOV.UK URL is in the Publishing API but only has a Welsh locale" do |
There was a problem hiding this comment.
I'm not clear what this test is trying to exercise differently to the one above it?
Welsh-only GOV.UK pages (e.g. /talu-treth-twe) were failing validation with "Url must reference a GOV.UK page" when added to document collection groups. The root cause was that get_content in the Publishing API defaults to locale: en, so Welsh-only content — which only exists in locale: cy — returned a 404.
This PR replaces get_content with the Content Store for fetching content items. The Content Store serves content regardless of locale, so Welsh URLs now resolve correctly.
The guide sub-page check (which validates that a two-segment path like /guidance/subpage belongs to a guide) continues to work because the Content Store returns the parent guide's content item for sub-page paths, making document_type available directly from that response.
BEFORE
Screen.Recording.2026-05-13.at.17.24.09.mov
AFTER
Screen.Recording.2026-05-13.at.17.23.03.mov
Jira