Skip to content

fix(ai): require UNSTRUCTURED_API_URL before sending attachments to Unstructured (#1287) - #1292

Open
Aniketchavan7 wants to merge 1 commit into
blinkospace:mainfrom
Aniketchavan7:fix/unstructured-api-opt-in
Open

Aniketchavan7 wants to merge 1 commit into
blinkospace:mainfrom
Aniketchavan7:fix/unstructured-api-opt-in

Conversation

@Aniketchavan7

Copy link
Copy Markdown

Resolves #1287

Summary

When indexing attachments with unsupported extensions, \AiService.loadFileContent\ defaulted to instantiating \UnstructuredLoader(filePath), which transmits files to the third-party hosted Unstructured API (\�pi.unstructured.io). On self-hosted deployments, this causes unexpected external file transmission (especially for photo formats like .heic\ not covered by \isImage).

Solution

  1. Unstructured Opt-in:
    • In \server/aiServer/index.ts, only instantiate \UnstructuredLoader\ if \process.env.UNSTRUCTURED_API_URL\ is explicitly configured. If not configured, log a warning and return an empty string rather than sending local files over the public internet.
  2. Extended Image Formats:
    • Expanded \isImage\ to recognize .heic, .heif, .avif, .ico, and .tiff\ so mobile camera photos are routed to vision models rather than document fallback loaders.
  3. Safe Empty Attachment Handling:
    • In \�mbeddingInsertAttachments, if no text content is extracted from an attachment, log and return early without failing the rest of the note's embedding pipeline.
  4. Unit Tests:
    • Added \server/tests/unit/aiServer/unstructured-loader.test.ts\ verifying image extension detection and Unstructured opt-in gating.

Co-authored-by: yalongwastaken yalongwastaken@users.noreply.github.com

…configured (blinkospace#1287)

In loadFileContent, only instantiate UnstructuredLoader when UNSTRUCTURED_API_URL is explicitly configured to prevent unintended external file transmission from self-hosted instances. Added HEIC/AVIF/ICO image formats to isImage and safely skip embedding when no text can be extracted. Closes blinkospace#1287

Co-authored-by: yalongwastaken <yalongwastaken@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

Don't send attachments to the hosted Unstructured API unless it's configured

1 participant