Point generated info_path at a URL path, not the plugin outputDir - #194
Merged
Conversation
The openapi-docs plugin derives each *.api.mdx's `info_path` frontmatter
from its `outputDir` option, which is a filesystem path
('docs/bitrise-api/api-reference'), and writes it out unchanged. The theme
then consumes that value as a URL rather than a doc id —
docusaurus-theme-openapi-docs, theme/ApiExplorer/SecuritySchemes/index.tsx:
const infoAuthPath = `/${props.infoPath}#authentication`;
The href is emitted verbatim, so it never goes through Docusaurus's
locale/routeBasePath resolution and has to carry the locale prefix itself.
With `routeBasePath: ''` and `i18n.localeConfigs.en.baseUrl: '/en/'`, the
generated value resolves to /docs/... and 404s, breaking the Authentication
link on all 164 API reference pages.
Verified against production:
/en/bitrise-api/api-reference/bitrise-api -> 200
/docs/bitrise-api/api-reference/bitrise-api -> 404
Fixing the files alone would not hold: the sync workflow runs
clean-api-docs + gen-api-docs on every spec change, so the wrong value is
reintroduced each time. patch-api-info.js already exists to reapply fixes
the plugin discards, so the normalisation belongs there as step 4. The
expected value is derived from each target's own infoFile rather than
hardcoded, so a future outputDir change can't silently reintroduce it.
- patch-api-info.js: add step 4, idempotent, existsSync-guarded
- Regenerate the 164 affected *.api.mdx via the script (one line each)
ilanazholobovsky
requested review from
aorcsik,
matenadasdi and
zoltan-baba
as code owners
August 19, 2026 12:56
Collaborator
Author
|
Verified on the deploy preview:
Correction to the description above: the broken URL is |
The previous commit set `info_path` to `en/...`. That fixes the en build but breaks the ja one, and it contradicts the convention #189 established. The theme renders the value through Docusaurus's <Link>: const infoAuthPath = `/${props.infoPath}#authentication`; <Link to={infoAuthPath}>...</Link> <Link> prepends the active locale's baseUrl unless the path already starts with it. So `en/...` renders as /en/... on the en build (correct, since it already carries the prefix) but as /ja/en/... on the ja build, which doesn't exist. Verified on the deploy preview: /ja/bitrise-api/api-reference/activity-list -> Authentication href /ja/en/bitrise-api/api-reference/bitrise-api -> 404 That is the exact failure mode sync_mcp_docs.py's rewrite_internal_links warns about, and the reason #189 stripped hardcoded /en/ from synced links. A bare route path is correct for every locale, because <Link> supplies the prefix. Both info pages exist under both locales today (the ja build falls back to the untranslated source), verified on the same preview: /en/bitrise-api/api-reference/bitrise-api -> 200 /ja/bitrise-api/api-reference/bitrise-api -> 200 /en/bitrise-rde-api/.../bitrise-remote-dev-environments-api -> 200 /ja/bitrise-rde-api/.../bitrise-remote-dev-environments-api -> 200 Also corrects the root-cause note in the script's header. The plugin does have logic to turn outputDir into a route, but it is guarded (plugin src/index.ts, v5.0.2): let infoBasePath = `${outputDir}/${item.infoId}`; if (docRouteBasePath) { ...rebuild from docRouteBasePath... } `docs.routeBasePath` is '' here, which is falsy, so the guard never fires and the raw filesystem path is written. This was latent until routeBasePath changed from 'en' to '' — which is why the value was correct before the change and wrong after the next regeneration. - EN_ROUTE_PREFIX -> ROUTE_BASE_PATH, mirroring docs.routeBasePath - Regenerate the 164 *.api.mdx via the script (one line each)
zoltan-baba
approved these changes
Aug 19, 2026
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.
What
info_pathon all 164 generated*.api.mdxpages currently points at a filesystem path instead of a route, so the security-scheme link in the API Explorer resolves to a 404 on every API reference page. This fixes the pages and stops the next spec sync reintroducing it.Where to see it. On any API reference page, the right-hand API Explorer panel has a header bar reading
AUTHORIZATION: AUTHORIZATION, and under it a box listingname: Authorization / type: apiKey / in: header. TheAuthorizationvalue next toname:is a link — the theme renders it as<Link to={infoAuthPath}>{name ?? key}</Link>, so the label is the security scheme's name from the spec, not the word "authentication". Only the href contains#authentication.Live on
docs.bitrise.io— activity-list:Scale honestly: it's a small link (80×13px, no underline, in a corner panel) so few readers will have hit it. It is wrong on all 164 pages, and the underlying value is what every future spec sync will keep corrupting — that's the reason to fix it rather than the click-through volume.
Why it broke
docusaurus-plugin-openapi-docsbuilds the value from itsoutputDiroption, which is a filesystem path. It does have logic to turn that into a route — but the logic is guarded (src/index.ts, v5.0.2):docRouteBasePathis ourdocs.routeBasePath, which #186 changed from'en'to''. Empty string is falsy, so the guard stopped firing and the rawoutputDirpath started being written out.That's why the value was correct before and wrong after: while
routeBasePathwas'en'the block ran and produceden/bitrise-api/…. #186 set it to'', and the next regeneration — #192 (44 files) and #193 (120 files), merged today — wrotedocs/bitrise-api/….Why a bare path, not
en/The theme renders the value through Docusaurus's
<Link>(docusaurus-theme-openapi-docs,theme/ApiExplorer/SecuritySchemes/index.tsx):<Link>prepends the active locale'sbaseUrlunless the path already starts with it. So the value must be a bare route path with no locale prefix — same convention as body links, and for the same reasonsync_mcp_docs.py'srewrite_internal_linksgives in #189: a hardcodeden/renders as/ja/en/…under the ja locale, which doesn't exist.The first commit on this branch got that wrong and used
en/. The second commit corrects it to a bare path. Verified on the deploy preview, all four combinations:/en/bitrise-api/api-reference/bitrise-api#authentication/ja/bitrise-api/api-reference/bitrise-api#authentication/en/bitrise-rde-api/…/bitrise-remote-dev-environments-api#authentication/ja/bitrise-rde-api/…/bitrise-remote-dev-environments-api#authenticationWhy the fix goes in
patch-api-info.jssync-api-references.ymlrunsclean-api-docs→gen-api-docs→patch-api-info.json every spec change, so editing the generated files alone would be undone by the next sync.patch-api-info.jsalready exists to reapply what the plugin discards (displayed_sidebar, licence name, duplicate sidebar labels) — this is step 4 in the same pattern, idempotent andexistsSync-guarded like the rest.The expected value is derived from each target's own
infoFilerelative todocs.path, not hardcoded, so a futureoutputDirchange can't silently reintroduce a filesystem prefix.Fixing the plugin's falsy check upstream would be the real solution. This keeps us correct in the meantime without pinning or patching the package.
Why CI didn't catch it
Nothing reads
info_path.scripts/check-links-source.jsdoesn't parse frontmatter at all, and it skips anchor validation under/bitrise-api/api-referenceand/bitrise-rde-api/api-reference(GENERATED_ANCHOR_ROUTE_PREFIXES). Raised as TW-1815 — this is the third/en/-prefix bug in two days (cf. #186, #189), and the checker gap is what lets the class through.Testing
main.Not verified: I confirmed the broken and fixed hrefs by reading the rendered DOM and fetching the target URLs, on production and on the preview. I did not get a click on the link itself to navigate — the element is small and may be overlapped. If that matters for review, worth a manual click on the preview.