From a562d5403e1047de29c4c29a62ebe83ce26befca Mon Sep 17 00:00:00 2001 From: Harold Kim Date: Thu, 9 Jul 2026 09:22:35 +0000 Subject: [PATCH] fix: centralize environment delete active statuses Share the active custom image setup status list between the environment service and delete route so the route guard cannot drift from the blast-radius query. Keep the route test mock aligned with the new service export. Co-Authored-By: Paperclip --- server/src/__tests__/environment-routes.test.ts | 1 + server/src/routes/environments.ts | 7 +++++-- server/src/services/environments.ts | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/server/src/__tests__/environment-routes.test.ts b/server/src/__tests__/environment-routes.test.ts index a97bca1a3d9..96bd15a5955 100644 --- a/server/src/__tests__/environment-routes.test.ts +++ b/server/src/__tests__/environment-routes.test.ts @@ -100,6 +100,7 @@ vi.mock("../services/secrets.js", () => ({ })); vi.mock("../services/environments.js", () => ({ + ACTIVE_CUSTOM_IMAGE_SETUP_STATUSES: ["starting", "waiting_for_user", "capturing"], environmentService: () => mockEnvironmentService, })); diff --git a/server/src/routes/environments.ts b/server/src/routes/environments.ts index 11521abb746..cf2247f8f6a 100644 --- a/server/src/routes/environments.ts +++ b/server/src/routes/environments.ts @@ -44,11 +44,14 @@ import { listReadyPluginEnvironmentDrivers } from "../services/plugin-environmen import { getConfiguredSecretProvider } from "../secrets/configured-provider.js"; import { assertBoardOrgAccess, getActorInfo } from "./authz.js"; import type { PluginWorkerManager } from "../services/plugin-worker-manager.js"; -import { environmentService } from "../services/environments.js"; +import { + ACTIVE_CUSTOM_IMAGE_SETUP_STATUSES, + environmentService, +} from "../services/environments.js"; import { environmentRuntimeService } from "../services/environment-runtime.js"; const ACTIVE_CUSTOM_IMAGE_SETUP_STATUSES_FOR_DELETE: ReadonlySet = - new Set(["starting", "waiting_for_user", "capturing"]); + new Set(ACTIVE_CUSTOM_IMAGE_SETUP_STATUSES); export function environmentRoutes( db: Db, diff --git a/server/src/services/environments.ts b/server/src/services/environments.ts index b696544b4ed..57092d68648 100644 --- a/server/src/services/environments.ts +++ b/server/src/services/environments.ts @@ -44,7 +44,7 @@ const DEFAULT_KUBERNETES_ENVIRONMENT_DESCRIPTION = const KUBERNETES_PROVIDER_KEY = "kubernetes"; /** Metadata marker for the company's managed-by-config Kubernetes sandbox environment. */ const KUBERNETES_MANAGED_MARKER = "managedKubernetesSandbox"; -const ACTIVE_CUSTOM_IMAGE_SETUP_STATUSES = ["starting", "waiting_for_user", "capturing"] as const; +export const ACTIVE_CUSTOM_IMAGE_SETUP_STATUSES = ["starting", "waiting_for_user", "capturing"] as const; /** * Configuration accepted by `ensureKubernetesEnvironment`. Mirrors the keys of