Skip to content

Commit 6ed7a76

Browse files
thomasballingerConvex, Inc.
authored andcommitted
Better error message when using codegen with a preview deploy key (#40898)
GitOrigin-RevId: 207f37b3a35dffb626d9c5edab23a75db92db6db
1 parent bb4c051 commit 6ed7a76

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

npm-packages/convex/src/cli/lib/components.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@ export async function runCodegen(
9090
);
9191

9292
if (ctx.fs.exists(componentRootPath)) {
93+
// Early exit for a better error message trying to use a preview key.
94+
if (deploymentSelection.kind === "preview") {
95+
return await ctx.crash({
96+
exitCode: 1,
97+
errorType: "invalid filesystem data",
98+
printedMessage: `Codegen requires an existing deployment so doesn't support CONVEX_DEPLOY_KEY.\nGenerate code in dev and commit it to the repo instead.\nhttps://docs.convex.dev/understanding/best-practices/other-recommendations#check-generated-code-into-version-control`,
99+
});
100+
}
101+
93102
const selectionWithinProject =
94103
deploymentSelectionWithinProjectFromOptions(options);
95104
const credentials = await loadSelectedDeploymentCredentials(

0 commit comments

Comments
 (0)