From e737d7215470859c44f9f0b98468084e9dea12f7 Mon Sep 17 00:00:00 2001 From: waleed Date: Tue, 21 Oct 2025 13:46:22 -1000 Subject: [PATCH] fix(kb): added internal auth for mistral OCR tool via KB --- .../sim/lib/knowledge/documents/document-processor.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/sim/lib/knowledge/documents/document-processor.ts b/apps/sim/lib/knowledge/documents/document-processor.ts index 6f55898b34d..0f634532ef5 100644 --- a/apps/sim/lib/knowledge/documents/document-processor.ts +++ b/apps/sim/lib/knowledge/documents/document-processor.ts @@ -417,11 +417,20 @@ async function parseWithMistralOCR(fileUrl: string, filename: string, mimeType: url = `${getBaseUrl()}${url}` } - const headers = + let headers = typeof mistralParserTool.request!.headers === 'function' ? mistralParserTool.request!.headers(params) : mistralParserTool.request!.headers + if (url.includes('/api/tools/mistral/parse')) { + const { generateInternalToken } = await import('@/lib/auth/internal') + const internalToken = await generateInternalToken() + headers = { + ...headers, + authorization: `Bearer ${internalToken}`, + } + } + const requestBody = mistralParserTool.request!.body!(params) as OCRRequestBody return makeOCRRequest(url, headers as Record, requestBody) },