Skip to content

Commit c7ca90c

Browse files
waleedlatif1claude
andauthored
fix(kb): fix Linear connector GraphQL type errors and tag slot reuse (#3919)
* fix(kb): fix Linear connector GraphQL type errors and tag slot reuse * fix(kb): simplify tag slot reuse, revert Linear GraphQL types to String Clean up newTagSlotMapping into direct assignment, remove unnecessary comment, and revert ID! back to String! to match Linear SDK types. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(kb): use ID! type for Linear GraphQL filter variables * 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> * fix(kb): enable search on connector selector dropdowns --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a9c9ed8 commit c7ca90c

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

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

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,19 +162,39 @@ export async function POST(request: NextRequest, { params }: { params: Promise<{
162162
}
163163

164164
const tagSlotMapping: Record<string, string> = {}
165+
let newTagSlots: Record<string, string> = {}
165166

166167
if (connectorConfig.tagDefinitions?.length) {
167168
const disabledIds = new Set((sourceConfig.disabledTagIds as string[] | undefined) ?? [])
168169
const enabledDefs = connectorConfig.tagDefinitions.filter((td) => !disabledIds.has(td.id))
169170

170171
const existingDefs = await db
171-
.select({ tagSlot: knowledgeBaseTagDefinitions.tagSlot })
172+
.select({
173+
tagSlot: knowledgeBaseTagDefinitions.tagSlot,
174+
displayName: knowledgeBaseTagDefinitions.displayName,
175+
fieldType: knowledgeBaseTagDefinitions.fieldType,
176+
})
172177
.from(knowledgeBaseTagDefinitions)
173178
.where(eq(knowledgeBaseTagDefinitions.knowledgeBaseId, knowledgeBaseId))
174179

175180
const usedSlots = new Set<string>(existingDefs.map((d) => d.tagSlot))
176-
const { mapping, skipped: skippedTags } = allocateTagSlots(enabledDefs, usedSlots)
181+
const existingByName = new Map(
182+
existingDefs.map((d) => [d.displayName, { tagSlot: d.tagSlot, fieldType: d.fieldType }])
183+
)
184+
185+
const defsNeedingSlots: typeof enabledDefs = []
186+
for (const td of enabledDefs) {
187+
const existing = existingByName.get(td.displayName)
188+
if (existing && existing.fieldType === td.fieldType) {
189+
tagSlotMapping[td.id] = existing.tagSlot
190+
} else {
191+
defsNeedingSlots.push(td)
192+
}
193+
}
194+
195+
const { mapping, skipped: skippedTags } = allocateTagSlots(defsNeedingSlots, usedSlots)
177196
Object.assign(tagSlotMapping, mapping)
197+
newTagSlots = mapping
178198

179199
for (const name of skippedTags) {
180200
logger.warn(`[${requestId}] No available slots for "${name}"`)
@@ -208,7 +228,7 @@ export async function POST(request: NextRequest, { params }: { params: Promise<{
208228
throw new Error('Knowledge base not found')
209229
}
210230

211-
for (const [semanticId, slot] of Object.entries(tagSlotMapping)) {
231+
for (const [semanticId, slot] of Object.entries(newTagSlots)) {
212232
const td = connectorConfig.tagDefinitions!.find((d) => d.id === semanticId)!
213233
await createTagDefinition(
214234
{

apps/sim/app/workspace/[workspaceId]/knowledge/[id]/components/add-connector-modal/components/connector-selector-field.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ export function ConnectorSelectorField({
7979
options={comboboxOptions}
8080
value={value || undefined}
8181
onChange={onChange}
82+
searchable
83+
searchPlaceholder={`Search ${field.title.toLowerCase()}...`}
8284
placeholder={
8385
!credentialId
8486
? 'Connect an account first'

apps/sim/connectors/linear/linear.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const ISSUE_FIELDS = `
119119
`
120120

121121
const ISSUE_BY_ID_QUERY = `
122-
query GetIssue($id: String!) {
122+
query GetIssue($id: ID!) {
123123
issue(id: $id) {
124124
${ISSUE_FIELDS}
125125
}
@@ -147,13 +147,13 @@ function buildIssuesQuery(sourceConfig: Record<string, unknown>): {
147147
const variables: Record<string, unknown> = {}
148148

149149
if (teamId) {
150-
varDefs.push('$teamId: String!')
150+
varDefs.push('$teamId: ID!')
151151
filterClauses.push('team: { id: { eq: $teamId } }')
152152
variables.teamId = teamId
153153
}
154154

155155
if (projectId) {
156-
varDefs.push('$projectId: String!')
156+
varDefs.push('$projectId: ID!')
157157
filterClauses.push('project: { id: { eq: $projectId } }')
158158
variables.projectId = projectId
159159
}

0 commit comments

Comments
 (0)