mirror of
https://github.com/VectifyAI/PageIndex.git
synced 2026-07-15 21:11:05 +02:00
fix(cloud_api): restore legacy is_retrieval_ready swallow-on-error contract
For faithful 0.2.x cloud SDK drop-in compatibility, is_retrieval_ready again swallows PageIndexAPIError and returns False (instead of raising), so existing `while not is_retrieval_ready(...)` polling loops behave exactly as before. Documented that this can loop forever on a permanent error — that is the legacy contract; callers guard their own loops. (The new SDK's own indexing path doesn't use this method — it polls document status with a bounded 120-attempt cap — so the infinite-loop risk is confined to legacy-SDK usage that already had it.) Test updated to assert the swallow behavior. Claude-Session: https://claude.ai/code/session_01Kx5DgKbhK1N8autqXH8SmS
This commit is contained in:
parent
b2756c73d2
commit
154c483fb1
2 changed files with 14 additions and 11 deletions
|
|
@ -326,15 +326,14 @@ def test_empty_api_key_warns_and_falls_back_to_local(caplog, tmp_path, monkeypat
|
|||
assert client._legacy_cloud_api is None
|
||||
|
||||
|
||||
def test_is_retrieval_ready_propagates_api_errors(monkeypatch):
|
||||
"""Regression: API failures (revoked key etc.) were swallowed as False,
|
||||
turning `while not is_retrieval_ready(...)` into an infinite poll."""
|
||||
def test_is_retrieval_ready_swallows_errors_like_legacy_sdk(monkeypatch):
|
||||
"""Faithful 0.2.x contract: API errors are swallowed and reported as
|
||||
"not ready" (False), so existing polling loops behave identically."""
|
||||
def fake_request(method, url, **kwargs):
|
||||
return FakeResponse(status_code=401, text="invalid api key")
|
||||
|
||||
monkeypatch.setattr("pageindex.cloud_api.requests.request", fake_request)
|
||||
with pytest.raises(PageIndexAPIError):
|
||||
PageIndexClient("pi-test").is_retrieval_ready("doc-1")
|
||||
assert PageIndexClient("pi-test").is_retrieval_ready("doc-1") is False
|
||||
|
||||
|
||||
def test_legacy_urls_encode_special_char_ids(monkeypatch):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue