calcom/cal.diy · error · HttpCode

Credentials not valid

Error message

Credentials not valid

What it means

Thrown when the stored credential key fails albyCredentialKeysSchema validation, which requires account_id, account_email, account_lightning_address, webhook_endpoint_id, and webhook_endpoint_secret. The credential row exists but its key JSON is incomplete or malformed. The parse error is console.error'd before the throw. Surfaced as HTTP 500 because the data is server-owned, not caller-controlled.

Source

Thrown at packages/app-store/alby/api/webhook.ts:81

                  where: {
                    type: "alby_payment",
                  },
                },
              },
            },
          },
        },
      },
    });

    if (!payment) throw new HttpCode({ statusCode: 204, message: "Payment not found" });
    const key = payment.booking?.user?.credentials?.[0].key;
    if (!key) throw new HttpCode({ statusCode: 204, message: "Credentials not found" });

    const parseCredentials = albyCredentialKeysSchema.safeParse(key);
    if (!parseCredentials.success) {
      console.error(parseCredentials.error);
      throw new HttpCode({ statusCode: 500, message: "Credentials not valid" });
    }

    const credentials = parseCredentials.data;

    const albyInvoice = await parseInvoice(bodyAsString, parsedHeaders, credentials.webhook_endpoint_secret);
    if (!albyInvoice) throw new HttpCode({ statusCode: 204, message: "Invoice not found" });
    if (albyInvoice.amount !== payment.amount) {
      throw new HttpCode({ statusCode: 400, message: "invoice amount does not match payment amount" });
    }

    const traceContext = distributedTracing.createTrace("alby_webhook", {
      meta: { paymentId: payment.id, bookingId: payment.bookingId },
    });
    return await handlePaymentSuccess({
      paymentId: payment.id,
      bookingId: payment.bookingId,
      appSlug: "alby",
      traceContext,

View on GitHub (pinned to 176037d0af)

Solutions

  1. Re-run the Alby setup flow to regenerate a complete credential key.
  2. Inspect the stored credential.key JSON for any missing required fields.
  3. If a new required field was introduced, update existing credentials or run a migration backfill.
Defensive patterns

Strategy: type-guard

Validate before calling

const parsed = albyCredentialKeysSchema.safeParse(key);
if (!parsed.success) {
  // prompt the user to re-run Alby setup to repopulate the credential key
}

Type guard

const isValidAlbyCredential = (k: unknown) => albyCredentialKeysSchema.safeParse(k).success;

Prevention

When it happens

Trigger: Setup flow was interrupted before all fields were persisted; a schema migration introduced a new required field; manual DB edit corrupted the key JSON.

Common situations: Partial setup; legacy credential from before webhook_endpoint_secret was introduced; credentials imported/migrated from another instance without all fields.

Related errors


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