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:
mountain 2026-07-09 20:18:44 +08:00
parent 1dffa769a2
commit fc401c912b
2 changed files with 32 additions and 2 deletions

View file

@ -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,