~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
"""Regression tests for the two bugs the 15-agent adversarial review confirmed
on the Notes-feature merge:
1. library_delete.delete_document_blob returned a Flask ``(body, status)`` tuple
-> FastAPI served HTTP 200 with a ``[{...}, 404]`` array body instead of 404.
2. notes._notes_json_body only enforced the 100 MB cap when a Content-Length
header was present, so a chunked body (no Content-Length) skipped the 413.
"""
import uuid
import pytest
from fastapi.testclient import TestClient
@pytest.fixture(scope="module")
def client():
from local_deep_research.web.fastapi_app import app
c = TestClient(app, raise_server_exceptions=False)
user = f"reviewfix_{uuid.uuid4().hex[:8]}"
pw = "TestPassword123!" # noqa: S105
def _csrf():
c.get("/auth/login")
r = c.get("/auth/csrf-token")
return r.json().get("csrf_token", "") if r.status_code == 200 else ""
c.post(
"/auth/register",
data={
"username": user,
"password": pw,
"confirm_password": pw,
"acknowledge": "true",
"csrf_token": _csrf(),
},
follow_redirects=False,
)
resp = c.post(
"/auth/login",
data={"username": user, "password": pw, "csrf_token": _csrf()},
follow_redirects=False,
)
if resp.status_code != 302:
pytest.fail(
f"Auth bootstrap broken: login returned {resp.status_code} "
f"(expected 302): {resp.text[:300]}"
)
yield c
def _csrf(client):
client.get("/auth/login")
return client.get("/auth/csrf-token").json().get("csrf_token", "")
def test_delete_blob_unknown_document_returns_404_not_tuple(client):
# Bug 1: previously returned HTTP 200 with body [{...}, 404]. The blob
# delete of a non-existent document must be a real 404 with a JSON object.
r = client.delete(
"/library/api/document/does-not-exist/blob",
headers={"X-CSRFToken": _csrf(client)},
)
assert r.status_code == 404, r.text[:200]
body = r.json()
assert isinstance(body, dict), f"body must be an object, got {type(body)}"
assert body["success"] is False
def test_notes_chunked_oversized_body_is_413(client, monkeypatch):
# Bug 2: a chunked request (no Content-Length) must still be capped at the
# notes ceiling. Shrink the cap so the test body is tiny.
import local_deep_research.web.routers.notes as notes_mod
monkeypatch.setattr(notes_mod, "_MAX_JSON_BODY_BYTES", 64)
def _chunked_body():
# A generator content makes httpx send Transfer-Encoding: chunked
# with NO Content-Length header — the exact shape the old check missed.
yield b'{"title": "'
yield b"x" * 200
yield b'"}'
r = client.post(
"/notes/api/notes",
content=_chunked_body(),
headers={
"X-CSRFToken": _csrf(client),
"Content-Type": "application/json",
},
)
assert r.status_code == 413, (
f"chunked over-cap body should 413, got {r.status_code}: {r.text[:150]}"
)
assert r.json()["success"] is False
def test_notes_chunked_small_body_still_works(client, monkeypatch):
# The stream cap must not break a normal chunked body under the limit.
import local_deep_research.web.routers.notes as notes_mod
monkeypatch.setattr(notes_mod, "_MAX_JSON_BODY_BYTES", 10_000)
def _small_chunked():
yield b'{"title": "chunked", '
yield b'"content": "hello"}'
r = client.post(
"/notes/api/notes",
content=_small_chunked(),
headers={
"X-CSRFToken": _csrf(client),
"Content-Type": "application/json",
},
)
assert r.status_code == 201, r.text[:200]
assert r.json()["success"] is True