Skip to content

Commit 6e0d016

Browse files
waleedlatif1claude
andcommitted
fix(kb): verify field type when reusing existing tag slots
Add fieldType check to the tag slot reuse logic so a connector with a matching displayName but different fieldType falls through to fresh slot allocation instead of silently reusing an incompatible slot. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent bcae263 commit 6e0d016

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

  • apps/sim/app/api/knowledge/[id]/connectors

apps/sim/app/api/knowledge/[id]/connectors/route.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,18 +172,21 @@ export async function POST(request: NextRequest, { params }: { params: Promise<{
172172
.select({
173173
tagSlot: knowledgeBaseTagDefinitions.tagSlot,
174174
displayName: knowledgeBaseTagDefinitions.displayName,
175+
fieldType: knowledgeBaseTagDefinitions.fieldType,
175176
})
176177
.from(knowledgeBaseTagDefinitions)
177178
.where(eq(knowledgeBaseTagDefinitions.knowledgeBaseId, knowledgeBaseId))
178179

179180
const usedSlots = new Set<string>(existingDefs.map((d) => d.tagSlot))
180-
const existingByName = new Map(existingDefs.map((d) => [d.displayName, d.tagSlot]))
181+
const existingByName = new Map(
182+
existingDefs.map((d) => [d.displayName, { tagSlot: d.tagSlot, fieldType: d.fieldType }])
183+
)
181184

182185
const defsNeedingSlots: typeof enabledDefs = []
183186
for (const td of enabledDefs) {
184-
const existingSlot = existingByName.get(td.displayName)
185-
if (existingSlot) {
186-
tagSlotMapping[td.id] = existingSlot
187+
const existing = existingByName.get(td.displayName)
188+
if (existing && existing.fieldType === td.fieldType) {
189+
tagSlotMapping[td.id] = existing.tagSlot
187190
} else {
188191
defsNeedingSlots.push(td)
189192
}

0 commit comments

Comments
 (0)