langfuse/langfuse · error · Error
Failed to create prompt
Error message
Failed to create prompt
What it means
Thrown when a Prisma create() for a new prompt returns a falsy result in the promptCreate mutation. Prisma create() practically never returns null, so hitting this means the create call was skipped, returned early, or an unexpected runtime shape occurred. It is a defensive guard, not an expected business error.
Source
Thrown at web/src/features/prompts/server/routers/promptRouter.ts:343
projectId: input.projectId,
scope: "promptProtectedLabels:CUD",
forbiddenErrorMessage: `You don't have permission to create a prompt with a protected label. Please contact your project admin for assistance.\n\n Protected labels are: ${protectedLabels.join(", ")}`,
});
}
const prompt = await createPrompt({
...input,
prisma: ctx.prisma,
createdBy: ctx.session.user.id,
user: {
id: ctx.session.user.id,
name: ctx.session.user.name ?? null,
email: ctx.session.user.email ?? null,
},
});
if (!prompt) {
throw new Error("Failed to create prompt");
}
await auditLog(
{
session: ctx.session,
resourceType: "prompt",
resourceId: prompt.id,
action: "create",
after: prompt,
},
ctx.prisma,
);
return prompt;
}),
duplicatePrompt: protectedProjectProcedure
.input(
z.object({View on GitHub (pinned to 59d92c7cf3)
Solutions
- Check server logs for the surrounding Prisma call and any DB errors just before this throw
- Verify the Prisma client version and that generated client matches packages/shared/prisma schema
- If reproducible only in tests, ensure the test prisma mock returns a truthy object for prompt.create
Defensive patterns
Strategy: try-catch
Try / catch
try {
await trpc.prompts.create.mutate(input);
} catch (e) {
if (e instanceof TRPCClientError && e.message === 'Failed to create prompt') {
// surface as internal error, check server logs
}
throw e;
} Prevention
- Keep prisma client and generated code in sync with schema
- In tests, make prisma.prompt.create mocks return a real object
When it happens
Trigger: Calling the tRPC mutation prompts.create (promptRouter.ts:343) with valid session/project and the underlying prisma.prompt.create unexpectedly returning undefined.
Common situations: Almost never fires in practice; if it does, suspect a Prisma version change, a mocked/stubbed prisma client in tests, or a database write that silently failed.
Related errors
- Failed to duplicate prompt: ${input.promptId}
- INTERNAL_SERVER_ERROR
- Failed to fetch upserted model
- CONFLICT
- NOT_FOUND
AI-assisted analysis of langfuse/langfuse@59d92c7cf3 (2026-08-27).
Data as JSON: /api/errors/6f5b180373e327ab.
Report an issue: GitHub.