Skip to content

Commit 9bd72ce

Browse files
committed
fix(kb-connectors): GCal externalId on config downgrade, Slack silent skip, valuesEqual order
- google-calendar getDocument: derive isMultiCalendar from the externalId's `:` separator instead of the current config count. Prevents duplicates when a user downgrades from multi to single calendar — previously the returned doc lost its `calendarId:` prefix and was treated as a new row by the sync engine, orphaning the original. - slack listDocuments: throw on unresolvable channel instead of silently skipping. Matches MS Teams behaviour. Silent skip would let the sync engine orphan-delete the previously indexed channel content if a bot was removed or a channel was archived/renamed mid-life. - edit-connector-modal valuesEqual: order-insensitive comparison for multi- select arrays via Set membership. Multi-select UI doesn't guarantee insertion order matches the server-returned order, so `["A","B"]` vs `["B","A"]` would otherwise flag false unsaved changes.
1 parent e6d8ccd commit 9bd72ce

3 files changed

Lines changed: 23 additions & 7 deletions

File tree

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,13 @@ function valuesEqual(a: unknown, b: unknown): boolean {
9999
const arrA = toArray(a) ?? []
100100
const arrB = toArray(b) ?? []
101101
if (arrA.length !== arrB.length) return false
102-
for (let i = 0; i < arrA.length; i++) {
103-
if (arrA[i] !== arrB[i]) return false
104-
}
105-
return true
102+
/**
103+
* Order-insensitive: the multi-select UI does not guarantee insertion order
104+
* matches the server-returned order, so `["PROD","ENG"]` and `["ENG","PROD"]`
105+
* should be treated as equal to avoid a false unsaved-changes state.
106+
*/
107+
const setA = new Set(arrA)
108+
return arrB.every((v) => setA.has(v))
106109
}
107110
return a === b
108111
}

apps/sim/connectors/google-calendar/google-calendar.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,16 @@ export const googleCalendarConnector: ConnectorConfig = {
455455
*/
456456
const parsedCalendarIds = parseMultiValue(sourceConfig.calendarId)
457457
const calendarIds = parsedCalendarIds.length > 0 ? parsedCalendarIds : ['primary']
458-
const isMultiCalendar = calendarIds.length > 1
459458

459+
/**
460+
* Derive `isMultiCalendar` from the externalId itself, not from the current
461+
* config. If a row was synced under a multi-calendar config and the user
462+
* later removed calendars, the row's externalId still has the prefix —
463+
* returning a doc without the prefix would mint a duplicate via the sync
464+
* engine's externalId-keyed matching.
465+
*/
460466
const separatorIndex = externalId.indexOf(':')
467+
const isMultiCalendar = separatorIndex !== -1
461468
let calendarId: string
462469
let eventId: string
463470
if (separatorIndex === -1) {

apps/sim/connectors/slack/slack.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,14 @@ export const slackConnector: ConnectorConfig = {
558558
for (const channelInput of channelInputs) {
559559
const channel = await resolveChannel(accessToken, channelInput)
560560
if (!channel) {
561-
logger.info(`Channel not found, skipping: ${channelInput}`)
562-
continue
561+
/**
562+
* Fail loudly rather than silently skipping. A configured channel that
563+
* suddenly stops resolving (bot removed, channel archived, renamed)
564+
* would otherwise have its previously-indexed document orphaned and
565+
* deleted by the sync engine with no error surfaced. Matches the MS
566+
* Teams connector's behaviour.
567+
*/
568+
throw new Error(`Channel not found: ${channelInput}`)
563569
}
564570

565571
const { content, contentHash, messageCount, lastActivityTs } =

0 commit comments

Comments
 (0)