From 67382a831e4d299c62ddac5f381ed1f1faa27e0d Mon Sep 17 00:00:00 2001 From: Max Holland Date: Wed, 2 Oct 2024 20:54:21 +0100 Subject: [PATCH] fix validator lookup --- packages/api/src/controllers/generate.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/api/src/controllers/generate.ts b/packages/api/src/controllers/generate.ts index fb2906a37..17ea64f9b 100644 --- a/packages/api/src/controllers/generate.ts +++ b/packages/api/src/controllers/generate.ts @@ -15,6 +15,7 @@ import { BadRequestError } from "../store/errors"; import { fetchWithTimeout, kebabToCamel } from "../util"; import { experimentSubjectsOnly } from "./experiment"; import { pathJoin2 } from "./helpers"; +import validators from "../schema/validators"; const AI_GATEWAY_TIMEOUT = 10 * 60 * 1000; // 10 minutes const RATE_LIMIT_WINDOW = 60 * 1000; // 1 minute @@ -181,6 +182,9 @@ function registerGenerateHandler( if (isJSONReq) { payloadParsers = [validatePost(`${camelType}Params`)]; } else { + if (!validators[`Body_gen${camelType}`]) { + camelType = type.toUpperCase(); + } payloadParsers = [ multipart.any(), validateFormData(`Body_gen${camelType}`),