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: soften server_config.json warnings & fix test quality (#2613)

LearningCircuit7bc013feabd8
diff --git a/src/local_deep_research/web/server_config.py b/src/local_deep_research/web/server_config.py
index 007296cb3f..c3364adec7 100644
--- a/src/local_deep_research/web/server_config.py
+++ b/src/local_deep_research/web/server_config.py
@@ -53,6 +53,19 @@ _LEGACY_KEY_MAP: Dict[str, tuple] = {
}
+_DEFAULTS: Dict[str, Any] = {
+ "host": "0.0.0.0",
+ "port": 5000,
+ "debug": False,
+ "use_https": True,
+ "allow_registrations": True,
+ "rate_limit_default": "5000 per hour;50000 per day",
+ "rate_limit_login": "5 per 15 minutes",
+ "rate_limit_registration": "3 per hour",
+ "rate_limit_settings": "30 per minute",
+}
+
+
def get_server_config_path() -> Path:
"""Return the path to the legacy server_config.json file."""
return Path(get_data_dir()) / "server_config.json"
@@ -71,7 +84,7 @@ def _load_legacy_config() -> Dict[str, Any]:
return {}
try:
- data = json.loads(config_path.read_text(encoding="utf-8"))
+ data = json.loads(config_path.read_text(encoding="utf-8-sig"))
except (json.JSONDecodeError, OSError) as exc:
logger.warning(
f"Could not read legacy server_config.json at {config_path}: "
@@ -87,28 +100,9 @@ def _load_legacy_config() -> Dict[str, Any]:
return {}
saved: Dict[str, Any] = {}
- for json_key, (
- setting_key,
- env_var,
- is_critical,
- ) in _LEGACY_KEY_MAP.items():
- if json_key not in data:
- continue
-
- saved[json_key] = data[json_key]
-
- if is_critical:
- logger.warning(
- f"SECURITY: server_config.json contains '{json_key}={data[json_key]}'. "
- f"This value will be honored during the deprecation period, but you "
- f"should migrate to the environment variable {env_var} and delete "
- f"server_config.json."
- )
- else:
- logger.info(
- f"Legacy server_config.json contains '{json_key}'. "
- f"Migrate to environment variable {env_var}."
- )
+ for json_key in _LEGACY_KEY_MAP:
+ if json_key in data:
+ saved[json_key] = data[json_key]
# Warn about unrecognized keys (likely typos)
unrecognized = set(data.keys()) - set(_LEGACY_KEY_MAP.keys())
@@ -120,10 +114,9 @@ def _load_legacy_config() -> Dict[str, Any]:
)
if saved:
- logger.warning(
- f"DEPRECATED: server_config.json found at {config_path}. "
- f"Migrate settings to environment variables, then delete the file. "
- f"Support for this file will be removed in a future release."
+ logger.info(
+ f"server_config.json detected at {config_path}. "
+ f"Environment variables are the preferred configuration method."
)
return saved
@@ -146,49 +139,74 @@ def load_server_config() -> Dict[str, Any]:
config = {
"host": get_typed_setting_value(
- "web.host", saved.get("host"), "text", default="0.0.0.0"
+ "web.host", saved.get("host"), "text", default=_DEFAULTS["host"]
),
"port": get_typed_setting_value(
- "web.port", saved.get("port"), "number", default=5000
+ "web.port", saved.get("port"), "number", default=_DEFAULTS["port"]
),
"debug": get_typed_setting_value(
- "app.debug", saved.get("debug"), "checkbox", default=False
+ "app.debug",
+ saved.get("debug"),
+ "checkbox",
+ default=_DEFAULTS["debug"],
),
"use_https": get_typed_setting_value(
- "web.use_https", saved.get("use_https"), "checkbox", default=True
+ "web.use_https",
+ saved.get("use_https"),
+ "checkbox",
+ default=_DEFAULTS["use_https"],
),
"allow_registrations": get_typed_setting_value(
"app.allow_registrations",
saved.get("allow_registrations"),
"checkbox",
- default=True,
+ default=_DEFAULTS["allow_registrations"],
),
"rate_limit_default": get_typed_setting_value(
"security.rate_limit_default",
saved.get("rate_limit_default"),
"text",
- default="5000 per hour;50000 per day",
+ default=_DEFAULTS["rate_limit_default"],
),
"rate_limit_login": get_typed_setting_value(
"security.rate_limit_login",
saved.get("rate_limit_login"),
"text",
- default="5 per 15 minutes",
+ default=_DEFAULTS["rate_limit_login"],
),
"rate_limit_registration": get_typed_setting_value(
"security.rate_limit_registration",
saved.get("rate_limit_registration"),
"text",
- default="3 per hour",
+ default=_DEFAULTS["rate_limit_registration"],
),
"rate_limit_settings": get_typed_setting_value(
"security.rate_limit_settings",
saved.get("rate_limit_settings"),
"text",
- default="30 per minute",
+ default=_DEFAULTS["rate_limit_settings"],
),
}
+ # Log per-key messages for legacy values that differ from defaults
+ if saved:
+ for json_key in saved:
+ setting_key, env_var, is_critical = _LEGACY_KEY_MAP[json_key]
+ typed_value = config[json_key]
+ default_value = _DEFAULTS[json_key]
+ if typed_value == default_value:
+ continue # matches default — no noise
+ if is_critical:
+ logger.warning(
+ f"SECURITY: server_config.json sets '{json_key}' to a non-default value. "
+ f"Consider migrating to environment variable {env_var}."
+ )
+ else:
+ logger.info(
+ f"server_config.json sets '{json_key}' to a non-default value. "
+ f"Environment variable {env_var} is the preferred configuration method."
+ )
+
# Security: if allow_registrations is set to an unrecognized string value
# (e.g. "disabled", "nein", typos like "flase"), default to False
# (registrations disabled) rather than True. This "fail closed" approach
diff --git a/src/local_deep_research/web/static/js/research_form.js b/src/local_deep_research/web/static/js/research_form.js
index dff98bb669..7fb2e3410d 100644
--- a/src/local_deep_research/web/static/js/research_form.js
+++ b/src/local_deep_research/web/static/js/research_form.js
@@ -281,8 +281,8 @@ function displayWarnings(warnings) {
const esc = window.escapeHtml || (s => String(s || '').replace(/[&<>"']/g, m => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":"&#39;"})[m]));
const warningsHtml = warnings.map(warning => {
// Use success styling for recommendations/tips, warning for others
- const isRecommendation = warning.type === 'searxng_recommendation';
- const alertClass = isRecommendation ? 'ldr-alert-success' : 'ldr-alert-warning';
+ const isInfo = warning.type === 'searxng_recommendation' || warning.type === 'legacy_server_config';
+ const alertClass = isInfo ? 'ldr-alert-info' : 'ldr-alert-warning';
return `
<div class="ldr-alert ${alertClass} warning-banner warning-${esc(warning.type)}" style="
diff --git a/src/local_deep_research/web/warning_checks/hardware.py b/src/local_deep_research/web/warning_checks/hardware.py
index 9eaa65ba4f..2910a3935c 100644
--- a/src/local_deep_research/web/warning_checks/hardware.py
+++ b/src/local_deep_research/web/warning_checks/hardware.py
@@ -72,13 +72,12 @@ def check_legacy_server_config(dismissed: bool) -> Optional[dict]:
return {
"type": "legacy_server_config",
- "icon": "⚠️",
- "title": "Legacy Configuration File Detected",
+ "icon": "ℹ️",
+ "title": "server_config.json Detected",
"message": (
- "A server_config.json file was found and its values are being used "
- "as fallback. Migrate settings to environment variables (LDR_WEB_HOST, "
- "LDR_WEB_PORT, etc.) and delete the file. Support will be removed in "
- "a future release."
+ "A server_config.json file was found. Environment variables are "
+ "the preferred configuration method. See the documentation for "
+ "migration details."
),
"dismissKey": "app.warnings.dismiss_legacy_config",
}
diff --git a/tests/web/test_server_config.py b/tests/web/test_server_config.py
index 0f8c4b2b41..17ca3eaff1 100644
--- a/tests/web/test_server_config.py
+++ b/tests/web/test_server_config.py
@@ -221,12 +221,14 @@ class TestAllowRegistrationsFailClosed:
with patch(
"local_deep_research.web.server_config.logger"
) as mock_logger:
- load_server_config()
+ result = load_server_config()
warning_calls = [str(c) for c in mock_logger.warning.call_args_list]
assert not any("recognized" in call for call in warning_calls), (
f"Unexpected warning for recognized value '{value}': {warning_calls}"
)
+ # Verify the value was actually processed (not silently dropped)
+ assert result["allow_registrations"] is not None
@pytest.mark.usefixtures("_default_typed_setting")
@pytest.mark.parametrize(
@@ -467,8 +469,11 @@ class TestLegacyMigration:
warning_calls = [str(c) for c in mock_logger.warning.call_args_list]
# Should warn about unrecognized keys
assert any("unrecognized" in call.lower() for call in warning_calls)
- # No DEPRECATED summary warning since no recognized keys
- assert not any("DEPRECATED" in call for call in warning_calls)
+ # No banner since no recognized keys
+ info_calls = [str(c) for c in mock_logger.info.call_args_list]
+ assert not any(
+ "server_config.json detected" in call for call in info_calls
+ )
# Defaults returned
assert result["host"] == "0.0.0.0"
@@ -483,19 +488,41 @@ class TestLegacyMigration:
assert result["host"] == "0.0.0.0"
assert result["allow_registrations"] is True
- warning_calls = [str(c) for c in mock_logger.warning.call_args_list]
- assert not any("DEPRECATED" in call for call in warning_calls)
+ info_calls = [str(c) for c in mock_logger.info.call_args_list]
+ assert not any(
+ "server_config.json detected" in call for call in info_calls
+ )
@pytest.mark.usefixtures("_passthrough_typed_setting")
- def test_deprecated_banner_logged_for_recognized_keys(self, _mock_data_dir):
- """DEPRECATED banner should be logged when recognized keys are present."""
+ def test_banner_logged_for_recognized_keys(self, _mock_data_dir):
+ """Info banner should be logged when recognized keys are present."""
self._write_legacy(_mock_data_dir, {"port": 8080})
with patch(
"local_deep_research.web.server_config.logger"
) as mock_logger:
load_server_config()
+ info_calls = [str(c) for c in mock_logger.info.call_args_list]
+ assert any("server_config.json detected" in call for call in info_calls)
+
+ @pytest.mark.usefixtures("_passthrough_typed_setting")
+ def test_all_defaults_no_per_key_messages(self, _mock_data_dir):
+ """Legacy file with all default values should not produce per-key messages."""
+ from local_deep_research.web.server_config import _DEFAULTS
+
+ self._write_legacy(_mock_data_dir, dict(_DEFAULTS))
+ with patch(
+ "local_deep_research.web.server_config.logger"
+ ) as mock_logger:
+ load_server_config()
+
+ # Banner should still appear (file exists with recognized keys)
+ info_calls = [str(c) for c in mock_logger.info.call_args_list]
+ assert any("server_config.json detected" in call for call in info_calls)
+
+ # But no per-key info or warning messages about non-default values
warning_calls = [str(c) for c in mock_logger.warning.call_args_list]
- assert any("DEPRECATED" in call for call in warning_calls)
+ assert not any("non-default" in call for call in info_calls)
+ assert not any("non-default" in call for call in warning_calls)
class TestLegacyAllowRegistrationsFailClosed:
@@ -519,18 +546,26 @@ class TestLegacyAllowRegistrationsFailClosed:
assert result["allow_registrations"] is False
@pytest.mark.usefixtures("_passthrough_typed_setting")
- def test_recognized_string_not_overridden(self, _mock_data_dir):
- """Recognized boolean strings ('true', 'false', etc.) should not trigger the guard."""
- for value in ("true", "false", "yes", "no", "1", "0", "on", "off"):
- self._write_legacy(_mock_data_dir, {"allow_registrations": value})
- result = load_server_config()
- # Guard should NOT override to False for recognized values
- assert result["allow_registrations"] != False or value in ( # noqa: E712
- "false",
- "no",
- "0",
- "off",
- ), f"Guard incorrectly triggered for recognized value '{value}'"
+ @pytest.mark.parametrize("value", ["true", "yes", "1", "on"])
+ def test_recognized_truthy_string_not_overridden(
+ self, value, _mock_data_dir
+ ):
+ """Truthy recognized strings should NOT be overridden by the guard."""
+ self._write_legacy(_mock_data_dir, {"allow_registrations": value})
+ result = load_server_config()
+ assert result["allow_registrations"] == value # passthrough, not False
+
+ @pytest.mark.usefixtures("_passthrough_typed_setting")
+ @pytest.mark.parametrize("value", ["false", "no", "0", "off"])
+ def test_recognized_falsy_string_not_overridden(
+ self, value, _mock_data_dir
+ ):
+ """Falsy recognized strings — guard should not override."""
+ self._write_legacy(_mock_data_dir, {"allow_registrations": value})
+ result = load_server_config()
+ assert (
+ result["allow_registrations"] == value
+ ) # passthrough, not bool False
@pytest.mark.usefixtures("_passthrough_typed_setting")
def test_native_bool_not_affected(self, _mock_data_dir):