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(news): accept up to 20 questions per iteration to match the subscription form (#6382)

Sebastian Cao112ffdd502b0
diff --git a/changelog.d/6066.bugfix.md b/changelog.d/6066.bugfix.md
new file mode 100644
index 0000000000..e5ef3b3e24
--- /dev/null
+++ b/changelog.d/6066.bugfix.md
@@ -0,0 +1,4 @@
+The news subscription API again accepts 11-20 questions per iteration,
+matching the subscription form's advertised maximum of 20. The FastAPI
+migration had capped the API at 10, so form submissions and edits of
+existing subscriptions with higher values received an HTTP 400.
diff --git a/src/local_deep_research/web/routers/news_flask_api.py b/src/local_deep_research/web/routers/news_flask_api.py
index f59b80348f..1124b976b4 100644
--- a/src/local_deep_research/web/routers/news_flask_api.py
+++ b/src/local_deep_research/web/routers/news_flask_api.py
@@ -51,7 +51,10 @@ NEWS_SUBSCRIPTION_MIN_REFRESH_MINUTES = 1
NEWS_SUBSCRIPTION_MAX_REFRESH_MINUTES = 10_080
NEWS_SUBSCRIPTION_MAX_QUERY_LENGTH = 10_000
NEWS_SUBSCRIPTION_MAX_SEARCH_ITERATIONS = 20
-NEWS_SUBSCRIPTION_MAX_QUESTIONS_PER_ITERATION = 10
+# The subscription form (news-subscription-form.html) advertises max="20"
+# for this field, and subscriptions saved with 11-20 must stay editable, so
+# the API cap cannot be lowered without a migration path (#6066).
+NEWS_SUBSCRIPTION_MAX_QUESTIONS_PER_ITERATION = 20
def _subscription_validation_error(message: str) -> JSONResponse:
diff --git a/tests/web/routers/test_news_api_routes_ported.py b/tests/web/routers/test_news_api_routes_ported.py
index 19926fbbc3..23443756a0 100644
--- a/tests/web/routers/test_news_api_routes_ported.py
+++ b/tests/web/routers/test_news_api_routes_ported.py
@@ -49,7 +49,9 @@ TestClient follows by default and Flask's did not.
"""
import json
+import re
import uuid
+from pathlib import Path
from unittest.mock import MagicMock, patch
import pytest
@@ -404,6 +406,45 @@ class TestSubscriptionPayloadValidator:
is None
)
+ def test_questions_per_iteration_public_limit_is_the_forms_20(self):
+ """Cross-layer pin of the questions-per-iteration boundary.
+
+ The shipped subscription form advertises ``max="20"``, so the API
+ must accept 20 or form submissions and previously saved values
+ 11-20 get a 400 (#6066). Every other expectation in this file is
+ derived from the server constant and would silently follow it
+ anywhere, so both layers are pinned to the literal number here.
+ """
+ template = (
+ Path(news_flask_api.__file__).parents[1]
+ / "templates"
+ / "pages"
+ / "news-subscription-form.html"
+ )
+ form_max = re.search(
+ r'id="subscription-questions"[^>]*max="(\d+)"',
+ template.read_text(encoding="utf-8"),
+ )
+ assert form_max is not None, (
+ "the form no longer declares a questions-per-iteration max"
+ )
+ assert int(form_max.group(1)) == 20
+ assert (
+ news_flask_api.NEWS_SUBSCRIPTION_MAX_QUESTIONS_PER_ITERATION == 20
+ )
+ assert (
+ news_flask_api._validate_subscription_payload(
+ {"questions_per_iteration": 20}
+ )
+ is None
+ )
+ assert (
+ news_flask_api._validate_subscription_payload(
+ {"questions_per_iteration": 21}
+ ).status_code
+ == 400
+ )
+
# ===========================================================================
# POST /news/api/vote -- the route had no Python test at all