[WHIT-3631] Fall back to draft content store for unpublished document collection links#11561
Open
TonyGDS wants to merge 1 commit into
Open
[WHIT-3631] Fall back to draft content store for unpublished document collection links#11561TonyGDS wants to merge 1 commit into
TonyGDS wants to merge 1 commit into
Conversation
…links Adding a not-yet-published GOV.UK URL to a document collection group failed with "Url must reference a GOV.UK page", because the link validation only queries the live content store, which holds published content only. Fall back to the draft content store when the live content store returns a 404, so unpublished URLs resolve again. The live store is still queried first, preserving locale-agnostic lookups (e.g. Welsh pages), and the draft store handles drafts in any locale. Add Services.draft_content_store, authenticated with a dedicated DRAFT_CONTENT_STORE_BEARER_TOKEN, as the draft content store serves non-public content and requires a Signon bearer token.
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
Adding a not-yet-published GOV.UK URL to a document collection group (
/government/admin/collections/:id/groups/:id/add_by_url) fails with "Url must reference a GOV.UK page".The link validation only queries the live content store, which holds published content only. This was a regression from WHIT-3436 (#11442), which replaced the previous Publishing API lookup (
lookup_content_idwithwith_drafts: true) with the live content store to fix Welsh/locale resolution — but in doing so dropped draft awareness.How
Services.draft_content_store, authenticated with a dedicatedDRAFT_CONTENT_STORE_BEARER_TOKEN— the draft content store serves non-public content and requires a Signon bearer token (unlike the live store, which Whitehall reads without one).The code defaults the token to
"example"(local dev). Integration/staging/production need a real token provisioning:DRAFT_CONTENT_STORE_BEARER_TOKEN.GdsApi::ContentStorereads against draft-content-store returnaccess_limiteditems, or only non-limited drafts (per the draft stack docs).Test plan