Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

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

  • 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
Copy link

vercel bot commented Oct 21, 2025

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

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Oct 21, 2025 6:52pm

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

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
Loading

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1 waleedlatif1 merged commit eb8995e into staging Oct 21, 2025
9 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/knowledgebase branch October 21, 2025 19:02
Sign up for free to 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.

2 participants