Missing Revalidation
Server actions that change data with no revalidatePath or revalidateTag
warningReliability
missing-revalidationWhy this matters
After a server action mutates data, the page still shows stale cached content unless you call revalidatePath or revalidateTag. Users think their action didn't work.
Example
app/actions/posts.ts"use server";
export async function updateTitle(id: string, title: string) {
await db.post.update({
where: { id },
data: { title },
});
// Page still shows the old title!
}app/actions/posts.ts"use server";
import { revalidatePath } from "next/cache";
export async function updateTitle(id: string, title: string) {
await db.post.update({
where: { id },
data: { title },
});
revalidatePath("/posts");
}How to fix
Call revalidatePath() or revalidateTag() after every server action that writes to the database, so cached pages show fresh data.
Reference
- In the output
- Findings carry
"ruleId": "missing-revalidation"in--jsonand the same id in SARIF and in the terminal. - Silence one line
// prodlint-disable-next-line missing-revalidation- Silence a whole file
// prodlint-disable missing-revalidationat the top of the file- How it works
- Matches text patterns. Source on GitHub