fix(kb): added internal auth for mistral OCR tool via KB#1704
Merged
waleedlatif1 merged 1 commit intostagingfrom Oct 21, 2025
Merged
fix(kb): added internal auth for mistral OCR tool via KB#1704waleedlatif1 merged 1 commit intostagingfrom
waleedlatif1 merged 1 commit intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
There was a problem hiding this comment.
Greptile Overview
Summary
Added internal JWT authentication when the knowledge base document processor calls the internal Mistral OCR API endpoint (/api/tools/mistral/parse). This ensures server-to-server calls are properly authenticated.
Key Changes
- Modified
parseWithMistralOCRfunction to detect internal API calls by checking if the URL includes/api/tools/mistral/parse - When detected, generates an internal JWT using
generateInternalToken()and adds it to the request headers - Follows the existing pattern used in
downloadFileWithTimeoutfor internal file serving authentication - The internal API endpoint already supports hybrid authentication (session, API key, or internal JWT) via
checkHybridAuth
Analysis
The implementation correctly addresses the authentication gap for internal server-to-server communication. The pattern is consistent with existing internal authentication in the codebase, and the endpoint already has proper validation through the hybrid auth system.
Confidence Score: 5/5
- This PR is safe to merge with minimal risk
- The change adds proper authentication for internal API calls using an established pattern already present in the codebase. The implementation is straightforward, follows existing conventions (similar to the authentication in downloadFileWithTimeout at line 216), and the receiving endpoint already supports internal JWT validation through checkHybridAuth. No breaking changes or side effects expected.
- No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/lib/knowledge/documents/document-processor.ts | 5/5 | Added internal JWT authentication for Mistral OCR API calls to /api/tools/mistral/parse endpoint |
Sequence Diagram
sequenceDiagram
participant KB as Knowledge Base Processor
participant Auth as Internal Auth Module
participant API as Mistral Parse API
participant Hybrid as Hybrid Auth Module
participant Mistral as Mistral OCR Service
Note over KB: Processing PDF document
KB->>KB: Prepare request parameters
KB->>KB: Build tool headers
KB->>KB: Check if URL is internal endpoint
alt Internal API Call
KB->>Auth: Request internal authentication
Auth-->>KB: Return authentication credentials
KB->>KB: Update authorization header
end
KB->>API: Send POST request
API->>Hybrid: Validate authentication
Hybrid->>Hybrid: Verify credentials
Hybrid-->>API: Authentication confirmed
API->>Mistral: Forward OCR request
Mistral-->>API: Return OCR result
API-->>KB: Send parsed content response
1 file reviewed, no comments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Type of Change
Testing
Tested manually
Checklist