Link to the code that reproduces this issue
https://gitlab.com/khemeri.med.khalil/test-revalidation
To Reproduce
Created an api revalidation endpoint to handle single post revalidation from webhooks
and this is the code app/api/revalidate/post/route.ts :
import { NextRequest, NextResponse } from "next/server";
import { revalidatePath } from "next/cache";
export async function POST(request: NextRequest) {
const body = await request.json();
console.log("post revalidation body : ", JSON.stringify(body));
revalidatePath("/post/" + body?.slug?.current);
return NextResponse.json({ revalidated: true, now: Date.now() });
}
Describe the Bug
so instead of working normally or getting an error related to revalidatePath , I got an error that seems related to revalidateTag :
I got this error after triggering a webhook to vercel, local prod mode no issue detected :
post revalidation body :
{"_id":"60e008f3-5a71-486f-a645-10ade5630450","slug":{"current":"how-to-create-a-revalidation-api-endpoint-in-next-js-using-the-app-router","_type":"slug"}} Failed to revalidate tag post/how-to-create-a-revalidation-api-endpoint-in-next-js-using-the-app-router Error: Request failed with status 500. at FetchCache.revalidateTag (/var/task/node_modules/next/dist/server/lib/incremental-cache/fetch-cache.js:92:23) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Promise.all (index 0) at async /var/task/.next/server/chunks/3616.js:2786:25
Expected Behavior
returned error should be related to revalidatePath not to revalidateTag
This is the repo ( no special code included ) :
I've made a deploy on vercel if that usefull : https://test-revalidation.vercel.app/
Update : ( problem found in the revalidationPath() !)
After conducting several tests, I have found that including more than 58 characters in the [slug] parameter will produce the error:
case 1 : ?path=understanding-inversion-of-control-dependency-inversion-pr === no problem (58 char)
case 2 : ?path=understanding-inversion-of-control-dependency-inversion-pri === Error thrown (59 char) addded the "i" char.
I created get method to test the revalidatePath()
1.Get : problem detected on vercel /api/revalidate?path=

Vercel Team Replied :
We have a fix going out for the unexpected 500 issue and are still investigating single path revalidate.
Last check :
There is no error throwing but revalidation still not working.
About khemeri mohamed khalil
Full-stack JavaScript developer with a passion for building scalable robust web applications using modern technologies. With expertise in both front-end and back-end development
Always eager to share knowledge and provide useful tips and insights for other developers in the community.