mirror of
https://github.com/VectifyAI/PageIndex.git
synced 2026-07-15 21:11:05 +02:00
fix(cloud): align cloud/local backend contracts and harden the HTTP layer
Fixes the cloud/local contract mismatches from the PR #272 review (verified against the official API docs — the cloud API has no folder/collection endpoints publicly, GET /docs supports limit<=100 with offset): - query_stream: emit a terminal answer_done event with the full answer (same contract as the local backend); raise CloudAPIError instead of disguising HTTP errors as answer events; move the initial connect inside try so a connection failure can no longer strand the consumer awaiting a sentinel that never arrives - _request: rewind file objects before retrying so a transient 5xx/429 during upload no longer re-sends an empty multipart body; carry the HTTP status on CloudAPIError (status_code) and keep the last status in the max-retries error - list_documents: paginate with limit/offset instead of a hard-coded limit=100, so >100-doc collections are no longer silently truncated (whole-collection queries rely on this list) - folders: treat only 403/404 as "folders unavailable" (warned via warnings.warn instead of an invisible logger.warning, matched on status_code instead of a "403" substring); transient errors now propagate instead of being permanently cached as folder_id=None - error taxonomy parity: cloud doc endpoints map HTTP 404 to DocumentNotFoundError; local get_document raises DocumentNotFoundError instead of returning {}; local delete_document raises on missing doc_id instead of silently deleting nothing - cloud get_document warns that include_text is not supported instead of silently ignoring it Adds regression tests for each fix (11 new tests). Claude-Session: https://claude.ai/code/session_01Kx5DgKbhK1N8autqXH8SmS
This commit is contained in:
parent
cc7e43c810
commit
284ce005f5
5 changed files with 366 additions and 74 deletions
|
|
@ -141,3 +141,17 @@ def test_normalize_doc_ids():
|
|||
def test_normalize_doc_ids_rejects_empty_list():
|
||||
with pytest.raises(ValueError, match="cannot be empty"):
|
||||
LocalBackend._normalize_doc_ids([])
|
||||
|
||||
|
||||
# ── error taxonomy: missing docs raise DocumentNotFoundError ─────────────────
|
||||
|
||||
def test_get_document_missing_raises(backend):
|
||||
backend.get_or_create_collection("papers")
|
||||
with pytest.raises(DocumentNotFoundError, match="ghost"):
|
||||
backend.get_document("papers", "ghost")
|
||||
|
||||
|
||||
def test_delete_document_missing_raises(backend):
|
||||
backend.get_or_create_collection("papers")
|
||||
with pytest.raises(DocumentNotFoundError, match="ghost"):
|
||||
backend.delete_document("papers", "ghost")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue