fix(docs): fix management API docs generation and regenerate files#7593
fix(docs): fix management API docs generation and regenerate files#7593kristof-siket wants to merge 3 commits intomainfrom
Conversation
WalkthroughTwo files updated: CI workflow adds cleanup and validation steps for generated documentation, and generation script refines operation name parsing, enhances frontmatter handling with title/method/path extraction, and implements metadata computation with content rewriting for MDX files. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/sync-management-api-docs.yml:
- Around line 44-57: The current check loop (variable missing, the for field in
url metaTitle metaDescription; do ... grep -q "^${field}:" "$1") inspects the
whole MDX file and allows matches in body content; change it to first extract
only the YAML frontmatter block (between the leading and trailing ---) for each
file and then assert each key exists with a non-empty value (e.g., test for a
pattern like '^field: .+' inside that extracted block rather than '^field:' in
the whole file). Update the shell snippet that sets missing to extract
frontmatter (using awk/sed or a YAML tool) and run the per-field grep/regex
against that extracted content, preserving the same variable names (missing,
field) and exit/error behavior when any required frontmatter key is absent or
empty.
In `@apps/docs/scripts/generate-docs.ts`:
- Around line 49-55: The JSON.parse of operations can fail leaving apiPath empty
which later produces malformed SEO metadata; update the try/catch around the
operations parsing (the block that sets apiPath from operations[0]?.path) to
either (A) throw or return early when parsing fails or operations[0]?.path is
absent, or (B) guard emission of metaTitle/metaDescription so they are only
constructed/written when apiPath is non-empty (use a fallback like _openapi.path
if available before emitting). Concretely, ensure the parsing catch logs the
error and aborts generation for that file (or sets a clear fallback), and wrap
the code that builds/writes metaTitle/metaDescription so it runs only when
apiPath (or an explicit fallback) is present.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: aeec1e50-0811-4e78-915b-83963e9e953f
📒 Files selected for processing (2)
.github/workflows/sync-management-api-docs.ymlapps/docs/scripts/generate-docs.ts
6850d17 to
6e7d75f
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
apps/docs/scripts/generate-docs.ts (1)
47-55:⚠️ Potential issue | 🟠 MajorGuard SEO metadata emission when API operation parsing fails.
At Line 49–Line 55, parse failures only warn and continue; then Line 79–Line 85 still emit metadata using possibly empty
apiPath/method, producing malformed values.Suggested fix
let apiPath = ""; if (apiPageMatch) { try { const operations = JSON.parse(apiPageMatch[1].replace(/'/g, '"')); if (operations[0]?.path) { apiPath = operations[0].path; } } catch (e) { console.warn(`Failed to parse operations for ${file.path}:`, e); } } + + if (!method || !apiPath || !title) { + console.warn( + `Skipping SEO metadata for ${file.path} (missing method/path/title)`, + ); + file.content = + `---\n${frontmatter}\n---` + file.content.slice(frontmatterMatch[0].length); + continue; + } const slug = file.path .replace(/^.*endpoints\//, "") .replace(/\.mdx$/, "");Also applies to: 79-85
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/docs/scripts/generate-docs.ts` around lines 47 - 55, Parsing of apiPageMatch into operations can fail but the code still emits SEO metadata using apiPath/method; update the logic so metadata is only emitted when parsing succeeded and valid values exist: inside the try/catch, set apiPath and method only if operations[0]?.path and operations[0]?.method are present, and in the emission block (the code that uses apiPath/method) add a guard that skips emitting or continues if apiPath or method are falsy (or set a parseFailed flag in the catch and check it before emitting). Reference variables/api symbols: apiPageMatch, operations, apiPath, method, file.path.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@apps/docs/scripts/generate-docs.ts`:
- Around line 47-55: Parsing of apiPageMatch into operations can fail but the
code still emits SEO metadata using apiPath/method; update the logic so metadata
is only emitted when parsing succeeded and valid values exist: inside the
try/catch, set apiPath and method only if operations[0]?.path and
operations[0]?.method are present, and in the emission block (the code that uses
apiPath/method) add a guard that skips emitting or continues if apiPath or
method are falsy (or set a parseFailed flag in the catch and check it before
emitting). Reference variables/api symbols: apiPageMatch, operations, apiPath,
method, file.path.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 12cca744-0f31-41fd-8f8c-5460413478c3
📒 Files selected for processing (42)
.github/workflows/sync-management-api-docs.ymlapps/docs/content/docs/management-api/endpoints/connections/delete-connections-by-id.mdxapps/docs/content/docs/management-api/endpoints/connections/get-connections-by-id.mdxapps/docs/content/docs/management-api/endpoints/connections/get-connections.mdxapps/docs/content/docs/management-api/endpoints/connections/meta.jsonapps/docs/content/docs/management-api/endpoints/connections/post-connections.mdxapps/docs/content/docs/management-api/endpoints/database-backups/get-databases-id-backups.mdxapps/docs/content/docs/management-api/endpoints/database-usage/get-databases-id-usage.mdxapps/docs/content/docs/management-api/endpoints/databases-connections/delete-connections.mdxapps/docs/content/docs/management-api/endpoints/databases-connections/get-databases-id-connections.mdxapps/docs/content/docs/management-api/endpoints/databases-connections/meta.jsonapps/docs/content/docs/management-api/endpoints/databases-connections/post-databases-id-connections.mdxapps/docs/content/docs/management-api/endpoints/databases/delete-databases-id.mdxapps/docs/content/docs/management-api/endpoints/databases/get-databases-id.mdxapps/docs/content/docs/management-api/endpoints/databases/get-databases.mdxapps/docs/content/docs/management-api/endpoints/databases/get-projects-id-databases.mdxapps/docs/content/docs/management-api/endpoints/databases/meta.jsonapps/docs/content/docs/management-api/endpoints/databases/patch-databases-id.mdxapps/docs/content/docs/management-api/endpoints/databases/post-databases.mdxapps/docs/content/docs/management-api/endpoints/databases/post-projects-id-databases.mdxapps/docs/content/docs/management-api/endpoints/integrations/delete-integrations-by-id.mdxapps/docs/content/docs/management-api/endpoints/integrations/delete-workspaces-id-integrations-id.mdxapps/docs/content/docs/management-api/endpoints/integrations/get-integrations-by-id.mdxapps/docs/content/docs/management-api/endpoints/integrations/get-integrations.mdxapps/docs/content/docs/management-api/endpoints/integrations/get-workspaces-id-integrations.mdxapps/docs/content/docs/management-api/endpoints/integrations/meta.jsonapps/docs/content/docs/management-api/endpoints/meta.jsonapps/docs/content/docs/management-api/endpoints/misc/get-regions-accelerate.mdxapps/docs/content/docs/management-api/endpoints/misc/get-regions-postgres.mdxapps/docs/content/docs/management-api/endpoints/projects/delete-projects-by-id.mdxapps/docs/content/docs/management-api/endpoints/projects/get-projects-by-id.mdxapps/docs/content/docs/management-api/endpoints/projects/get-projects.mdxapps/docs/content/docs/management-api/endpoints/projects/meta.jsonapps/docs/content/docs/management-api/endpoints/projects/patch-projects-by-id.mdxapps/docs/content/docs/management-api/endpoints/projects/post-projects-by-id-transfer.mdxapps/docs/content/docs/management-api/endpoints/projects/post-projects.mdxapps/docs/content/docs/management-api/endpoints/regions/get-regions.mdxapps/docs/content/docs/management-api/endpoints/regions/meta.jsonapps/docs/content/docs/management-api/endpoints/workspaces/get-workspaces-by-id.mdxapps/docs/content/docs/management-api/endpoints/workspaces/get-workspaces.mdxapps/docs/content/docs/management-api/endpoints/workspaces/meta.jsonapps/docs/scripts/generate-docs.ts
💤 Files with no reviewable changes (1)
- apps/docs/content/docs/management-api/endpoints/databases-connections/delete-connections.mdx
✅ Files skipped from review due to trivial changes (9)
- apps/docs/content/docs/management-api/endpoints/misc/get-regions-postgres.mdx
- apps/docs/content/docs/management-api/endpoints/misc/get-regions-accelerate.mdx
- apps/docs/content/docs/management-api/endpoints/projects/post-projects-by-id-transfer.mdx
- apps/docs/content/docs/management-api/endpoints/databases/delete-databases-id.mdx
- apps/docs/content/docs/management-api/endpoints/database-usage/get-databases-id-usage.mdx
- apps/docs/content/docs/management-api/endpoints/databases/post-databases.mdx
- apps/docs/content/docs/management-api/endpoints/connections/meta.json
- apps/docs/content/docs/management-api/endpoints/integrations/get-workspaces-id-integrations.mdx
- apps/docs/content/docs/management-api/endpoints/databases/patch-databases-id.mdx
🚧 Files skipped from review as they are similar to previous changes (1)
- .github/workflows/sync-management-api-docs.yml
6e7d75f to
831c448
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
apps/docs/scripts/generate-docs.ts (1)
43-55:⚠️ Potential issue | 🟠 MajorGuard SEO field emission when
apiPathcannot be derived.At Line [79] and Line [81], metadata is generated even if
apiPathis empty (e.g., APIPage parse failure at Line [49]-Line [55]). That can produce malformed frontmatter and fail CI validators.💡 Proposed hardening diff
const apiPageMatch = file.content.match( /<APIPage[^>]*operations=\{(\[.*?\])\}/s, ); - let apiPath = ""; - if (apiPageMatch) { + const openapiPathMatch = frontmatter.match( + /^\s*path:\s*["']?([^"'\n]+)["']?\s*$/m, + ); + let apiPath = openapiPathMatch?.[1] ?? ""; + + if (!apiPath && apiPageMatch) { try { const operations = JSON.parse(apiPageMatch[1].replace(/'/g, '"')); if (operations[0]?.path) { apiPath = operations[0].path; } } catch (e) { console.warn(`Failed to parse operations for ${file.path}:`, e); } } + + if (!method || !title || !apiPath) { + console.warn( + `Skipping SEO metadata for ${file.path}: missing method/title/path.`, + ); + continue; + } @@ const metaTitle = `${method} ${apiPath} | ${title} - Prisma Postgres`; const descriptionClean = description.replace(/\.$/, ""); const metaDescription = `Management API: ${descriptionClean}. ${method} ${apiPath}.`;Also applies to: 79-85
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/docs/scripts/generate-docs.ts` around lines 43 - 55, The metadata/frontmatter emission currently unconditionally includes SEO fields even when apiPath is empty (apiPageMatch / operations parsing may fail and leave apiPath === ""), so update the generation logic to guard emission: where frontmatter/metadata is assembled (around the code that uses apiPath at the metadata generation section), check that apiPath is non-empty before adding SEO-related entries (or skip emitting the whole SEO block) to avoid producing malformed frontmatter; locate the variables apiPageMatch, operations and apiPath in generate-docs.ts and conditionally include the metadata only when apiPath is truthy (or provide a safe default/omit the keys) so CI validators won’t fail.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@apps/docs/scripts/generate-docs.ts`:
- Around line 43-55: The metadata/frontmatter emission currently unconditionally
includes SEO fields even when apiPath is empty (apiPageMatch / operations
parsing may fail and leave apiPath === ""), so update the generation logic to
guard emission: where frontmatter/metadata is assembled (around the code that
uses apiPath at the metadata generation section), check that apiPath is
non-empty before adding SEO-related entries (or skip emitting the whole SEO
block) to avoid producing malformed frontmatter; locate the variables
apiPageMatch, operations and apiPath in generate-docs.ts and conditionally
include the metadata only when apiPath is truthy (or provide a safe default/omit
the keys) so CI validators won’t fail.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 145a5fab-e90e-4348-947c-db4fb8f67b99
📒 Files selected for processing (42)
.github/workflows/sync-management-api-docs.ymlapps/docs/content/docs/management-api/endpoints/connections/delete-connections-by-id.mdxapps/docs/content/docs/management-api/endpoints/connections/get-connections-by-id.mdxapps/docs/content/docs/management-api/endpoints/connections/get-connections.mdxapps/docs/content/docs/management-api/endpoints/connections/meta.jsonapps/docs/content/docs/management-api/endpoints/connections/post-connections.mdxapps/docs/content/docs/management-api/endpoints/database-backups/get-databases-id-backups.mdxapps/docs/content/docs/management-api/endpoints/database-usage/get-databases-id-usage.mdxapps/docs/content/docs/management-api/endpoints/databases-connections/delete-connections.mdxapps/docs/content/docs/management-api/endpoints/databases-connections/get-databases-id-connections.mdxapps/docs/content/docs/management-api/endpoints/databases-connections/meta.jsonapps/docs/content/docs/management-api/endpoints/databases-connections/post-databases-id-connections.mdxapps/docs/content/docs/management-api/endpoints/databases/delete-databases-id.mdxapps/docs/content/docs/management-api/endpoints/databases/get-databases-id.mdxapps/docs/content/docs/management-api/endpoints/databases/get-databases.mdxapps/docs/content/docs/management-api/endpoints/databases/get-projects-id-databases.mdxapps/docs/content/docs/management-api/endpoints/databases/meta.jsonapps/docs/content/docs/management-api/endpoints/databases/patch-databases-id.mdxapps/docs/content/docs/management-api/endpoints/databases/post-databases.mdxapps/docs/content/docs/management-api/endpoints/databases/post-projects-id-databases.mdxapps/docs/content/docs/management-api/endpoints/integrations/delete-integrations-by-id.mdxapps/docs/content/docs/management-api/endpoints/integrations/delete-workspaces-id-integrations-id.mdxapps/docs/content/docs/management-api/endpoints/integrations/get-integrations-by-id.mdxapps/docs/content/docs/management-api/endpoints/integrations/get-integrations.mdxapps/docs/content/docs/management-api/endpoints/integrations/get-workspaces-id-integrations.mdxapps/docs/content/docs/management-api/endpoints/integrations/meta.jsonapps/docs/content/docs/management-api/endpoints/meta.jsonapps/docs/content/docs/management-api/endpoints/misc/get-regions-accelerate.mdxapps/docs/content/docs/management-api/endpoints/misc/get-regions-postgres.mdxapps/docs/content/docs/management-api/endpoints/projects/delete-projects-by-id.mdxapps/docs/content/docs/management-api/endpoints/projects/get-projects-by-id.mdxapps/docs/content/docs/management-api/endpoints/projects/get-projects.mdxapps/docs/content/docs/management-api/endpoints/projects/meta.jsonapps/docs/content/docs/management-api/endpoints/projects/patch-projects-by-id.mdxapps/docs/content/docs/management-api/endpoints/projects/post-projects-by-id-transfer.mdxapps/docs/content/docs/management-api/endpoints/projects/post-projects.mdxapps/docs/content/docs/management-api/endpoints/regions/get-regions.mdxapps/docs/content/docs/management-api/endpoints/regions/meta.jsonapps/docs/content/docs/management-api/endpoints/workspaces/get-workspaces-by-id.mdxapps/docs/content/docs/management-api/endpoints/workspaces/get-workspaces.mdxapps/docs/content/docs/management-api/endpoints/workspaces/meta.jsonapps/docs/scripts/generate-docs.ts
💤 Files with no reviewable changes (1)
- apps/docs/content/docs/management-api/endpoints/databases-connections/delete-connections.mdx
✅ Files skipped from review due to trivial changes (1)
- apps/docs/content/docs/management-api/endpoints/databases-connections/get-databases-id-connections.mdx
🚧 Files skipped from review as they are similar to previous changes (27)
- apps/docs/content/docs/management-api/endpoints/projects/post-projects.mdx
- .github/workflows/sync-management-api-docs.yml
- apps/docs/content/docs/management-api/endpoints/projects/post-projects-by-id-transfer.mdx
- apps/docs/content/docs/management-api/endpoints/workspaces/meta.json
- apps/docs/content/docs/management-api/endpoints/database-usage/get-databases-id-usage.mdx
- apps/docs/content/docs/management-api/endpoints/databases/patch-databases-id.mdx
- apps/docs/content/docs/management-api/endpoints/database-backups/get-databases-id-backups.mdx
- apps/docs/content/docs/management-api/endpoints/workspaces/get-workspaces-by-id.mdx
- apps/docs/content/docs/management-api/endpoints/misc/get-regions-accelerate.mdx
- apps/docs/content/docs/management-api/endpoints/integrations/get-workspaces-id-integrations.mdx
- apps/docs/content/docs/management-api/endpoints/databases-connections/meta.json
- apps/docs/content/docs/management-api/endpoints/misc/get-regions-postgres.mdx
- apps/docs/content/docs/management-api/endpoints/connections/post-connections.mdx
- apps/docs/content/docs/management-api/endpoints/regions/get-regions.mdx
- apps/docs/content/docs/management-api/endpoints/connections/delete-connections-by-id.mdx
- apps/docs/content/docs/management-api/endpoints/workspaces/get-workspaces.mdx
- apps/docs/content/docs/management-api/endpoints/integrations/delete-integrations-by-id.mdx
- apps/docs/content/docs/management-api/endpoints/databases/delete-databases-id.mdx
- apps/docs/content/docs/management-api/endpoints/projects/delete-projects-by-id.mdx
- apps/docs/content/docs/management-api/endpoints/connections/meta.json
- apps/docs/content/docs/management-api/endpoints/databases/post-databases.mdx
- apps/docs/content/docs/management-api/endpoints/databases/get-databases-id.mdx
- apps/docs/content/docs/management-api/endpoints/databases/meta.json
- apps/docs/content/docs/management-api/endpoints/integrations/get-integrations-by-id.mdx
- apps/docs/content/docs/management-api/endpoints/projects/get-projects.mdx
- apps/docs/content/docs/management-api/endpoints/regions/meta.json
- apps/docs/content/docs/management-api/endpoints/meta.json
831c448 to
d4b7354
Compare
d4b7354 to
825633e
Compare
… files - Fix generate-docs.ts: inject required frontmatter (url, metaTitle, metaDescription), fix filename collisions for ById endpoints, use slice-based content replacement to prevent corruption, add SEO guard - Update sync workflow: add stale file cleanup, comprehensive validation (lint:links, lint:spellcheck, next build) before committing - Include regenerated MDX files and updated meta.json to restore CI on main
825633e to
d098090
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/docs/scripts/generate-docs.ts`:
- Around line 65-74: The current check uses !frontmatter.includes("path:") which
scans the whole frontmatter and can miss injecting _openapi.path when another
top-level path exists; update the logic to detect the _openapi block and only
test that block for a missing "path:" before injecting. Concretely, locate the
code manipulating frontmatter (the frontmatter variable and the replace call),
extract the _openapi block (e.g., with a regex that captures
/_openapi:\s*\n([\s\S]*?)(\n\S|$)/), check whether that captured block contains
"path:" and only when it does not, perform the replace/injection of `path:
"${apiPath}"` into the _openapi block; ensure you still require apiPath and
preserve the existing replace call on the _openapi section.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 0bc75038-855a-4319-9e2a-86f15aaa80e4
📒 Files selected for processing (2)
.github/workflows/sync-management-api-docs.ymlapps/docs/scripts/generate-docs.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- .github/workflows/sync-management-api-docs.yml
Address CodeRabbit review: the previous `frontmatter.includes("path:")`
check scanned the entire frontmatter. Now we extract the `_openapi:`
block first and only check/inject `path:` within that block.
|
@coderabbitai review |
The OG image route only had GET, POST, DELETE in HTTP_METHOD_COLORS. PATCH endpoints (now valid with correct frontmatter) caused Satori to crash on "3px solid undefined" CSS. Add PATCH/PUT colors and a fallback for any future unknown methods.
Problem
The docs sync workflow pushes generated MDX files directly to
main, but the generation produces files that break three CI workflows:url,metaTitle,metaDescription)Root causes in
generate-docs.ts:beforeWriteonly injected_openapi.path, not the three SEO fields required bysource.config.ts./By[A-Z][a-z]*/gstripsByIdentirely, soGET /v1/projectsandGET /v1/projects/{id}both produceget-projects.mdx. The second write corrupts the first.String.replace(frontmatter, ...)matches content body text, causing further corruption.Changes
apps/docs/scripts/generate-docs.tsurl,metaTitle,metaDescriptionfrom operation metadata inbeforeWriteBy[A-Z][a-z]*→By[A-Z][a-z]{2,}— preservesByIdas-by-id, preventing collisionsString.replaceapiPathfrom_openapi.pathfrontmatter_openapi.pathinjection to the_openapiYAML block only.github/workflows/sync-management-api-docs.yml*.mdxbefore generation so renamed endpoints don't accumulatelint:links+lint:spellcheck+next build— if any check fails, nothing is pushed tomainapps/docs/src/app/og/[...slug]/route.tsxPATCHandPUTtoHTTP_METHOD_COLORS— previously only GET/POST/DELETE were mapped, causing Satori to crash on"3px solid undefined"CSS when rendering OG images for PATCH endpoints#a0aec0) for any unknown HTTP methodsstringfor future-proofingRegenerated MDX files & meta.json
Since
mainis currently in a broken state, this PR also includes the correctly regenerated output so that merging immediately restores CI:meta.jsonforconnections,regions,workspacesdirectoriesmeta.jsonfordatabases,integrations,projects,databases-connections, and top-levelendpointsdelete-connections.mdx→delete-connections-by-id.mdx)Test plan
workflow_dispatchmainhas correct frontmatter and no stale files