fix(): further validate 404 reports#7543
Conversation
WalkthroughReformats Vercel redirects (mostly stylistic) and removes one redirect. Updates several docs links (switches issue links to prisma/web), removes Fig subsection from editor-setup pages, and adds a new external link linter script plus npm/turbo scripts to run it. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🍈 Lychee Link Check Report3664 links: ❌ Errors
Full Statistics Table
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
apps/docs/scripts/lint-external-links.ts (3)
28-28:MARKDOWN_IMAGE_REGEXis defined but never used — dead code.The constant is declared and its
lastIndexis reset incollectFileLinks(line 126), but it's never passed to awhile((match = ...) !== null)exec loop. Image links are already excluded by (a) the(?<!!)negative lookbehind inMARKDOWN_LINK_REGEXand (b) theisImageUrl()guard inside each loop. The definition and thelastIndexreset can both be removed.🧹 Proposed cleanup
-const MARKDOWN_IMAGE_REGEX = /!\[[^\]]*]\(([^)\n]+)\)/g; const MARKDOWN_LINK_REGEX = /(?<!!)\[[^\]]*]\(([^)\n]+)\)/g;- MARKDOWN_IMAGE_REGEX.lastIndex = 0; MARKDOWN_LINK_REGEX.lastIndex = 0;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/docs/scripts/lint-external-links.ts` at line 28, Remove the unused MARKDOWN_IMAGE_REGEX definition and its lastIndex reset in collectFileLinks: delete the const MARKDOWN_IMAGE_REGEX = /!\[[^\]]*]\(([^)\n]+)\)/g declaration and remove any code that resets MARKDOWN_IMAGE_REGEX.lastIndex (referenced in collectFileLinks), since image links are already excluded by MARKDOWN_LINK_REGEX and isImageUrl guards.
195-196:|| response.status === 429in the retry guard is always covered by>= 400.Since 429 ≥ 400 is unconditionally true, the second clause is a no-op. The intent (retry all 4xx/5xx responses from HEAD with GET) is already expressed by
>= 400alone.🧹 Proposed cleanup
- if (response.status >= 400 || response.status === 429) { + if (response.status >= 400) { response = await fetchWithTimeout(url, { method: "GET", headers: BROWSER_HEADERS }); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/docs/scripts/lint-external-links.ts` around lines 195 - 196, The conditional that checks "if (response.status >= 400 || response.status === 429)" is redundant because 429 is already >= 400; update the retry guard by removing the redundant "|| response.status === 429" clause so it simply checks "response.status >= 400" before calling fetchWithTimeout(url, { method: "GET", headers: BROWSER_HEADERS }); reference the existing variables/identifiers "response", "fetchWithTimeout", and "BROWSER_HEADERS" when making the change.
240-299: Consider CI impact: this script makes live external HTTP requests on every run.A few operational implications worth keeping in mind as this gets wired into the lint pipeline:
- No result caching. Every invocation re-fetches all unique URLs. For a large doc corpus, this adds meaningful CI wall-clock time.
- No per-domain throttling.
MAX_CONCURRENCY = 15is a global cap, but all 15 slots can hit the same host simultaneously (e.g.,github.com), which increases 429 risk. SinceACCEPTED_STATUSESincludes 429 this won't cause false failures, but it means broken links on rate-limited hosts will silently pass.- Flakiness surface. Transient network errors or upstream outages will fail the lint step with no retry. Consider whether this task should be allowed to fail without blocking the PR, or whether a simple retry count (
--retry n) would help.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/docs/scripts/lint-external-links.ts` around lines 240 - 299, The script performs live HTTP checks in main() with runWithConcurrency capped by MAX_CONCURRENCY and uses checkUrl/ACCEPTED_STATUSES; to reduce CI impact add (1) an optional local cache layer (e.g., cache file keyed by URL + TTL) to skip re-fetching recent results, (2) per-host rate limiting or concurrency partitioning so runWithConcurrency does not schedule all slots against the same domain, (3) a retry mechanism in checkUrl with configurable --retry N and backoff for transient failures, and (4) a CLI flag (e.g., --non-blocking) so failures don’t break CI; implement these as configurable options and ensure main() reads flags to enable caching, retries, per-host limits, and non-blocking behavior.
🤖 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/content/docs/`(index)/prisma-orm/quickstart/mongodb.mdx:
- Line 326: The GitHub issue link referenced in the sentence about "Empty
database name" may be incorrect or unverified; confirm that
https://github.com/prisma/web/issues/5562 is the intended target and resolves to
the correct Prisma issue, and if not replace it with the correct issue/URL or
remove the link, updating the sentence in the MongoDB quickstart content (the
paragraph containing "Empty database name" in mongodb.mdx) to point to the
validated issue or to an appropriate official Prisma docs page; ensure the final
text and link are accurate and consistent with the referenced occurrence in
add-to-existing-project/mongodb.mdx.
---
Nitpick comments:
In `@apps/docs/scripts/lint-external-links.ts`:
- Line 28: Remove the unused MARKDOWN_IMAGE_REGEX definition and its lastIndex
reset in collectFileLinks: delete the const MARKDOWN_IMAGE_REGEX =
/!\[[^\]]*]\(([^)\n]+)\)/g declaration and remove any code that resets
MARKDOWN_IMAGE_REGEX.lastIndex (referenced in collectFileLinks), since image
links are already excluded by MARKDOWN_LINK_REGEX and isImageUrl guards.
- Around line 195-196: The conditional that checks "if (response.status >= 400
|| response.status === 429)" is redundant because 429 is already >= 400; update
the retry guard by removing the redundant "|| response.status === 429" clause so
it simply checks "response.status >= 400" before calling fetchWithTimeout(url, {
method: "GET", headers: BROWSER_HEADERS }); reference the existing
variables/identifiers "response", "fetchWithTimeout", and "BROWSER_HEADERS" when
making the change.
- Around line 240-299: The script performs live HTTP checks in main() with
runWithConcurrency capped by MAX_CONCURRENCY and uses
checkUrl/ACCEPTED_STATUSES; to reduce CI impact add (1) an optional local cache
layer (e.g., cache file keyed by URL + TTL) to skip re-fetching recent results,
(2) per-host rate limiting or concurrency partitioning so runWithConcurrency
does not schedule all slots against the same domain, (3) a retry mechanism in
checkUrl with configurable --retry N and backoff for transient failures, and (4)
a CLI flag (e.g., --non-blocking) so failures don’t break CI; implement these as
configurable options and ensure main() reads flags to enable caching, retries,
per-host limits, and non-blocking behavior.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (13)
apps/docs/content/docs.v6/(index)/prisma-orm/add-to-existing-project/mongodb.mdxapps/docs/content/docs.v6/(index)/prisma-orm/quickstart/mongodb.mdxapps/docs/content/docs.v6/orm/more/ai-tools/chatgpt.mdxapps/docs/content/docs.v6/orm/more/dev-environment/editor-setup.mdxapps/docs/content/docs.v6/orm/prisma-client/setup-and-configuration/databases-connections/index.mdxapps/docs/content/docs/(index)/prisma-orm/add-to-existing-project/mongodb.mdxapps/docs/content/docs/(index)/prisma-orm/quickstart/mongodb.mdxapps/docs/content/docs/ai/tools/chatgpt.mdxapps/docs/content/docs/orm/more/dev-environment/editor-setup.mdxapps/docs/package.jsonapps/docs/scripts/lint-external-links.tspackage.jsonturbo.json
💤 Files with no reviewable changes (2)
- apps/docs/content/docs.v6/orm/more/dev-environment/editor-setup.mdx
- apps/docs/content/docs/orm/more/dev-environment/editor-setup.mdx
✅ Files skipped from review due to trivial changes (3)
- apps/docs/content/docs.v6/orm/more/ai-tools/chatgpt.mdx
- apps/docs/content/docs.v6/(index)/prisma-orm/quickstart/mongodb.mdx
- apps/docs/content/docs.v6/(index)/prisma-orm/add-to-existing-project/mongodb.mdx
Summary by CodeRabbit
Chores
Documentation