From 3026e3aeb72829bd9da0b458b6ebe7681d7f3b56 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Sat, 8 Aug 2026 13:31:41 -0700 Subject: [PATCH] chore(knowledge): document the tag-definition field-type runtime check The create-tag route validates fieldType at runtime because the contract keeps it a plain string. Its sibling bulk route already explains why; without the same note here the check reads as redundant with the contract and invites removal. --- apps/sim/app/api/knowledge/[id]/tag-definitions/route.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/sim/app/api/knowledge/[id]/tag-definitions/route.ts b/apps/sim/app/api/knowledge/[id]/tag-definitions/route.ts index 811077245b3..d7944330903 100644 --- a/apps/sim/app/api/knowledge/[id]/tag-definitions/route.ts +++ b/apps/sim/app/api/knowledge/[id]/tag-definitions/route.ts @@ -76,6 +76,11 @@ export const POST = withRouteHandler( if (!parsed.success) return parsed.response const validatedData = parsed.data.body + /** + * Defense-in-depth runtime check: the contract types `fieldType` as a plain + * string because tightening to the field-type enum cascades into UI form + * state types. Cast here to allow `includes` to accept the wider input. + */ if (!(SUPPORTED_FIELD_TYPES as readonly string[]).includes(validatedData.fieldType)) { return NextResponse.json( { error: 'Invalid request data', details: 'Invalid field type' },