Skip to content

fix(downloader): list supported URL schemes in DownloadFile error - #9689

Merged
mudler merged 3 commits into
mudler:masterfrom
Anai-Guo:fix/downloader-uri-error-message-schemes
May 6, 2026
Merged

fix(downloader): list supported URL schemes in DownloadFile error#9689
mudler merged 3 commits into
mudler:masterfrom
Anai-Guo:fix/downloader-uri-error-message-schemes

Conversation

@Anai-Guo

@Anai-Guo Anai-Guo commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #9683.

When DownloadFile is given an input that is neither a local path that exists nor an HTTP-style URL, it returns the error:

file ... does not exist (...) and ... does not look like an HTTP URL

The wording suggests only HTTP URLs are accepted. In reality, LocalAI's downloader also recognizes file://, huggingface:// / hf:// / hf.co/, ollama://, oci://, and github:// (see the constants in pkg/downloader/uri.go and LooksLikeURL).

In #9683 the user typed the bare filename Phi-3-mini-4k-instruct-q4.gguf — none of the supported scheme prefixes match, so the error fires and the message gives no hint about what scheme they should have used (e.g. file:// for a local absolute path or huggingface://microsoft/Phi-3-mini-4k-instruct-gguf for HF).

Change

One-line wording fix in pkg/downloader/uri.go. The new message:

could not fetch %q: local file does not exist (%v) and %q is not a recognized
downloadable URL (supported schemes: http://, https://, file://, huggingface://,
hf://, ollama://, oci://, github://)

No tests assert on the exact phrasing (grep -n "does not look like" pkg/downloader/uri_test.go is empty), so this is a pure UX improvement.

Test plan

  • gofmt -l clean
  • string isn't asserted in pkg/downloader/uri_test.go
  • CI

🤖 Generated with Claude Code

@mudler mudler left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Ideally I'm ok with changing the error message, but instead of duplicating the prefixes accepted, we have constants/prefix already - better use these so we keep it tight and it makes it easier to manage drift long-term

The error message previously read "does not look like an HTTP URL",
but the downloader actually supports file://, huggingface://, hf://,
ollama://, oci://, and github:// in addition to http(s)://. Users who
type a bare filename or a typo'd scheme (e.g. fle:// instead of file://)
get the misleading impression that only HTTP is accepted.

Reference the existing prefix constants directly via strings.Join so
the scheme list cannot drift when new prefixes are added.

Refs mudler#9683.

Signed-off-by: Tai An <antai12232931@outlook.com>
@Anai-Guo
Anai-Guo force-pushed the fix/downloader-uri-error-message-schemes branch from c866389 to 6a72a40 Compare May 6, 2026 16:13
@Anai-Guo

Anai-Guo commented May 6, 2026

Copy link
Copy Markdown
Contributor Author

@mudler thanks for the review — addressed in 6a72a40. The error message now does strings.Join(...) over the existing prefix constants (HTTPPrefix, HTTPSPrefix, LocalPrefix, HuggingFacePrefix, HuggingFacePrefix1, OllamaPrefix, OCIPrefix, OCIFilePrefix, GithubURI2) instead of duplicating the literals, so it can't drift when new schemes are added. Also signed-off the rewritten commit so DCO is green now.

Anai-Guo added 2 commits May 6, 2026 12:15
Resolves the noisy diff and golangci-lint errcheck warnings on lines I did not actually modify.
@mudler
mudler merged commit 0497bb6 into mudler:master May 6, 2026
47 of 48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Import local model(fle://) error

2 participants