Weise bei einem Paperless-Fehler auf die Kombination aus allen Tags und Zusatzfeld hin, die Paperless selbst mit HTTP 500 beantwortet.
Deploy Development / deploy (push) Successful in 49s
Test Suite / pytest-backend (push) Failing after 6m4s
Test Suite / smoke-dev (push) Successful in 1s
Test Suite / frontend-build (push) Successful in 24s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
StommerandClaude Sonnet 5.5 committed 2026-10-25 06:58:07 +01:00
1 parent 0f2b7a8fab
commit ffdaf1c721
2 files changed
+14 -3

No files matched your search

+7 -3
View File
@@ -417,7 +417,10 @@ def paperless_documents(conn, owner_id: UUID, query: str, connector_id: UUID | N
release_for_external(conn)
names = _paperless_lookup(row["id"], base, row["secret"])
params = _paperless_params(query, options, names["custom_fields"])
payload = _paperless_get(base, row["secret"], "/api/documents/", params)
# Observed on a real instance: all-tags together with a custom field makes Paperless answer 500.
clash = "," in params.get("tags__id__all", "") and "custom_field_query" in params
hint = "Das tritt auf, wenn „Alle gewählten Tags“ mit einem Zusatzfeld zusammentrifft. Wähle „Mindestens eines“ oder lass das Zusatzfeld weg." if clash else ""
payload = _paperless_get(base, row["secret"], "/api/documents/", params, hint)
assert_still_owned(conn, row["id"], owner_id)
terms = _search_terms(query, (options or {}).get("title"))
items = []
@@ -1005,7 +1008,7 @@ def _filename(disposition: str | None) -> str:
return value.replace("\\", "").replace("/", "")[:180]
def _paperless_get(base: str, token: str, path: str, params: dict) -> dict:
def _paperless_get(base: str, token: str, path: str, params: dict, hint: str = "") -> dict:
url = f"{base}{path}?{urlencode(params)}"
request = Request(url, headers={"Authorization": f"Token {token}", "Accept": "application/json"})
try:
@@ -1014,7 +1017,8 @@ def _paperless_get(base: str, token: str, path: str, params: dict) -> dict:
except HTTPError as exc:
if exc.code in {401, 403}:
raise unprocessable("Paperless hat den Schlüssel abgelehnt.") from exc
raise unprocessable(f"Paperless hat die Anfrage nicht beantwortet ({_refusal(exc, path)}).") from exc
advice = f" {hint}" if hint and exc.code >= 500 else ""
raise unprocessable(f"Paperless hat die Anfrage nicht beantwortet ({_refusal(exc, path)}).{advice}") from exc
except (URLError, TimeoutError, json.JSONDecodeError) as exc:
raise unprocessable("Paperless ist nicht erreichbar.") from exc
+7
View File
@@ -677,6 +677,13 @@ def test_paperless_refusal_names_the_status_and_reason(monkeypatch):
with pytest.raises(Problem) as caught:
sources._paperless_get("https://paper.example.test", "token-alpha", "/api/documents/", {})
assert caught.value.detail.endswith("(HTTP 500 auf /api/documents/).")
with pytest.raises(Problem) as caught:
sources._paperless_get("https://paper.example.test", "token-alpha", "/api/documents/", {}, "Hinweis.")
assert caught.value.detail.endswith("(HTTP 500 auf /api/documents/). Hinweis.")
monkeypatch.setattr(sources, "urlopen", refuse(400, b"{}"))
with pytest.raises(Problem) as caught:
sources._paperless_get("https://paper.example.test", "token-alpha", "/api/documents/", {}, "Hinweis.")
assert "Hinweis" not in caught.value.detail
monkeypatch.setattr(sources, "urlopen", refuse(403, b"{}"))
with pytest.raises(Problem) as caught:
sources._paperless_get("https://paper.example.test", "token-alpha", "/api/documents/", {})