From 5594ff45e1b39a91d2cce8ecace6865910968e4c Mon Sep 17 00:00:00 2001 From: Eugene Molodkin Date: Mon, 11 Nov 2024 14:42:30 +0100 Subject: [PATCH] wip: disallow unknown fields --- .../src/evaluation/test-definition.schema.ts | 24 +++++++++++-------- .../evaluation/test-definition.service.ee.ts | 5 ---- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/packages/cli/src/evaluation/test-definition.schema.ts b/packages/cli/src/evaluation/test-definition.schema.ts index 606233bcdd..ffb6d82ab5 100644 --- a/packages/cli/src/evaluation/test-definition.schema.ts +++ b/packages/cli/src/evaluation/test-definition.schema.ts @@ -1,13 +1,17 @@ import { z } from 'zod'; -export const testDefinitionCreateRequestBodySchema = z.object({ - name: z.string().min(1).max(255), - workflowId: z.string().min(1), - evaluationWorkflowId: z.string().min(1).optional(), -}); +export const testDefinitionCreateRequestBodySchema = z + .object({ + name: z.string().min(1).max(255), + workflowId: z.string().min(1), + evaluationWorkflowId: z.string().min(1).optional(), + }) + .strict(); -export const testDefinitionPatchRequestBodySchema = z.object({ - name: z.string().min(1).max(255).optional(), - evaluationWorkflowId: z.string().min(1).optional(), - annotationTagId: z.string().min(1).optional(), -}); +export const testDefinitionPatchRequestBodySchema = z + .object({ + name: z.string().min(1).max(255).optional(), + evaluationWorkflowId: z.string().min(1).optional(), + annotationTagId: z.string().min(1).optional(), + }) + .strict(); diff --git a/packages/cli/src/evaluation/test-definition.service.ee.ts b/packages/cli/src/evaluation/test-definition.service.ee.ts index ad96744ed9..18055f32bc 100644 --- a/packages/cli/src/evaluation/test-definition.service.ee.ts +++ b/packages/cli/src/evaluation/test-definition.service.ee.ts @@ -89,11 +89,6 @@ export class TestDefinitionService { await validateEntity(updatedTest); } - // Do not allow updating the workflow ID after test definition creation - if (attrs.workflowId) { - delete attrs.workflowId; - } - // Check if the annotation tag exists if (attrs.annotationTagId) { const annotationTagExists = await this.annotationTagRepository.exists({