From d5902e91daba8295b9d7dc272556e1f51380181a Mon Sep 17 00:00:00 2001 From: Waleed Date: Tue, 21 Oct 2025 16:56:53 -0700 Subject: [PATCH] fix(kb): added internal auth for mistral OCR tool via KB (#1704) --- .../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 6f55898b34..0f634532ef 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) },