Skip to content

Commit 3be8294

Browse files
waleedlatif1claude
andcommitted
fix(knowledge): remove pdf/rtf from allowlist, normalize unrecognized extensions
- Remove application/pdf and application/rtf from TEXT_COMPATIBLE_MIME_TYPES since these tools pass plain text content, not binary - Normalize unrecognized extensions (e.g. report.v2) to .txt instead of preserving the original extension with text/plain MIME type Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent fa9f344 commit 3be8294

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

apps/sim/tools/knowledge/types.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@ const TEXT_COMPATIBLE_MIME_TYPES = new Set([
1111
'application/json',
1212
'application/xml',
1313
'application/x-yaml',
14-
'application/rtf',
15-
'application/pdf',
1614
])
1715

1816
/**
1917
* Extracts extension from a filename and returns the normalized filename and MIME type.
20-
* If no extension is present, appends `.txt` and uses `text/plain`.
21-
* Falls back to `text/plain` for non-text MIME types (knowledge docs are always text content).
18+
* If the extension maps to a recognized text-compatible MIME type, it is preserved.
19+
* Otherwise, the filename is normalized to `.txt` with `text/plain`.
2220
*/
2321
export function inferDocumentFileInfo(documentName: string): {
2422
filename: string
@@ -27,12 +25,12 @@ export function inferDocumentFileInfo(documentName: string): {
2725
const ext = getFileExtension(documentName)
2826
if (ext) {
2927
const mimeType = getUploadMimeType(ext)
30-
return {
31-
filename: documentName,
32-
mimeType: TEXT_COMPATIBLE_MIME_TYPES.has(mimeType) ? mimeType : 'text/plain',
28+
if (TEXT_COMPATIBLE_MIME_TYPES.has(mimeType)) {
29+
return { filename: documentName, mimeType }
3330
}
3431
}
35-
return { filename: `${documentName}.txt`, mimeType: 'text/plain' }
32+
const base = ext ? documentName.slice(0, documentName.lastIndexOf('.')) : documentName
33+
return { filename: `${base}.txt`, mimeType: 'text/plain' }
3634
}
3735

3836
export interface KnowledgeSearchResult {

0 commit comments

Comments
 (0)