Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix: helpful .gguf file listing never reached user due to swallowed ValueError (#2451)

LearningCircuit081f56b76daa
diff --git a/src/local_deep_research/config/llm_config.py b/src/local_deep_research/config/llm_config.py
index 6e5fc2e257..529b813c86 100644
--- a/src/local_deep_research/config/llm_config.py
+++ b/src/local_deep_research/config/llm_config.py
@@ -838,6 +838,7 @@ def get_llm(
# If the path is not a file, try to provide helpful directory listing
# Only do this after path has passed security validation (safe_join check)
if "not a file" in error_msg:
+ helpful_message = None
try:
model_root = str(get_models_directory())
safe_path = PathValidator.validate_safe_path(
@@ -858,13 +859,15 @@ def get_llm(
suggestion = (
"No .gguf files found in this directory"
)
- raise ValueError(
+ helpful_message = (
f"Model path is a directory, not a file: {model_path}\n"
f"Please specify the full path to a .gguf model file.\n"
f"{suggestion}"
- ) from e
+ )
except ValueError:
- pass # Re-raise original error if secondary validation fails
+ pass # Secondary validation failed, use original error
+ if helpful_message:
+ raise ValueError(helpful_message) from e
logger.exception("Model path validation failed")
raise
diff --git a/tests/config/test_llm_config_extended.py b/tests/config/test_llm_config_extended.py
index 4d7ef8e35f..274551a8e1 100644
--- a/tests/config/test_llm_config_extended.py
+++ b/tests/config/test_llm_config_extended.py
@@ -273,6 +273,82 @@ class TestLlamaCppProvider:
get_llm(provider="llamacpp")
mock_pv_validate.assert_called_once_with(str(model_file))
+ def test_directory_path_lists_gguf_files(self, tmp_path):
+ """Directory with .gguf files produces helpful error listing them."""
+ (tmp_path / "alpha.gguf").write_text("fake")
+ (tmp_path / "beta.gguf").write_text("fake")
+
+ settings = _settings_dict(
+ {
+ "llm.provider": "llamacpp",
+ "llm.llamacpp_model_path": str(tmp_path),
+ }
+ )
+
+ with (
+ patch(
+ "local_deep_research.config.llm_config.is_llm_registered",
+ return_value=False,
+ ),
+ patch(
+ "local_deep_research.config.llm_config.get_setting_from_snapshot",
+ side_effect=_mock_get_setting(settings),
+ ),
+ patch(
+ "local_deep_research.security.path_validator.PathValidator.validate_model_path",
+ side_effect=ValueError(f"Model path is not a file: {tmp_path}"),
+ ),
+ patch(
+ "local_deep_research.security.path_validator.PathValidator.validate_safe_path",
+ return_value=tmp_path,
+ ),
+ patch(
+ "local_deep_research.config.paths.get_models_directory",
+ return_value=tmp_path,
+ ),
+ ):
+ with pytest.raises(
+ ValueError, match="Found .gguf files:"
+ ) as exc_info:
+ get_llm(provider="llamacpp")
+ msg = str(exc_info.value)
+ assert "alpha.gguf" in msg
+ assert "beta.gguf" in msg
+
+ def test_directory_path_no_gguf_files(self, tmp_path):
+ """Empty directory produces helpful error about no .gguf files."""
+ settings = _settings_dict(
+ {
+ "llm.provider": "llamacpp",
+ "llm.llamacpp_model_path": str(tmp_path),
+ }
+ )
+
+ with (
+ patch(
+ "local_deep_research.config.llm_config.is_llm_registered",
+ return_value=False,
+ ),
+ patch(
+ "local_deep_research.config.llm_config.get_setting_from_snapshot",
+ side_effect=_mock_get_setting(settings),
+ ),
+ patch(
+ "local_deep_research.security.path_validator.PathValidator.validate_model_path",
+ side_effect=ValueError(f"Model path is not a file: {tmp_path}"),
+ ),
+ patch(
+ "local_deep_research.security.path_validator.PathValidator.validate_safe_path",
+ return_value=tmp_path,
+ ),
+ patch(
+ "local_deep_research.config.paths.get_models_directory",
+ return_value=tmp_path,
+ ),
+ ):
+ with pytest.raises(ValueError, match="No .gguf files found"):
+ get_llm(provider="llamacpp")
+
# ── Ollama provider ────────────────────────────────────────────────