~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
fix(settings): preserve single-child namespace shape (#5377)
Ziyang Guo83eea8f69484
diff --git a/changelog.d/4948.bugfix.md b/changelog.d/4948.bugfix.mdnew file mode 100644index 0000000000..a8c9ac2bbf--- /dev/null+++ b/changelog.d/4948.bugfix.md@@ -0,0 +1 @@+Return a mapping for settings namespaces with exactly one child, matching snapshot-backed reads while preserving scalar exact-key reads.diff --git a/src/local_deep_research/settings/manager.py b/src/local_deep_research/settings/manager.pyindex 0992e7e151..02d7598a9a 100644--- a/src/local_deep_research/settings/manager.py+++ b/src/local_deep_research/settings/manager.py@@ -661,13 +661,14 @@ class SettingsManager(ISettingsManager):for s in settingsif str(s.key) == key or is_valid_setting_key(str(s.key))]- if len(settings) == 1:- # This is a bottom-level key.+ if len(settings) == 1 and str(settings[0].key) == key:+ # Only an exact row is a bottom-level key. A lone child row+ # still represents a namespace and must return a mapping,+ # matching get_setting_from_snapshot().return self.__get_typed_setting_value(settings[0], default, check_env)- # Cache the result- if len(settings) > 1:+ if settings:# This is a higher-level key.settings_map = {}for setting in settings:diff --git a/tests/settings/test_settings_manager.py b/tests/settings/test_settings_manager.pyindex 88a72fcf35..9ddca2f475 100644--- a/tests/settings/test_settings_manager.py+++ b/tests/settings/test_settings_manager.py@@ -2408,6 +2408,26 @@ class TestSettingsManagerPrefixQueriesRealDB:# The key "llm." should NOT match as a subkey of "llm" (i.e. we should not have an empty string key in result)assert "" not in result+ def test_single_child_namespace_matches_snapshot_shape(self, session):+ """A lone child remains a mapping; only an exact row is scalar."""+ from local_deep_research.database.models import Setting++ session.add(+ Setting(+ key="single.child",+ name="Single child",+ value="value",+ ui_element="text",+ type="APP",+ )+ )+ session.commit()++ manager = SettingsManager(db_session=session)++ assert manager.get_setting("single") == {"child": "value"}+ assert manager.get_setting("single.child") == "value"+def test_malformed_subkey_rows_dont_wrap_a_leaf_read(self, session):"""A pathological pre-existing malformed row (``foo..`` / ``foo. ``)must not turn a leaf read into a wrapper dict rendered as