Repository navigation
fix(redirects): redirect bare API paths and renamed API pages - #1017
Merged
Merged
Conversation
…erence pages Each API reference page embeds its operation path (e.g. /safari/mcp/server/update) as a root-relative string in the rendered page data. Crawlers resolve it against the docs domain and request it, which returns 404 because every page lives under /zh/ or /en/. - Add scripts/api_path_redirects.py, which derives one redirect per operation path from the zh API navigation in docs.json and the x-mint.href of each operation, and rewrites that block of redirects. `--check` fails when the block is out of date; the OpenAPI lint workflow now runs it. - Add the generated 338 redirects (bare path -> /zh/api-reference/...). - Redirect 7 API pages per locale whose slugs were renamed while the operation stayed (artifact gallery, IM war room list, status page list) to their current slugs. Endpoints that were retired from the API keep returning 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.
Problem
Requests to bare API operation paths on the docs domain return 404, for example:
/safari/mcp/server/update/calendar/event/delete/monit/datasource/deleteEach API reference page embeds its operation path as a root-relative string in the rendered page data (
"path":"/safari/mcp/server/update"). Crawlers resolve that string againstdocs.flashduty.comand request it, but every page lives under/zh/or/en/.A second group of 404s are API pages whose slug was renamed while the operation stayed, e.g.
/zh/api-reference/ai-sre/artifacts/artifact-gallery-read-get(nowartifact-read-get).Change
scripts/api_path_redirects.pyderives one redirect per operation path from thezhAPI navigation indocs.jsonplus each operation'sx-mint.href, and rewrites that block ofredirects. Managed entries = source without a locale prefix and destination under/zh/api-reference/; hand-written redirects are untouched.--checkexits 1 when the block is stale.docs.json: 338 generated redirects (bare path -> zh reference page; zh is the default locale,/already goes to/zh/home), plus 14 redirects (7 per locale) for renamed API page slugs.openapi-lint.ymlrunsapi_path_redirects.py --checkand now also triggers ondocs.json, so spec or navigation changes that leave the redirects stale fail CI. After regenerating specs, runpython3 scripts/api_path_redirects.py.Endpoints retired from the API (old monitor rule/rule-set/service-map, environment, channel notify-rule endpoints, etc.) are intentionally left as 404: they have no replacement page.
Verification
python3 scripts/api_path_redirects.py --check-> exit 0;python3 scripts/lint_openapi.py-> no violationsmint validate-> build validation passed;mint broken-links-> no broken links foundmint dev:/safari/mcp/server/update,/calendar/event/delete,/monit/datasource/delete,/incident/comment-type/reorder,/enrichment/mapping/schema/info,/safari/artifact/gallery/file-state,/monit/prometheus/api/v1/label/{label_name}/values(raw and percent-encoded braces) and/en/api-reference/on-call/status-pages/statuspage-read-page-listredirect to the expected pages;/zh/api-reference/monitors/service-map/monit-servicemap-read-statusstays 404