Fix redirects not written or deployed for isolated builds - #3746
Conversation
Isolated builds (e.g. docs-builder's own docs) were discarding the GenerationResult from GenerateAll with `_ = await`, so redirects.json was never produced and redirects defined in _redirects.yml had no effect. - Capture GenerateAll result in IsolatedBuildService.Build and write redirects.json with path-prefix-resolved absolute URLs - Add --no-delete flag to `assembler deploy update-redirects` so per-docset deploys only PUT new entries without wiping other repos' KVS redirects - Add Deploy redirects step in docs-preview-local.yml to push docs-builder's redirects.json to the CloudFront KVS on push to main Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
Do we have redirects in our preview environment? |
The preview environment does not serve redirects from a CloudFront KVS, so deploying redirects.json there has no effect. The build-side changes (writing redirects.json, --no-delete flag) remain as groundwork for when a deploy target exists. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
… infra" This reverts commit 65a4922.
|
Good question — I went and checked the infra to be sure. The preview environment does already have the full redirect-serving setup:
So the only missing piece was exactly what this PR adds: producing One known limitation worth flagging: since the deploy uses |
Why
Redirects defined in
_redirects.ymlfor docs-builder's own docs (and any other isolated/per-docset build) were silently discarded.IsolatedBuildService.BuildcalledGenerateAllwith the discard operator (_ = await), so theGenerationResult.Redirectsmap was thrown away andredirects.jsonwas never written to disk. And even if it had been written, no workflow step ever pushed it to the redirect store the preview environment already serves from.What
IsolatedBuildService.Build: captures theGenerateAllresult and writesredirects.jsonto the output directory, resolving each redirect's relative file paths to absolute URL paths using the configured--path-prefixassembler deploy update-redirects: gains a--no-deleteflag that skips the KVS reconciliation delete pass — only PUTs the new entries. This is required for per-docset deploys, which only know about their own redirects and must not wipe other repos' entries from a shared KVSdocs-preview-local.yml: adds a "Deploy redirects to CloudFront KVS" step after the S3 upload, running on pushes to main only, that invokesassembler deploy update-redirects --no-delete previewHow
The URL resolution in
IsolatedBuildService.ToAbsoluteUrlmirrorsFileNavigationLeaf.DetermineUrl: strips.md, strips trailing/index, and treats a bareindexpath as the path-prefix root. Cross-repo redirects (containing://) are skipped since the isolated build has no cross-link resolver to follow them.Known limitation: with
--no-deletethere is no reconciliation, so redirects removed from_redirects.ymlwill linger in the KVS. A scoped reconciliation (deleting only keys under this docset's path prefix) is a reasonable follow-up.