fix(kb): add base URL for kb fetches#1701
Merged
waleedlatif1 merged 1 commit intostagingfrom Oct 21, 2025
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
There was a problem hiding this comment.
Greptile Overview
Summary
Fixed a bug where Mistral OCR requests failed in Trigger.dev background tasks by converting relative URLs to absolute URLs.
- Added base URL resolution for relative API paths (
/api/tools/mistral/parse) when called from Trigger.dev context - Uses dynamic import of
getBaseUrl()utility to prepend the application's base URL to relative paths - This fix ensures that knowledge base document processing works correctly in background tasks where there's no request context
Confidence Score: 5/5
- This PR is safe to merge with minimal risk
- The change is a focused bug fix that adds proper URL resolution for background task contexts. The implementation follows the existing pattern used in the same codebase (mistral/parser.ts:104), uses dynamic import appropriately, and handles the edge case correctly
- No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/lib/knowledge/documents/document-processor.ts | 5/5 | Added base URL resolution for relative URLs in Mistral OCR calls when running in Trigger.dev context |
Sequence Diagram
sequenceDiagram
participant Trigger as Trigger.dev Task
participant DP as DocumentProcessor
participant Parser as MistralParserTool
participant Utils as getBaseUrl()
participant API as Mistral OCR API
Trigger->>DP: parseWithMistralOCR(fileUrl, filename, mimeType)
DP->>Parser: Get request URL from mistralParserTool.request.url
Parser-->>DP: Returns '/api/tools/mistral/parse'
alt URL starts with '/'
DP->>Utils: import and call getBaseUrl()
Utils-->>DP: Returns base URL (e.g., 'https://sim.ai')
DP->>DP: Prepend base URL to relative path
Note over DP: url = 'https://sim.ai/api/tools/mistral/parse'
end
DP->>API: POST to absolute URL with file data
API-->>DP: OCR result
DP-->>Trigger: Return processed content
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
add base URL for kb fetches, since trigger doesn't have context of a base URL and was making relative fetches
Type of Change
Testing
Tested manually.
Checklist