fix(llm): normalize multimodal image paths to file:// URIs#1090
Merged
msluszniak merged 1 commit intomainfrom Apr 22, 2026
Merged
fix(llm): normalize multimodal image paths to file:// URIs#1090msluszniak merged 1 commit intomainfrom
msluszniak merged 1 commit intomainfrom
Conversation
The native multimodal pipeline expects image paths to be `file://` URIs. `ResourceFetcher.fetch` returns raw filesystem paths without that prefix (per its own docstring), and platform image-picker APIs typically return `file:///...` URIs, so callers can plausibly arrive at `LLMModule.generate`/`sendMessage` with either form. Today only the prefixed form works — the bare path gets `"Read image error: invalid argument"` from native, with no explanation in the error. Normalize each image path inside `LLMController.forward` so both forms are accepted, and document the new contract on the relevant JSDoc (`Message.mediaPath` and `LLMModule.forward`'s `imagePaths` parameter). Refs #1086 (item 3). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
barhanc
approved these changes
Apr 22, 2026
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.
Description
LLMController.forwardpassedimagePathsstraight through tonativeModule.generateMultimodalwith no normalization. The native side requires thefile://prefix; without it, native throws"Read image error: invalid argument"with no further context. Callers can plausibly arrive with either form:ResourceFetcher.fetchreturns raw paths withoutfile://(per its own docstring on thefetchmethod).expo-image-picker) typically returnfile:///...URIs.forward(...)works either way; the asymmetry between vision modules and multimodal LLM is undocumented.This PR normalizes each image path inside
LLMController.forwardso both forms work, and updates the JSDoc onMessage.mediaPathandLLMModule.forward.imagePathsto document the new contract.Introduces a breaking change?
Strictly additive: previously-working calls (paths with
file://) keep working unchanged. Previously-failing calls (paths withoutfile://) now succeed.Type of change
Tested on
The bare-path failure was reproduced on Android (Samsung Galaxy S24 Ultra) with LFM2-VL-1.6B while building a downstream consumer; both forms tested manually post-fix on the same device. Re-verification of both forms on iOS is recommended.
Testing instructions
Related issues
Addresses item 3 of #1086.
Checklist
Additional notes
The normalizer is module-scope (matching
messagesForChatTemplatefrom #1089) rather than a class method because it doesn't depend on controller state.