Repository navigation
Test that older readers ignore new properties in links.json - #4752
Merged
Merged
Conversation
links.json is read by every build, including builds of older docs-builder versions, and a newer build can add properties such as the pages of an API. These tests deserialize a links.json with a floating section and with several unknown shapes, and check that the rest reads unchanged and that cross-links resolve as before. They fail if RepositoryLinks starts rejecting unknown properties. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Contributor
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4752/ |
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.
Adds tests that an older reader of
links.jsonignores properties it does not know and reads everything else as before. They guard the link index against a newer build adding data, such as the pages of an API.Affects: Links & redirects
Prompt summary: Validate that the current
maincan read the new link index, and add a dedicated PR againstmainso backwards compatibility stays covered. The link index is read by every build, including builds of older docs-builder versions.Why
#4731 adds a
floatingproperty to thelinks.jsonof a docset that declares APIs. Every consumer of the link index reads that file withRepositoryLinks, so it keeps working only while the reader ignores unknown properties. Nothing tests that today. A change such as strict unmapped-member handling would break every build that fetches a repository with an API, and it would break them at once.What
Unknown properties are ignored
LinksJsonForwardCompatibilityTestsdeserializes alinks.jsonthat has thefloatingsection a later build writes, and several arbitrary shapes under the same name and under another unknown name: a string, a number, an array, and nested unknown fields. In each caselinks,cross_links,redirects,originandurl_path_prefixread exactly as they do without the property.Cross-links resolve as before
A file with and without the
floatingsection resolves the same cross-links throughCrossLinkResolver: a page, a page with an existing anchor, a missing anchor and a missing page.Verify
With
[JsonUnmappedMemberHandling(JsonUnmappedMemberHandling.Disallow)]added toRepositoryLinks, all 12 tests fail.I also read the real
links.jsonofdocs-contentbuilt with the newfloatingsection (1.45 MB, ten APIs) with this code. It reads exactly like the real file built without it: 2,775 links, 1,884 cross-links and 909 redirects are equal, and 60 real cross-links resolve identically.🤖 Generated with Claude Code