Skip to content

Commit 50858d4

Browse files
committed
fix(knowledge): validate UUID format in kbTableName
1 parent 507cc36 commit 50858d4

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

apps/sim/lib/knowledge/dynamic-tables.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ function isTagSlotKey(key: string): key is AllTagSlot {
2222

2323
/** Convert a KB UUID to a valid Postgres table name */
2424
export function kbTableName(kbId: string): string {
25+
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(kbId)) {
26+
throw new Error(`Invalid knowledge base ID: "${kbId}". Must be a UUID.`)
27+
}
2528
return `kb_embeddings_${kbId.replace(/-/g, '_')}`
2629
}
2730

0 commit comments

Comments
 (0)