Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions crates/mesh-llm-host-runtime/src/models/delete_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,27 @@ fn create_cache_repo_file(

#[tokio::test]
async fn resolve_model_identifier_rejects_filesystem_paths() {
let err = resolve_model_identifier("/tmp/model.gguf")
.await
.unwrap_err();
assert!(
err.to_string()
.contains("does not support filesystem paths")
);
// Every shape here is a filesystem path on some platform and a valid
// model stem on none, so each is rejected the same way everywhere.
// `/tmp/model.gguf` is the one that mattered: Windows does not consider
// it absolute, so it used to fall through to the Hugging Face branch and
// fail with a message about model stems instead.
for input in [
"/tmp/model.gguf",
"/home/user/model.gguf",
"C:\\models\\model.gguf",
"\\\\server\\share\\model.gguf",
"./model.gguf",
"../model.gguf",
"~/model.gguf",
] {
let err = resolve_model_identifier(input).await.unwrap_err();
assert!(
err.to_string()
.contains("does not support filesystem paths"),
"{input} should be rejected as a path, got: {err}"
);
}
}

#[tokio::test]
Expand Down
4 changes: 4 additions & 0 deletions crates/model-hf/src/store/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ async fn parse_delete_model_ref(
if input.starts_with("http://") || input.starts_with("https://") {
bail!("Delete does not support direct URLs. Use a model stem or Hugging Face ref.");
}
// A leading `/` is rooted on Windows without being absolute there, so
// `is_absolute()` alone lets POSIX-style paths through on that platform.
// No model stem or Hugging Face ref starts with one on any platform.
if Path::new(input).is_absolute()
|| input.starts_with('/')
|| input.contains('\\')
|| input.starts_with("./")
|| input.starts_with("../")
Expand Down
Loading