From eef59c74ee38288e89cc85234984831aa27a665e Mon Sep 17 00:00:00 2001 From: Codex Date: Sun, 7 Jun 2026 21:03:47 +0800 Subject: [PATCH] fix: replace hardcoded backend profile validation with isBackendProfile() The session creation route had a hardcoded check for only codex/deepseek/minimax-m3 profiles. Since ofcx-go was added to BackendProfile type and backend-profiles.ts spec list, the validation must use isBackendProfile() from the shared module so that adding new profiles only requires one data change, not scattered string checks. Refs pikasTech/HWLAB#1034 --- src/mgr/server.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mgr/server.ts b/src/mgr/server.ts index ee3b699..ff39a32 100644 --- a/src/mgr/server.ts +++ b/src/mgr/server.ts @@ -5,6 +5,7 @@ import type { AgentRunStore, ListQueueTasksInput, ListSessionsInput, SessionEven import { openAgentRunStoreFromEnv } from "./store.js"; import { AgentRunError, errorToJson } from "../common/errors.js"; import { asRecord, validateBackendProfile, validateCreateCommand, validateCreateQueueTask, validateCreateRun, validateQueueTaskState, validateSessionListState } from "../common/validation.js"; +import { isBackendProfile } from "../common/backend-profiles.js"; import type { ApiErrorBody, ApiOkBody, JsonRecord, JsonValue, RunEvent } from "../common/types.js"; import { createKubernetesRunnerJob } from "./kubernetes-runner-job.js"; import { dispatchQueueTask, refreshQueueTaskFromCore } from "./queue-dispatch.js"; @@ -187,7 +188,7 @@ async function route({ method, url, body, store, sourceCommit, runnerJobDefaults const tenantId = stringField(record, "tenantId"); const projectId = stringField(record, "projectId"); const backendProfileRaw = typeof record.backendProfile === "string" ? record.backendProfile : "codex"; - if (backendProfileRaw !== "codex" && backendProfileRaw !== "deepseek" && backendProfileRaw !== "minimax-m3") throw new AgentRunError("schema-invalid", `backendProfile ${backendProfileRaw} is not supported`, { httpStatus: 400 }); + if (!isBackendProfile(backendProfileRaw)) throw new AgentRunError("schema-invalid", `backendProfile ${backendProfileRaw} is not supported`, { httpStatus: 400 }); const conversationId = typeof record.conversationId === "string" ? record.conversationId : null; const codexRolloutSubdir = typeof record.codexRolloutSubdir === "string" && record.codexRolloutSubdir.length > 0 ? record.codexRolloutSubdir : "sessions"; const expiresAt = typeof record.expiresAt === "string" ? record.expiresAt : new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString();