Skip to content

Commit c877c31

Browse files
committed
fix(github): apply binary check to blob fallback path
fetchBlobContent now runs isBinaryBuffer on base64-decoded data and returns null for binaries; getDocument propagates the null so 1-10MB binary files are skipped instead of being decoded into garbled UTF-8.
1 parent 9014c08 commit c877c31

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

apps/sim/connectors/github/github.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ async function fetchBlobContent(
114114
owner: string,
115115
repo: string,
116116
sha: string
117-
): Promise<string> {
117+
): Promise<string | null> {
118118
const url = `${GITHUB_API_URL}/repos/${owner}/${repo}/git/blobs/${encodeURIComponent(sha)}`
119119
const response = await fetchWithRetry(url, {
120120
method: 'GET',
@@ -134,7 +134,9 @@ async function fetchBlobContent(
134134
const encoding = data.encoding as string | undefined
135135

136136
if (encoding === 'base64') {
137-
return Buffer.from(content, 'base64').toString('utf8')
137+
const buf = Buffer.from(content, 'base64')
138+
if (isBinaryBuffer(buf)) return null
139+
return buf.toString('utf8')
138140
}
139141
if (encoding === 'utf-8') {
140142
return content
@@ -332,7 +334,12 @@ export const githubConnector: ConnectorConfig = {
332334
}
333335
content = buf.toString('utf8')
334336
} else if (encoding === 'none' && data.sha && size > 0) {
335-
content = await fetchBlobContent(accessToken, owner, repo, data.sha as string)
337+
const blobContent = await fetchBlobContent(accessToken, owner, repo, data.sha as string)
338+
if (blobContent === null) {
339+
logger.info('Skipping binary GitHub file', { path, size })
340+
return null
341+
}
342+
content = blobContent
336343
} else {
337344
content = ''
338345
}

0 commit comments

Comments
 (0)