diff --git a/apps/webapp/app/v3/services/createTaskRunAttempt.server.ts b/apps/webapp/app/v3/services/createTaskRunAttempt.server.ts index 90ad49273..91dc5ccad 100644 --- a/apps/webapp/app/v3/services/createTaskRunAttempt.server.ts +++ b/apps/webapp/app/v3/services/createTaskRunAttempt.server.ts @@ -16,14 +16,10 @@ export class CreateTaskRunAttemptService extends BaseService { run: TaskRun; attempt: TaskRunAttempt; }> { - let environment: AuthenticatedEnvironment | undefined = env; + const environment = env ?? (await getAuthenticatedEnvironmentFromRun(runId, this._prisma)); if (!environment) { - environment = await getAuthenticatedEnvironmentFromRun(runId, this._prisma); - - if (!environment) { - throw new ServiceValidationError("Environment not found", 404); - } + throw new ServiceValidationError("Environment not found", 404); } const isFriendlyId = runId.startsWith("run_");