diff --git a/.server-changes/deprecate-v3-cli-deploys.md b/.server-changes/deprecate-v3-cli-deploys.md new file mode 100644 index 0000000000..72040b4c5e --- /dev/null +++ b/.server-changes/deprecate-v3-cli-deploys.md @@ -0,0 +1,6 @@ +--- +area: webapp +type: breaking +--- + +Add server-side deprecation gate for deploys from v3 CLI versions (gated by `DEPRECATE_V3_CLI_DEPLOYS_ENABLED`). v4 CLI deploys are unaffected. diff --git a/apps/webapp/app/env.server.ts b/apps/webapp/app/env.server.ts index 8d72b2e51b..b839af6eb5 100644 --- a/apps/webapp/app/env.server.ts +++ b/apps/webapp/app/env.server.ts @@ -348,6 +348,12 @@ const EnvironmentSchema = z .int() .default(60 * 1000 * 15), // 15 minutes + // When enabled, reject deploys made by v3 CLI versions (i.e. payloads that + // omit the `type` field). v4 CLI versions always send `type` ("MANAGED" or "V1"), + // so they are unaffected. Defaults to off so detection can run in + // log-only mode before enforcement. + DEPRECATE_V3_CLI_DEPLOYS_ENABLED: z.string().default("0"), + OBJECT_STORE_BASE_URL: z.string().optional(), OBJECT_STORE_BUCKET: z.string().optional(), OBJECT_STORE_ACCESS_KEY_ID: z.string().optional(), diff --git a/apps/webapp/app/v3/services/initializeDeployment.server.ts b/apps/webapp/app/v3/services/initializeDeployment.server.ts index 987925aa70..9ecc25f994 100644 --- a/apps/webapp/app/v3/services/initializeDeployment.server.ts +++ b/apps/webapp/app/v3/services/initializeDeployment.server.ts @@ -59,6 +59,28 @@ export class InitializeDeploymentService extends BaseService { }; } + // v4 CLI versions always send `payload.type` ("MANAGED" or "V1"). v3 CLI + // versions never do, so the absence of `type` is a reliable signal that + // the request came from a 3.x CLI. Detection always runs (so we can + // observe how many deploys are still using v3), enforcement is gated + // behind DEPRECATE_V3_CLI_DEPLOYS_ENABLED so it can be rolled out safely. + if (!payload.type) { + const enforced = env.DEPRECATE_V3_CLI_DEPLOYS_ENABLED === "1"; + + logger.warn("Detected deploy from deprecated v3 CLI", { + environmentId: environment.id, + projectId: environment.projectId, + organizationId: environment.project.organizationId, + enforced, + }); + + if (enforced) { + throw new ServiceValidationError( + "The trigger.dev CLI v3 is no longer supported for deployments. Please upgrade your project to v4: https://trigger.dev/docs/migrating-from-v3" + ); + } + } + if (payload.type === "UNMANAGED") { throw new ServiceValidationError("UNMANAGED deployments are not supported"); }