Skip to content

fix(sidebar): remove orphan entries during sidebar:fix#555

Merged
steve-calvert-glean merged 3 commits into
mainfrom
fix/sidebar-remove-orphans
May 14, 2026
Merged

fix(sidebar): remove orphan entries during sidebar:fix#555
steve-calvert-glean merged 3 commits into
mainfrom
fix/sidebar-remove-orphans

Conversation

@steve-calvert-glean
Copy link
Copy Markdown
Contributor

Summary

  • Follow-up to fix(scripts): map endpoints to sidebar categories by OpenAPI tag #551: sidebar drift was being handled in only one direction. The fixer would add entries for newly-discovered endpoints, but if upstream renamed or removed an endpoint, the stale entry was left in `sidebars.ts` and Docusaurus would reject the file during build with `Invalid sidebar file at "sidebars.ts"`.
  • This is the failure mode that's currently blocking Regenerate OpenAPI Documentation #553 (the latest regenerate PR): upstream renamed two `tools` endpoints to their `*-action-pack` variants, but `sidebars.ts` on `main` still has entries for the old names.
  • This change adds `removeOrphanEntries()` to `sync-api-sidebar.mjs` and calls it from `--fix` so the regenerate workflow keeps `sidebars.ts` in sync with the actual `.api.mdx` files in both directions. It also drops the two currently-orphaned `tools/authorize-action` and `tools/get-action-auth-status` entries inline so Regenerate OpenAPI Documentation #553 (and any future regenerate PR) can build cleanly without a separate cleanup step.

Test plan

  • `pnpm sidebar:check` on a clean main: passes (no missing, no orphans).
  • After regenerating `docs/api/client-api/` from upstream live spec (which has the renames): `sidebar:check` warns about 2 orphans, `sidebar:fix` removes them, follow-up `sidebar:check` passes.
  • Diff in `sidebars.ts` matches the 2 expected removals exactly — no other edits.
  • CI passes on this PR.
  • After merge, rebase or re-run Regenerate OpenAPI Documentation #553's CI; it should now build successfully.

🤖 Generated with Claude Code

Follow-up to #551: the sync-api-sidebar.mjs fixer handled "new endpoint
→ add entry" but not "endpoint renamed/removed → drop stale entry."
The script's `--check` mode warned about orphans but `--fix` left them
in place, so the Trigger Redeploy workflow's regenerate run produced
PRs whose sidebars.ts referenced docs that no longer exist (e.g. when
upstream renamed `authorize-action` → `authorize-action-pack`),
which Docusaurus rejects with `Invalid sidebar file at "sidebars.ts"`
during build.

- Add `removeOrphanEntries(root, orphanedIds)`: walks every `items`
  array in the sidebar AST and filters out entries whose `id` is in
  the orphan set.
- Call it from --fix after insertion so the same run that adds
  newly-discovered endpoints also drops stale ones.
- Update the early-exit condition: only skip work when both
  `missing.length` and `orphaned.length` are zero.
- Update output to report removed entries.

This commit also clears the two orphans currently on main:
- api/client-api/tools/authorize-action
- api/client-api/tools/get-action-auth-status

(both were superseded by `*-action-pack` variants in upstream).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@steve-calvert-glean steve-calvert-glean requested a review from a team as a code owner May 14, 2026 00:07
@vercel
Copy link
Copy Markdown

vercel Bot commented May 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
glean-developer-site Ready Ready Preview, Comment May 14, 2026 0:13am

Request Review

CI's prettier check caught the chained method-call indentation in
removeOrphanEntries (added in the previous commit) — prettier prefers
the single-line form. No behavioural change.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The earlier commit removed two `tools/authorize-action` and
`tools/get-action-auth-status` entries based on a local regenerate
that pulled the live upstream spec. CI sees a different state because
Turbo caches the spec-download output (its inputs only include the
script path, not the URL), so the cached `.api.mdx` files for those
endpoints still exist in CI's tree.

That means on `main`, those entries aren't actually orphaned — the
files still exist via the Turbo cache. Removing the entries here
breaks `sidebar:check` until the cache invalidates or the regenerate
workflow runs against fresh inputs.

Keep this PR script-only. The orphan-removal logic still ships; the
actual `sidebars.ts` cleanup will happen organically the next time
the regenerate workflow runs.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@steve-calvert-glean steve-calvert-glean merged commit 0fe5476 into main May 14, 2026
4 checks passed
@steve-calvert-glean steve-calvert-glean deleted the fix/sidebar-remove-orphans branch May 14, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant