diff --git a/crates/mesh-llm-host-runtime/src/models/delete_tests.rs b/crates/mesh-llm-host-runtime/src/models/delete_tests.rs index 1ff1736455..568564e194 100644 --- a/crates/mesh-llm-host-runtime/src/models/delete_tests.rs +++ b/crates/mesh-llm-host-runtime/src/models/delete_tests.rs @@ -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] diff --git a/crates/model-hf/src/store/delete.rs b/crates/model-hf/src/store/delete.rs index f7db2cba9a..48ca6d9277 100644 --- a/crates/model-hf/src/store/delete.rs +++ b/crates/model-hf/src/store/delete.rs @@ -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("../")