Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

Summary

Updated the cache revalidation API in the docs bundle from revalidateTag to invalidateByTag to align with Next.js 15's caching API changes.

Changes Made

  • Updated import statement in revalidate/route.ts to use invalidateByTag instead of revalidateTag
  • Replaced the revalidateTag(domain) call with invalidateByTag(domain)

What to Review

⚠️ Critical Path - Untested Change

This change affects cache invalidation for all documentation updates. While lint checks pass, this has NOT been functionally tested. Please verify:

  1. API Compatibility: Confirm that invalidateByTag is the correct Next.js 15.5.4 API and has identical behavior to revalidateTag
  2. Functional Testing: Test cache invalidation in a preview deployment before merging
  3. Signature Match: Verify the function signature is compatible (currently called with just domain parameter)

Testing

  • ✅ Lint checks pass (biome, stylelint, yaml formatting)
  • ❌ No functional testing performed
  • ❌ No automated tests updated

Link to Devin run: https://app.devin.ai/sessions/b2516892bfed41638d97ecf163ceb7f3
Requested by: Deep Singhvi (@dsinghvi)

@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@vercel
Copy link
Contributor

vercel bot commented Oct 31, 2025

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

Project Deployment Preview Updated (UTC)
dev.ferndocs.com Ready Ready Preview Oct 31, 2025 5:28pm
fern-dashboard Ready Ready Preview Oct 31, 2025 5:28pm
fern-dashboard-dev Ready Ready Preview Oct 31, 2025 5:28pm
ferndocs.com Ready Ready Preview Oct 31, 2025 5:28pm
preview.ferndocs.com Ready Ready Preview Oct 31, 2025 5:28pm
prod-assets.ferndocs.com Ready Ready Preview Oct 31, 2025 5:28pm
prod.ferndocs.com Ready Ready Preview Oct 31, 2025 5:28pm
1 Skipped Deployment
Project Deployment Preview Updated (UTC)
fern-platform Ignored Ignored Oct 31, 2025 5:28pm


const { host, domain } = await props.params;
revalidateTag(domain);
invalidateByTag(domain);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Calling non-existent invalidateByTag function will cause a TypeError.
Severity: CRITICAL | Confidence: 1.00

🔍 Detailed Analysis

The application attempts to import and call invalidateByTag from next/cache at line 66. This function does not exist in the Next.js API. When the /api/fern-docs/revalidate endpoint is invoked, the call to invalidateByTag(domain) will result in a TypeError: invalidateByTag is not a function, causing the process to terminate.

💡 Suggested Fix

Replace invalidateByTag(domain) with the correct Next.js cache invalidation API, revalidateTag(domain), to ensure proper cache invalidation.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location:
packages/fern-docs/bundle/src/app/[host]/[domain]/api/fern-docs/revalidate/route.ts#L66

Potential issue: The application attempts to import and call `invalidateByTag` from
`next/cache` at line 66. This function does not exist in the Next.js API. When the
`/api/fern-docs/revalidate` endpoint is invoked, the call to `invalidateByTag(domain)`
will result in a `TypeError: invalidateByTag is not a function`, causing the process to
terminate.

Did we get this right? 👍 / 👎 to inform future reviews.

import { mapValues } from "es-toolkit/object";
import { escapeRegExp } from "es-toolkit/string";
import { revalidatePath, revalidateTag } from "next/cache";
import { invalidateByTag, revalidatePath } from "next/cache";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function invalidateByTag does not exist in Next.js 15.5.4's cache API. The correct function is revalidateTag, which is still being used in similar route files across the codebase.

View Details
📝 Patch Details
diff --git a/packages/fern-docs/bundle/src/app/[host]/[domain]/api/fern-docs/revalidate/route.ts b/packages/fern-docs/bundle/src/app/[host]/[domain]/api/fern-docs/revalidate/route.ts
index 298cd42fa..0e3d10ef0 100644
--- a/packages/fern-docs/bundle/src/app/[host]/[domain]/api/fern-docs/revalidate/route.ts
+++ b/packages/fern-docs/bundle/src/app/[host]/[domain]/api/fern-docs/revalidate/route.ts
@@ -29,7 +29,7 @@ import { getEnv, waitUntil } from "@vercel/functions";
 import { kv } from "@vercel/kv";
 import { mapValues } from "es-toolkit/object";
 import { escapeRegExp } from "es-toolkit/string";
-import { invalidateByTag, revalidatePath } from "next/cache";
+import { revalidateTag, revalidatePath } from "next/cache";
 import { type NextRequest, NextResponse } from "next/server";
 import { UnreachableCaseError } from "ts-essentials";
 import { getFaiClient } from "@/getFaiClient";
@@ -63,7 +63,7 @@ export async function GET(
     const start = performance.now();
 
     const { host, domain } = await props.params;
-    invalidateByTag(domain);
+    revalidateTag(domain);
 
     // delay to ensure invalidation propagates before cache is accessed
     await new Promise((resolve) => setTimeout(resolve, 500));

Analysis

Invalid function invalidateByTag imported from Next.js cache API

What fails: Route packages/fern-docs/bundle/src/app/[host]/[domain]/api/fern-docs/revalidate/route.ts imports invalidateByTag from next/cache, but this function doesn't exist in Next.js 15.5.4

How to reproduce:

cd packages/fern-docs/bundle
pnpm exec node -e "const { invalidateByTag } = require('next/cache'); console.log(typeof invalidateByTag);"
# Output: undefined

Result: TypeScript compilation error: '"next/cache"' has no exported member named 'invalidateByTag'. Did you mean 'revalidateTag'? Runtime error when endpoint is called: invalidateByTag is not a function

Expected: Should use revalidateTag function which is the correct Next.js cache invalidation API per Next.js documentation and matches usage in other route files in the codebase

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