From 162b70d82563e97705c0fd8fe99fad25847256ac Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 11 Apr 2026 01:04:03 +0800 Subject: [PATCH] fix: poll status=="completed" in cloud add_document MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The cloud backend previously polled tree_resp["retrieval_ready"] as the ready signal. Empirically this flag is not a reliable indicator — docs can reach status=="completed" without retrieval_ready flipping, causing col.add() to wait until the 10 min timeout before giving up on otherwise-successful uploads. The cloud API's canonical ready signal is status=="completed"; switch the poll to check that instead. --- pageindex/backend/cloud.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pageindex/backend/cloud.py b/pageindex/backend/cloud.py index 587a6c6..bc42c36 100644 --- a/pageindex/backend/cloud.py +++ b/pageindex/backend/cloud.py @@ -141,12 +141,13 @@ class CloudBackend: doc_id = resp["doc_id"] - # Poll until retrieval-ready + # Poll until indexing completes. The cloud API signals readiness via + # status == "completed"; retrieval_ready is not a reliable indicator. for _ in range(120): # 10 min max tree_resp = self._request("GET", f"/doc/{self._enc(doc_id)}/", params={"type": "tree"}) - if tree_resp.get("retrieval_ready"): - return doc_id status = tree_resp.get("status", "") + if status == "completed": + return doc_id if status == "failed": raise CloudAPIError(f"Document {doc_id} indexing failed") time.sleep(5)