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(errors): stop over-broad error patterns from giving wrong advice (#4666)

LearningCircuitb21b0728000f
diff --git a/src/local_deep_research/error_handling/error_reporter.py b/src/local_deep_research/error_handling/error_reporter.py
index 6feeee9d91..ee1b786d91 100644
--- a/src/local_deep_research/error_handling/error_reporter.py
+++ b/src/local_deep_research/error_handling/error_reporter.py
@@ -53,7 +53,7 @@ class ErrorReporter:
r"Authentication.*error",
r"max_workers must be greater than 0",
r"TypeError.*Context.*Size",
- r"'<' not supported between",
+ r"'<' not supported between instances of .* and 'NoneType'",
r"No auth credentials found",
r"401.*API key",
# OpenAI-compatible endpoint tokens (#3878)
@@ -85,9 +85,8 @@ class ErrorReporter:
r"Search engine.*error",
r"The search is longer than 256 characters",
r"Failed to create search engine",
- r"could not be found",
+ r"search engine.*could not be found",
r"GitHub API error",
- r"database.*locked",
],
ErrorCategory.SYNTHESIS_ERROR: [
r"Error.*synthesis",
@@ -105,6 +104,8 @@ class ErrorReporter:
r"No module named.*local_deep_research",
r"HTTP error 404.*research results",
r"Attempt to write readonly database",
+ r"database is locked",
+ r"database table is locked",
],
}
diff --git a/src/local_deep_research/error_handling/report_generator.py b/src/local_deep_research/error_handling/report_generator.py
index b16912abab..62d4cbf880 100644
--- a/src/local_deep_research/error_handling/report_generator.py
+++ b/src/local_deep_research/error_handling/report_generator.py
@@ -359,7 +359,7 @@ We're here to help you get this working:
"- Check you're using the right Python environment\n"
"- For Docker users: rebuild the container"
),
- "Failed to create search engine|could not be found": (
+ "Failed to create search engine|search engine.*could not be found": (
"Search engine configuration problem.\n\n"
"**Try this:**\n"
"- Use the default search engine (auto)\n"
@@ -376,7 +376,7 @@ We're here to help you get this working:
"- **Switch search engines:** Try DuckDuckGo, Brave, or Google (if API key configured)\n"
"- **Check for typos** in your research query"
),
- "TypeError.*Context.*Size|'<' not supported between": (
+ "TypeError.*Context.*Size|'<' not supported between instances of .* and 'NoneType'": (
"Model configuration issue. The context size setting might not be compatible with your model.\n\n"
"**Try this:**\n"
"- Check your model's maximum context size\n"
@@ -404,6 +404,14 @@ We're here to help you get this working:
"- On Linux/Mac: Check folder permissions\n"
"- Delete and recreate the database file if corrupted"
),
+ "database is locked|database table is locked": (
+ "The local database is temporarily locked, usually because "
+ "another operation is writing to it at the same time.\n\n"
+ "**Try this:**\n"
+ "- Wait a few seconds and run the research again\n"
+ "- Avoid starting multiple researches that write at the same moment\n"
+ "- If it persists, restart the LDR server to clear stuck connections"
+ ),
"does not support tools|tool calling": (
"Your current model does not support tool calling, which is required by the **langgraph-agent** strategy.\n\n"
"**Try this:**\n"
@@ -422,7 +430,7 @@ We're here to help you get this working:
"- **Switch strategy.** If you don't need an agentic loop, Settings → Search Strategy → **source-based** or **focused-iteration** sidesteps tool-calling entirely.\n"
"- See [issue #3897](https://github.com/LearningCircuit/local-deep-research/issues/3897) for the original report and discussion."
),
- "Invalid value.*SearXNG|database.*locked": (
+ "Invalid value.*SearXNG": (
"SearXNG configuration or rate limiting issue.\n\n"
"**Try this:**\n"
"- Keep 'Search snippets only' enabled (don't turn it off)\n"
diff --git a/tests/error_handling/test_error_categorization.py b/tests/error_handling/test_error_categorization.py
index 4b4310803d..7da8cb2f4e 100644
--- a/tests/error_handling/test_error_categorization.py
+++ b/tests/error_handling/test_error_categorization.py
@@ -400,9 +400,8 @@ class TestSearchErrorPatterns:
"Search engine error",
"The search is longer than 256 characters",
"Failed to create search engine",
- "could not be found",
+ "search engine 'brave' could not be found",
"GitHub API error",
- "database is locked",
]
for error_msg in test_cases:
@@ -473,6 +472,8 @@ class TestFileErrorPatterns:
"Disk is full",
"No module named local_deep_research",
"Attempt to write readonly database",
+ "database is locked",
+ "database table is locked",
]
for error_msg in test_cases:
diff --git a/tests/error_handling/test_error_reporter_behavior.py b/tests/error_handling/test_error_reporter_behavior.py
index 7c2188809b..d27bc78669 100644
--- a/tests/error_handling/test_error_reporter_behavior.py
+++ b/tests/error_handling/test_error_reporter_behavior.py
@@ -426,7 +426,8 @@ class TestCategorizeSearchError:
assert result == ErrorCategory.SEARCH_ERROR
def test_categorizes_database_locked(self):
- """Categorizes database locked as search error."""
+ """Categorizes a SQLite lock as a file-system error (it is the local
+ DB file, not a search problem)."""
from local_deep_research.error_handling.error_reporter import (
ErrorCategory,
ErrorReporter,
@@ -434,7 +435,7 @@ class TestCategorizeSearchError:
reporter = ErrorReporter()
result = reporter.categorize_error("database is locked")
- assert result == ErrorCategory.SEARCH_ERROR
+ assert result == ErrorCategory.FILE_ERROR
class TestCategorizeSynthesisError:
diff --git a/tests/error_handling/test_error_reporter_coverage.py b/tests/error_handling/test_error_reporter_coverage.py
index 969baf106d..69ac0df55b 100644
--- a/tests/error_handling/test_error_reporter_coverage.py
+++ b/tests/error_handling/test_error_reporter_coverage.py
@@ -62,7 +62,7 @@ class TestCategorizeErrorModel:
"Authentication error: forbidden",
"max_workers must be greater than 0",
"TypeError Context Size mismatch",
- "'<' not supported between instances",
+ "'<' not supported between instances of 'int' and 'NoneType'",
"No auth credentials found for provider",
"401 API key missing or revoked",
],
@@ -108,9 +108,8 @@ class TestCategorizeErrorSearch:
"Search engine encountered an error",
"The search is longer than 256 characters",
"Failed to create search engine instance",
- "Module 'xyz' could not be found",
+ "search engine 'xyz' could not be found",
"GitHub API error 403 forbidden",
- "database is locked, try again",
],
ids=lambda m: m[:40],
)
@@ -150,6 +149,8 @@ class TestCategorizeErrorFile:
"No module named local_deep_research.core",
"File config.yaml not found in expected location",
"Attempt to write readonly database",
+ "database is locked, try again",
+ "database table is locked",
],
ids=lambda m: m[:40],
)
diff --git a/tests/error_handling/test_report_generator_behavior.py b/tests/error_handling/test_report_generator_behavior.py
index b13fe586ed..f59acfdb38 100644
--- a/tests/error_handling/test_report_generator_behavior.py
+++ b/tests/error_handling/test_report_generator_behavior.py
@@ -139,7 +139,12 @@ class TestMakeErrorUserFriendly:
)
gen = ErrorReportGenerator()
- result = gen._make_error_user_friendly("database is locked")
+ # Was "database is locked" -- that bare SQLite message is unrelated to
+ # SearXNG and is now classified separately (see
+ # TestBroadPatternTightening). Use a real SearXNG error here.
+ result = gen._make_error_user_friendly(
+ "Invalid value for SearXNG setting"
+ )
assert "SearXNG configuration" in result
def test_replaced_message_includes_technical_error(self):
@@ -301,6 +306,104 @@ class TestErrorTypeTokenShortCircuit:
assert result == msg
+class TestBroadPatternTightening:
+ """Tests that over-broad replacement patterns no longer misclassify
+ unrelated exceptions into wrong advice.
+
+ Three table arms used to match far more than intended:
+ ``could not be found`` (any "X could not be found"), ``database.*locked``
+ (any SQLite "database is locked" -> wrong SearXNG advice), and
+ ``'<' not supported between`` (any heterogeneous-sort TypeError -> wrong
+ model-context-size advice). Each was anchored to its real context.
+ """
+
+ def test_database_locked_gets_db_advice_not_searxng(self):
+ # A plain SQLite "database is locked" (real, under per-user encrypted
+ # DBs) must get database-contention advice, NOT the old SearXNG /
+ # "use a VPN" advice it used to be misclassified into.
+ from local_deep_research.error_handling.report_generator import (
+ ErrorReportGenerator,
+ )
+
+ gen = ErrorReportGenerator()
+ result = gen._make_error_user_friendly("Error: database is locked")
+
+ assert "local database is temporarily locked" in result
+ assert "SearXNG configuration" not in result
+ assert "use a VPN" not in result
+
+ def test_searxng_invalid_value_still_matched(self):
+ # The legitimate SearXNG arm must keep working after database.*locked
+ # was removed from it.
+ from local_deep_research.error_handling.report_generator import (
+ ErrorReportGenerator,
+ )
+
+ gen = ErrorReportGenerator()
+ result = gen._make_error_user_friendly(
+ "Invalid value for SearXNG setting"
+ )
+ assert "SearXNG configuration" in result
+
+ def test_generic_could_not_be_found_not_misclassified(self):
+ # An unrelated "could not be found" must NOT be classified as a search
+ # engine configuration problem.
+ from local_deep_research.error_handling.report_generator import (
+ ErrorReportGenerator,
+ )
+
+ gen = ErrorReportGenerator()
+ msg = "Model file could not be found at /models/x.gguf"
+ result = gen._make_error_user_friendly(msg)
+
+ assert result == msg
+ assert "Search engine configuration problem" not in result
+
+ def test_search_engine_errors_still_matched(self):
+ # Both the factory failure and an engine-scoped "could not be found"
+ # must still get search-engine advice.
+ from local_deep_research.error_handling.report_generator import (
+ ErrorReportGenerator,
+ )
+
+ gen = ErrorReportGenerator()
+ for msg in (
+ "Failed to create search engine 'brave'",
+ "search engine 'brave' could not be found",
+ ):
+ result = gen._make_error_user_friendly(msg)
+ assert "Search engine configuration problem" in result
+
+ def test_generic_sort_typeerror_not_misclassified(self):
+ # A heterogeneous-sort TypeError unrelated to model config must NOT be
+ # classified as a context-size problem.
+ from local_deep_research.error_handling.report_generator import (
+ ErrorReportGenerator,
+ )
+
+ gen = ErrorReportGenerator()
+ msg = (
+ "TypeError: '<' not supported between instances of 'str' and 'int'"
+ )
+ result = gen._make_error_user_friendly(msg)
+
+ assert result == msg
+ assert "Model configuration issue" not in result
+
+ def test_nonetype_context_comparison_still_matched(self):
+ # The realistic missing-context-size case (a numeric setting left None
+ # then compared) must still get the model-config advice.
+ from local_deep_research.error_handling.report_generator import (
+ ErrorReportGenerator,
+ )
+
+ gen = ErrorReportGenerator()
+ msg = "'<' not supported between instances of 'int' and 'NoneType'"
+ result = gen._make_error_user_friendly(msg)
+
+ assert "Model configuration issue" in result
+
+
class TestFormatPartialResults:
"""Tests for ErrorReportGenerator._format_partial_results() method."""