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(settings): type-strict comparison of redacted container leaves (#6230)

Vladimir Babindb370c1ffe7c
diff --git a/changelog.d/6181.bugfix.md b/changelog.d/6181.bugfix.md
new file mode 100644
index 0000000000..daaa2b612a
--- /dev/null
+++ b/changelog.d/6181.bugfix.md
@@ -0,0 +1 @@
+Settings redaction: the container write-back no-op guard now compares non-string leaves by exact type as well as value, so a cross-type edit (e.g. an integer replaced by a boolean or float) inside a redacted sensitive container is no longer misclassified as an untouched round trip.
diff --git a/src/local_deep_research/web/routers/settings.py b/src/local_deep_research/web/routers/settings.py
index 79054261cf..6c04cbe640 100644
--- a/src/local_deep_research/web/routers/settings.py
+++ b/src/local_deep_research/web/routers/settings.py
@@ -663,7 +663,7 @@ def _container_matches_stored_shape(
# confirm the stored counterpart was maskable too, so a non-string
# leaf can't silently "become" a string one under this exemption.
return isinstance(stored_value, str) and bool(stored_value.strip())
- return value == stored_value
+ return type(value) is type(stored_value) and value == stored_value
def _is_secret_empty_noop(
diff --git a/tests/security/test_settings_secret_redaction_isolation.py b/tests/security/test_settings_secret_redaction_isolation.py
index ea7c4c8317..4c7a329591 100644
--- a/tests/security/test_settings_secret_redaction_isolation.py
+++ b/tests/security/test_settings_secret_redaction_isolation.py
@@ -537,6 +537,45 @@ def test_container_non_string_leaf_edit_is_not_a_silent_noop():
)
+def test_container_cross_type_leaf_edit_is_not_a_silent_noop():
+ """#6181: the non-maskable-leaf comparison must be type-strict. Python
+ equality is not: ``1 == 1.0`` and ``True == 1`` are both true, so a
+ stored ``{"token": "s", "mode": 1}`` submitted back as
+ ``{"token": "[REDACTED]", "mode": True}`` (or ``1.0``) would slip past
+ the no-op arm as an untouched round-trip and drop the requested type
+ change. The stored-shape check now requires identical type AND value.
+ """
+ from local_deep_research.web.routers.settings import (
+ _embeds_redaction_sentinel,
+ _is_secret_empty_noop,
+ )
+
+ stored = {"token": "s", "mode": 1}
+
+ bool_for_int = {"token": REDACTED, "mode": True}
+ assert not _is_secret_empty_noop(
+ BROADENED_ARM_KEY, None, bool_for_int, stored
+ )
+ assert _embeds_redaction_sentinel(
+ BROADENED_ARM_KEY, None, bool_for_int, stored
+ )
+
+ float_for_int = {"token": REDACTED, "mode": 1.0}
+ assert not _is_secret_empty_noop(
+ BROADENED_ARM_KEY, None, float_for_int, stored
+ )
+ assert _embeds_redaction_sentinel(
+ BROADENED_ARM_KEY, None, float_for_int, stored
+ )
+
+ # Same type and value stays a genuine no-op.
+ untouched = {"token": REDACTED, "mode": 1}
+ assert _is_secret_empty_noop(BROADENED_ARM_KEY, None, untouched, stored)
+ assert not _embeds_redaction_sentinel(
+ BROADENED_ARM_KEY, None, untouched, stored
+ )
+
+
def test_container_sentinel_on_create_has_no_noop_exemption():
"""Creation has no prior stored value, so unlike the update path, even
the pure round-trip shape (every leaf exactly the sentinel) cannot mean