Improve 404 recovery with related page suggestions#3655
Open
theletterf wants to merge 11 commits into
Open
Conversation
reakaleek
reviewed
Jul 16, 2026
Member
|
Since this is hard to preview, can you attach a video or screenshots? |
reakaleek
reviewed
Jul 16, 2026
reakaleek
reviewed
Jul 16, 2026
Keep the production 404 page unchanged until related-page recovery is enabled, and avoid linking to an unsupported search route. Co-authored-by: GPT-5.6 Terra <noreply@openai.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Validate the 404 response shared by all environments instead of recovery controls that are intentionally disabled locally. Co-authored-by: GPT-5.6 Terra <noreply@openai.com> Co-authored-by: Cursor <cursoragent@cursor.com>
…feature/related-pages-404
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.
Preview testing
The shared preview CloudFront distribution has a static error target at
/docs/404/index.html. It cannot select the generated 404 page beneath an individual PR path prefix, so an arbitrary missing preview URL currently renders the generic distribution-level error page.As a temporary review aid, the
assembler-previewworkflow publishes this generated 404 page at a known route:https://docs-v3-preview.elastic.dev/elastic/docs-builder/docs/3655/opentelemetry-collector
This route validates the branch's server-rendered 404 layout and frontend bundle without relying on CloudFront error handling. It intentionally returns HTTP 200 and therefore does not validate the final CloudFront status mapping.
It is not currently an end-to-end test of related-page embeddings. The preview distribution does not expose the docs search API at the preview path, and the API is currently protected by the
searchOrAskAifeature cookie in WAF. The related-pages component hides itself when that API request fails.The 404 intentionally does not include an inline search bar in this PR. Search remains available through the
Open full searchlink; adding an embedded search experience can be discussed separately with the wider team.The route-copy workaround is isolated in the workflow step named
Publish temporary 404 experience preview. Delete that single step after the infrastructure fallback is available.Required docs-infra follow-up
Before enabling
RELATED_PAGESin production, docs-infra needs to:searchOrAskAicookie gate from WAF;RELATED_PAGESfor production after the API and error routing are ready.The preview distribution currently uses the static
/docs/404/index.htmlobject. Relevant configuration:https://github.com/elastic/docs-infra/blob/main/modules/elastic-docs-v3/cloudfront-distribution.tf
Local testing
The regular docs development server renders the repository
404.mdfor missing documentation routes. The assembled static host also serves the generated 404 page with status 404, providing local coverage of the layout and response status.To verify real related-page results locally, run the API against a search endpoint with embeddings. Keep credentials out of the repository:
Use the Elasticsearch (
.es.) endpoint, not the matching Kibana (.kb.) endpoint. Confirm suggestions for a missing path with:curl 'http://127.0.0.1:5020/docs/_api/v1/related-pages?path=%2Fdocs%2Fopentelemetry-collector'The request returns up to five suggestions. To render them in the 404 page, enable
RELATED_PAGES, serve an assembled site with the same API configuration, and visit a nonexistent documentation URL. The hosted PR preview cannot perform this final request until the docs-infra WAF and preview routing follow-up is complete.The related-pages component can be rendered locally by enabling
RELATED_PAGES, but real suggestions still require a reachable docs search API with embeddings. Local layout testing therefore does not by itself validate semantic results.Validation
./build.sh lintdotnet test tests/Elastic.Documentation.Api.Infrastructure.Tests/ --no-restoredotnet test tests/Elastic.Documentation.Api.Tests/ --no-restoredotnet test tests/Elastic.Markdown.Tests/ --no-restore --filter FullyQualifiedName~NotFoundPageTestsnpm run test -- RelatedPagesnpm run compile:checknpm run lintnpm run fmt:checknpm run buildAddresses https://github.com/elastic/docs-eng-team/issues/663