Skip to content

Allow Welsh-language mainstream URLs [WHIT-3436]#11442

Open
GDSNewt wants to merge 1 commit into
mainfrom
allow-mainstream-welsh-links
Open

Allow Welsh-language mainstream URLs [WHIT-3436]#11442
GDSNewt wants to merge 1 commit into
mainfrom
allow-mainstream-welsh-links

Conversation

@GDSNewt
Copy link
Copy Markdown
Contributor

@GDSNewt GDSNewt commented May 12, 2026

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

@GDSNewt GDSNewt force-pushed the allow-mainstream-welsh-links branch from 80db2fe to 7bc045a Compare May 12, 2026 16:02
Comment thread app/models/document_collection_non_whitehall_link/govuk_url.rb
Copy link
Copy Markdown
Contributor

@jamiestamp jamiestamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@GDSNewt GDSNewt force-pushed the allow-mainstream-welsh-links branch 3 times, most recently from f368fb0 to 1cabc1c Compare May 13, 2026 16:33
@GDSNewt GDSNewt requested a review from jamiestamp May 13, 2026 16:39
Comment thread app/models/document_collection_non_whitehall_link/govuk_url.rb Outdated
@GDSNewt GDSNewt force-pushed the allow-mainstream-welsh-links branch from 522daf1 to b72739f Compare May 14, 2026 14:45
…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.
@GDSNewt GDSNewt force-pushed the allow-mainstream-welsh-links branch from b72739f to adc8991 Compare May 14, 2026 15:22
Copy link
Copy Markdown
Contributor

@ChrisBAshton ChrisBAshton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 🤞

Comment on lines +34 to +35
content_id
@content_item ||= content_item_from_content_store
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kind of 'side effect' method (content_id) isn't very readable. Probably best being more open that one is dependent on the other:

Suggested change
content_id
@content_item ||= content_item_from_content_store
@content_item ||= content_item_from_content_store(content_id)

end

def content_id
@content_id ||= Services.publishing_api.lookup_content_id(base_path: parsed_url.path, with_drafts: true)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we agreed to drop this call and just call Content Store right off the bat? It would simplify things a lot.

@TonyGDS
Copy link
Copy Markdown
Contributor

TonyGDS commented May 15, 2026

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants