calcom/cal.diy · error · Error

Unable to create user credential for type ${appType}

Error message

Unable to create user credential for type ${appType}

What it means

Thrown by createDefaultInstallation when prisma.credential.create returns a falsy value. In practice Prisma's create throws on failure rather than returning null, so this guard is defensive and rarely fires. If it does, it means the DB layer returned an unexpected empty result for the insert.

Source

Thrown at packages/app-store/_utils/installation.ts:55

  key = {},
  teamId,
  billingCycleStart,
  paymentStatus,
  subscriptionId,
}: InstallationArgs) {
  const installation = await prisma.credential.create({
    data: {
      type: appType,
      key,
      ...(teamId ? { teamId } : { userId: user.id }),
      appId: slug,
      subscriptionId,
      paymentStatus,
      billingCycleStart,
    },
  });
  if (!installation) {
    throw new Error(`Unable to create user credential for type ${appType}`);
  }
  return installation;
}

View on GitHub (pinned to 176037d0af)

Solutions

  1. Check server logs for the underlying Prisma behavior; a real create failure usually throws first.
  2. If using Prisma extensions/middleware, ensure they return the created record.
  3. Verify DB connectivity and that the credential table accepts the insert (constraints, column types).
  4. In tests, make sure the mocked prisma.credential.create resolves to a truthy object.

Example fix

// before - mock returns undefined
prisma.credential.create = jest.fn().mockResolvedValue(undefined);
// after - mock returns the created record
prisma.credential.create = jest.fn().mockResolvedValue({ id: 1, type: 'zoom', appId: 'zoom' });
Defensive patterns

Strategy: try-catch

Validate before calling

null

Type guard

null

Try / catch

try {
  return await prisma.credential.create({ data: { ... } });
} catch (dbError) {
  // Prisma throws on real failures; surface the actual DB error
  throw new Error(`Credential create failed: ${dbError.message}`);
}

Prevention

When it happens

Trigger: prisma.credential.create completes without throwing but resolves to null/undefined. Theoretically possible with a custom Prisma client interceptor, a DB driver quirk, or a malformed input that Prisma silently coerces to nothing. Almost never seen with stock Prisma.

Common situations: A Prisma extension/middleware that swallows the insert and returns null; a DB connection that dropped mid-write in a way Prisma did not surface as a throw; extremely rare driver bug; testing with a mocked prisma that returns undefined.

Related errors


AI-assisted analysis of calcom/cal.diy@176037d0af (2026-08-12). Data as JSON: /api/errors/f574f740f2d48baa. Report an issue: GitHub.