calcom/cal.diy · info · Error
Unable to create user credential for giphy
Error message
Unable to create user credential for giphy
What it means
Thrown if `prisma.credential.create` returns a falsy value. Per Prisma's contract, `create` either returns the created row or throws (e.g. P2002 unique-constraint → `getServerErrorFromPrismaError` maps to 400); it never returns null. This branch is therefore effectively unreachable defensive code, and were it to fire it would surface as HTTP 500 because it is a plain `Error`. Real create failures are reported as Prisma errors (400), not via this message.
Source
Thrown at packages/app-store/giphy/api/add.ts:45
const alreadyInstalled = await prisma.credential.findFirst({
where: {
type: appType,
...credentialOwner,
},
});
if (alreadyInstalled) {
throw new Error("Already installed");
}
const installation = await prisma.credential.create({
data: {
type: appType,
key: {},
...credentialOwner,
appId: "giphy",
},
});
if (!installation) {
throw new Error("Unable to create user credential for giphy");
}
} catch (error: unknown) {
const httpError = getServerErrorFromUnknown(error);
return res.status(httpError.statusCode).json({ message: httpError.message });
}
return res.status(200).json({ url: getInstalledAppPath({ variant: "other", slug: "giphy" }) });
}
View on GitHub (pinned to 176037d0af)
Solutions
- If you encounter this in logs, suspect mocking/stubbing of `prisma.credential.create`; the real failure path is the Prisma exception, not this branch.
- Remove the dead `if (!installation)` check (Prisma guarantees a returned record) to avoid misleading 500 semantics, or convert it to an explicit `HttpError({ statusCode: 500 })` assertion if kept.
- For genuine install failures, inspect the Prisma error code in the surrounding `catch` (P2002 = duplicate, P2003 = FK, etc.).
Defensive patterns
Strategy: try-catch
Try / catch
// The branch is unreachable; real failures surface as Prisma errors in the surrounding catch.
// Handle those explicitly instead of expecting this message.
try {
await prisma.credential.create({
data: { type: "giphy_other", key: {}, ...credentialOwner, appId: "giphy" },
});
} catch (error) {
if (error instanceof Prisma.PrismaClientKnownRequestError && error.code === "P2002") {
// duplicate install — handle as 'already installed'
} else {
throw error; // getServerErrorFromUnknown maps P2003/P2025/etc. appropriately
}
} Prevention
- Do not stub `prisma.credential.create` to return undefined in tests — that is the only way to reach this branch.
- Rely on Prisma's throw-on-failure contract; do not add null-checks that imply create can silently fail.
- If this message appears in production logs, suspect a mocked client or a non-Prisma datasource impersonating the credential model.
When it happens
Trigger: Only reachable if `prisma.credential.create` returned `null`/`undefined` — which contradicts Prisma's documented behavior. In practice never hit; the only realistic way to trigger it is a test that stubs/mocks `create` to return undefined.
Common situations: A unit test mocks `prisma.credential.create` to resolve to `undefined`; otherwise not observed in production. Any genuine DB failure surfaces earlier as a thrown Prisma error caught at line 47.
Related errors
- Already installed
- Unable to create user credential for Alby
- Missing Giphy api_key
- Email, code, and user ID are required
- Stripe app not found
AI-assisted analysis of calcom/cal.diy@176037d0af (2026-08-12).
Data as JSON: /api/errors/8385ea773771ca88.
Report an issue: GitHub.