Skip to content

Commit 11b9392

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 2a8fcb9 commit 11b9392

File tree

1 file changed

+7
-4
lines changed
  • apps/sim/app/api/knowledge/[id]/connectors

1 file changed

+7
-4
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,21 @@ export async function POST(request: NextRequest, { params }: { params: Promise<{
161161
.select({
162162
tagSlot: knowledgeBaseTagDefinitions.tagSlot,
163163
displayName: knowledgeBaseTagDefinitions.displayName,
164+
fieldType: knowledgeBaseTagDefinitions.fieldType,
164165
})
165166
.from(knowledgeBaseTagDefinitions)
166167
.where(eq(knowledgeBaseTagDefinitions.knowledgeBaseId, knowledgeBaseId))
167168

168169
const usedSlots = new Set<string>(existingDefs.map((d) => d.tagSlot))
169-
const existingByName = new Map(existingDefs.map((d) => [d.displayName, d.tagSlot]))
170+
const existingByName = new Map(
171+
existingDefs.map((d) => [d.displayName, { tagSlot: d.tagSlot, fieldType: d.fieldType }])
172+
)
170173

171174
const defsNeedingSlots: typeof enabledDefs = []
172175
for (const td of enabledDefs) {
173-
const existingSlot = existingByName.get(td.displayName)
174-
if (existingSlot) {
175-
tagSlotMapping[td.id] = existingSlot
176+
const existing = existingByName.get(td.displayName)
177+
if (existing && existing.fieldType === td.fieldType) {
178+
tagSlotMapping[td.id] = existing.tagSlot
176179
} else {
177180
defsNeedingSlots.push(td)
178181
}

0 commit comments

Comments
 (0)