Skip to content

Commit 228afa4

Browse files
waleedlatif1claude
andcommitted
fix(connectors): address PR review comments - metadata merge, retryOptions, UTF-8 safety
- Sync engine: merge metadata from getDocument during deferred hydration, so Gmail/Obsidian/Confluence tags and metadata survive the stub→full transition - Evernote: pass retryOptions {retries:3, backoff:500} from listDocuments and getDocument callers into apiFindNotesMetadata and apiGetNote - Google Drive + SharePoint: safe UTF-8 truncation that walks back to the last complete character boundary instead of splitting multi-byte chars Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f9785be commit 228afa4

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

apps/sim/connectors/evernote/evernote.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,14 @@ export const evernoteConnector: ConnectorConfig = {
412412

413413
logger.info('Listing Evernote notes', { offset, maxNotes: NOTES_PER_PAGE })
414414

415-
const result = await apiFindNotesMetadata(accessToken, offset, NOTES_PER_PAGE, notebookGuid)
415+
const retryOptions = { retries: 3, backoff: 500 }
416+
const result = await apiFindNotesMetadata(
417+
accessToken,
418+
offset,
419+
NOTES_PER_PAGE,
420+
notebookGuid,
421+
retryOptions
422+
)
416423

417424
const documents: ExternalDocument[] = result.notes.map((meta) => {
418425
const tagNames = meta.tagGuids.map((g) => tagMap[g]).filter(Boolean)
@@ -451,7 +458,8 @@ export const evernoteConnector: ConnectorConfig = {
451458
syncContext?: Record<string, unknown>
452459
): Promise<ExternalDocument | null> => {
453460
try {
454-
const note = await apiGetNote(accessToken, externalId)
461+
const retryOptions = { retries: 3, backoff: 500 }
462+
const note = await apiGetNote(accessToken, externalId, retryOptions)
455463
const plainText = htmlToPlainText(note.content)
456464
if (!plainText.trim()) return null
457465

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ async function downloadTextFile(accessToken: string, fileId: string): Promise<st
7070
const text = await response.text()
7171
if (Buffer.byteLength(text, 'utf8') > MAX_EXPORT_SIZE) {
7272
logger.warn(`File exceeds ${MAX_EXPORT_SIZE} bytes, truncating`)
73-
return Buffer.from(text, 'utf8').subarray(0, MAX_EXPORT_SIZE).toString('utf8')
73+
const buf = Buffer.from(text, 'utf8')
74+
let end = MAX_EXPORT_SIZE
75+
while (end > 0 && (buf[end] & 0xc0) === 0x80) end--
76+
return buf.subarray(0, end).toString('utf8')
7477
}
7578
return text
7679
}

apps/sim/connectors/sharepoint/sharepoint.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,10 @@ async function downloadFileContent(
135135
const text = await response.text()
136136
if (Buffer.byteLength(text, 'utf8') > MAX_DOWNLOAD_SIZE) {
137137
logger.warn(`File "${fileName}" exceeds ${MAX_DOWNLOAD_SIZE} bytes, truncating`)
138-
return Buffer.from(text, 'utf8').subarray(0, MAX_DOWNLOAD_SIZE).toString('utf8')
138+
const buf = Buffer.from(text, 'utf8')
139+
let end = MAX_DOWNLOAD_SIZE
140+
while (end > 0 && (buf[end] & 0xc0) === 0x80) end--
141+
return buf.subarray(0, end).toString('utf8')
139142
}
140143
return text
141144
}

apps/sim/lib/knowledge/connectors/sync-engine.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ export async function executeSync(
463463
content: fullDoc.content,
464464
contentHash: fullDoc.contentHash ?? op.extDoc.contentHash,
465465
contentDeferred: false,
466+
metadata: { ...op.extDoc.metadata, ...fullDoc.metadata },
466467
},
467468
}
468469
})

0 commit comments

Comments
 (0)