Skip to content

fix(kb): added internal auth for mistral OCR tool via KB - #1704

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/kb
Oct 21, 2025
Merged

fix(kb): added internal auth for mistral OCR tool via KB#1704
waleedlatif1 merged 1 commit into
stagingfrom
fix/kb

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • added internal auth for mistral OCR tool via KB

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercelBot commented Oct 21, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
ProjectDeploymentPreviewCommentsUpdated (UTC)
docsSkippedSkippedOct 21, 2025 11:47pm

@greptile-appsgreptile-appsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 parseWithMistralOCR function 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 downloadFileWithTimeout for 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

FilenameScoreOverview
apps/sim/lib/knowledge/documents/document-processor.ts5/5Added 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
Loading

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1
waleedlatif1 merged commit d5902e9 into stagingOct 21, 2025
9 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/kb branch October 21, 2025 23:56
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@waleedlatif1