fix(pipeline): resolve nav entries to real files before reading or writing them - #450
Open
shirgoldbird wants to merge 1 commit into
Open
shirgoldbird wants to merge 1 commit into
shirgoldbird wants to merge 1 commit into
Conversation
…iting them A gap's `path` is a docs.json nav entry. Nav entries carry no file extension, and a page can share its name with the directory holding its children (docs/resources/breaking-changes-change-notices is both a page and that folder). generate.py used those paths as filesystem paths, which broke every page-editing gap in three different ways: - Directory collision: open() got the directory and raised "[Errno 21] Is a directory", recorded as a generation error (PR #447). - Otherwise load_file() swallowed FileNotFoundError and returned "", so the model was told to expand a page whose current content was empty and wrote a replacement from scratch. Existing content would have been discarded. - The output path had no extension, so the draft was named `docs--a--b` and promote.py, which collects only *.mdx, dropped it silently. The page was reported as generated but never shipped -- which is why PR #447 lists an expanded page that isn't in its diff. So thin_page, missing_code_examples and missing_description have never produced a shipped page. - detect_gaps.page_file() is now the one way to turn a nav entry into a file, using is_file() so a directory can never masquerade as the page. - generate.load_existing_page() raises rather than returning nothing, so a failed read can't become "write this page from scratch". - determine_output_path() and apply_description() resolve through page_file(), so drafts keep their .mdx and promote picks them up. This also makes open-PR path matching work for these gaps, since PR file lists carry extensions. Also stops flagging hub pages as thin. breaking-changes-change-notices is short because its content is on its child pages; padding it out is the wrong fix, so pages with children are exempt. The Anthropic SDK is now imported lazily, so gap detection, --dry-run and the tests run without it. CI installs only pyyaml for the pipeline tests. Tests: pipeline/test_gap_paths.py (17), against a temp docs tree. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
This branch was successfully deployed
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.
Summary
Follow-up to #449, which surfaced this in #447's body:
A gap's
pathis a docs.json nav entry. Nav entries carry no file extension, and a page can share its name with the directory holding its children —docs/resources/breaking-changes-change-noticesis both a page (.mdx) and the folder its notices live in.generate.pyused those values as filesystem paths.That one mistake broke every page-editing gap in three ways:
open()got the directory and raised[Errno 21] Is a directory.load_file()swallowedFileNotFoundErrorand returned"", so the model was told to expand a page whose current content was empty and wrote a replacement from scratch. The real content would have been discarded.docs--a--bandpromote.py— which collects only*.mdx— dropped it without a word. This is why docs: pipeline-generated pages (?, Languages, Voice) #447 reports an expandedcookbook/google-sheetsthat isn't in its diff.So
thin_page,missing_code_examplesandmissing_descriptionhave never produced a shipped page. Symptom 2 is the one worth noting: it never landed only because symptom 3 kept it from shipping.What changed
detect_gaps.page_file()is now the single way to turn a nav entry into a file. It usesis_file(), so a directory can never masquerade as the page, and it replaces two copies of the extension-guessing loop.generate.load_existing_page()raises rather than returning nothing, so a failed read can't become "write this page from scratch". It also rejects an empty page.determine_output_path()andapply_description()resolve throughpage_file(), so drafts keep their.mdxand promote picks them up. This also fixes open-PR path matching for these gaps, since PR file lists carry extensions.Hub pages are no longer flagged as thin
breaking-changes-change-noticesis short because its content is on its child pages. Padding it out is the wrong fix, so pages with children are exempt from the thin-page check. After this, the onlythin_pagegap in the repo is the genuine one:Lazy SDK import
generate.pyimportsanthropicat call time instead of at import. Gap detection,--dry-runand the tests no longer need the SDK, so the CI test job installs onlypyyaml.Verification
Against the two real pages, before → after:
breaking-changes-change-notices[Errno 21] Is a directorycookbook/google-sheetsgoogle-sheets.mdxNew
pipeline/test_gap_paths.py— 17 tests against a temp docs tree, including the directory-collision regression and "a name prefix is not a child" (notices-and-moremust not count as a child ofnotices). 41 tests total inpipeline/.Not addressed: whether a 40-word cookbook page should be expanded by the pipeline at all is a judgment call, and stays with the reviewer.
🤖 Generated with Claude Code