mirror of
https://github.com/VectifyAI/PageIndex.git
synced 2026-07-15 21:11:05 +02:00
fix: tolerate empty body on legacy delete_document
delete_document unconditionally called response.json(), so a successful
DELETE that returns 200 with an empty body (the documented examples don't
consume one, and REST APIs commonly return no content for deletes) would
raise JSONDecodeError even though the document was already deleted. Return
{} when the response has no content, else parse the JSON body as before.
This commit is contained in:
parent
1dffa769a2
commit
fc401c912b
2 changed files with 32 additions and 2 deletions
|
|
@ -230,7 +230,11 @@ class LegacyCloudAPI:
|
|||
f"/doc/{self._enc(doc_id)}/",
|
||||
"Failed to delete document",
|
||||
)
|
||||
return response.json()
|
||||
# A successful DELETE may come back with an empty body (the documented
|
||||
# examples don't consume one, and REST APIs commonly return no content
|
||||
# for deletes). Don't let json() raise JSONDecodeError on success —
|
||||
# the document is already gone; return an empty dict.
|
||||
return response.json() if response.content else {}
|
||||
|
||||
def list_documents(
|
||||
self,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue