~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
[verified] Bound unsupported field names in news update errors (#7415)
Chanhyo Jungc0afc79e856d
diff --git a/changelog.d/+news-update-error-bounds.bugfix.md b/changelog.d/+news-update-error-bounds.bugfix.mdnew file mode 100644index 0000000000..e1dfeed1e8--- /dev/null+++ b/changelog.d/+news-update-error-bounds.bugfix.md@@ -0,0 +1 @@+Bound unsupported field names reflected in news subscription and folder update errors while preserving validation behavior.diff --git a/src/local_deep_research/news/constants.py b/src/local_deep_research/news/constants.pyindex cb5db0c6d5..16d5d8aca8 100644--- a/src/local_deep_research/news/constants.py+++ b/src/local_deep_research/news/constants.py@@ -57,12 +57,28 @@ COMPACT_SUBSCRIPTION_READONLY_ECHO_FIELDS = ()+def _unsupported_update_fields_message(unsupported_fields):+ """Reflect at most eight sorted names, each at most 32 characters.++ Including separators and the omitted-count suffix, this stays below+ 320 characters. This bounds reflected content, not parsing or sorting.+ """+ fields = sorted(unsupported_fields)+ message = ", ".join(+ field if len(field) <= 32 else field[:29] + "..."+ for field in fields[:8]+ )+ if len(fields) > 8:+ message += f", ... (+{len(fields) - 8} more)"+ return message++def compact_subscription_update_error(data):"""Return the validation message for a compact subscription update, or None.Routes return this string to the client directly rather than echoing- ``str()`` of a caught exception, so only these fixed messages can ever- reach the response body.+ ``str()`` of a caught exception. Unsupported names are reflected with+ bounded content; other validation messages are fixed."""unsupported_fields = (set(data)@@ -70,7 +86,7 @@ def compact_subscription_update_error(data):- COMPACT_SUBSCRIPTION_READONLY_ECHO_FIELDS)if unsupported_fields:- fields = ", ".join(sorted(unsupported_fields))+ fields = _unsupported_update_fields_message(unsupported_fields)return f"Unsupported subscription update fields: {fields}"if "is_active" in data and type(data["is_active"]) is not bool:@@ -170,7 +186,7 @@ def folder_update_error(data):set(data) - FOLDER_UPDATABLE_FIELDS - FOLDER_READONLY_ECHO_FIELDS)if unsupported_fields:- fields = ", ".join(sorted(unsupported_fields))+ fields = _unsupported_update_fields_message(unsupported_fields)return f"Unsupported folder update fields: {fields}"# ``name`` is NOT NULL on the SubscriptionFolder model (database/models/diff --git a/tests/news/test_news_update_validation_messages.py b/tests/news/test_news_update_validation_messages.pyindex d8a437d9ef..80c248a578 100644--- a/tests/news/test_news_update_validation_messages.py+++ b/tests/news/test_news_update_validation_messages.py@@ -105,3 +105,71 @@ def test_folder_update_valid():data = {"name": "n", "sort_order": 2, "id": 7}assert folder_update_error(data) is Noneassert normalize_folder_update(data) == {"name": "n", "sort_order": 2}+++ ("validator", "normalize", "prefix", "invalid_known"),+ [+ (+ compact_subscription_update_error,+ normalize_compact_subscription_update,+ "Unsupported subscription update fields: ",+ {"is_active": "yes", "refresh_interval_minutes": False},+ ),+ (+ folder_update_error,+ normalize_folder_update,+ "Unsupported folder update fields: ",+ {"name": None, "sort_order": True},+ ),+ ],+ ids=["subscription", "folder"],+)+ ("keys", "rendered"),+ [+ (["zebra", "alpha"], "alpha, zebra"),+ (["x" * 32], "x" * 32),+ (["x" * 33], "x" * 29 + "..."),+ (["a" * 100_000], "a" * 29 + "..."),+ (["界" * 100_000], "界" * 29 + "..."),+ (+ [f"key_{i:04d}" for i in range(8)],+ "key_0000, key_0001, key_0002, key_0003, "+ "key_0004, key_0005, key_0006, key_0007",+ ),+ (+ [f"key_{i:04d}" for i in range(1_000)],+ "key_0000, key_0001, key_0002, key_0003, "+ "key_0004, key_0005, key_0006, key_0007, ... (+992 more)",+ ),+ (+ [f"{i:04d}" + "x" * 10_000 for i in range(100)],+ ", ".join(f"{i:04d}" + "x" * 25 + "..." for i in range(8))+ + ", ... (+92 more)",+ ),+ ],+ ids=[+ "short-sorted",+ "key-boundary",+ "key-truncated",+ "long-first-key",+ "unicode-long-key",+ "count-boundary",+ "many-keys",+ "many-long-keys",+ ],+)+def test_unsupported_update_fields_bounded(+ validator, normalize, prefix, invalid_known, keys, rendered+):+ expected = prefix + rendered+ for ordered_keys in (keys, list(reversed(keys))):+ data = {key: 1 for key in ordered_keys}+ data.update(invalid_known)+ message = validator(data)+ with pytest.raises(ValueError) as exc:+ normalize(data)+ assert str(exc.value) == message+ assert len(message) <= len(prefix) + 320+ assert message == expected