RubenR
Convex Community16mo ago
12 replies
Ruben

Preview deployment fails with: '✖ Please set CONVEX_DEPLOY_KEY to a new key which you can [...]'

Since last week I'm unable to make preview deployments for my Vercel app. The deployment is able to deploy all convex functions and even prints: Ran "npm run build" with environment variable "NEXT_PUBLIC_CONVEX_URL" set.

However after logging ✔ Deployed Convex functions to https:[...].convex.cloud it errors with the following error message:

✖ Please set CONVEX_DEPLOY_KEY to a new key which you can find on your Convex dashboard.

Which seems odd as the functions itself have been successfully been deployed so it would seem the CONVEX_DEPLOY_KEY is valid. This error seems to originate from here: https://github.com/get-convex/convex-backend/blob/aef1e1bd991d0aa46e530f3dfc88a4e8335aca7d/npm-packages/convex/src/cli/lib/deployment.ts#L181

A small snippet from the copied github link:

export async function deploymentNameFromAdminKeyOrCrash(
  ctx: Context,
  adminKey: string,
) {
  const deploymentName = deploymentNameFromAdminKey(adminKey);
  if (deploymentName === null) {
    return await ctx.crash({
      exitCode: 1,
      errorType: "fatal",
      printedMessage: `Please set ${CONVEX_DEPLOY_KEY_ENV_VAR_NAME} to a new key which you can find on your Convex dashboard.`,
    });
  }
  return deploymentName;
}

function deploymentNameFromAdminKey(adminKey: string) {
  const parts = adminKey.split("|");
  if (parts.length === 1) {
    return null;
  }
  if (isPreviewDeployKey(adminKey)) {
    // Preview deploy keys do not contain a deployment name.
    return null;
  }
  return stripDeploymentTypePrefix(parts[0]);
}


Here deploymentNameFromAdminKeyOrCrash will throw the specified error when it's called with preview adminKey, which it probably does because this is a preview deployment.

Hopefully someone can help us out!
GitHub
The Convex open-source backend. Contribute to get-convex/convex-backend development by creating an account on GitHub.
convex-backend/npm-packages/convex/src/cli/lib/deployment.ts at aef...
Was this page helpful?