Skip to content

Commit ef7abac

Browse files
jfrancoaclaude
andcommitted
fix: accept 202 for namespace delete to match server response
The server returns 202 Accepted for DELETE /namespaces/{name} because cleanup of classes, aliases, and namespaced users completes asynchronously. The client was declaring ok_in=[204], so successful deletions surfaced as errors even though the server-side delete went through. Align the status code with the spec and document the async behaviour, and update the mock test accordingly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 74a037f commit ef7abac

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

mock_tests/test_namespaces.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,12 @@ def test_namespaces_list_all_handles_empty_array(
194194
# ---------------------------------------------------------------------------
195195

196196

197-
def test_namespaces_delete_accepts_204(
197+
def test_namespaces_delete_accepts_202(
198198
ns_client: Tuple[weaviate.WeaviateClient, HTTPServer],
199199
) -> None:
200200
client, server = ns_client
201201
server.expect_request("/v1/namespaces/myns", method="DELETE").respond_with_response(
202-
Response(status=204)
202+
Response(status=202)
203203
)
204204

205205
# Must not raise; returns None.

weaviate/namespaces/base.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ def resp(res: Response) -> List[Namespace]:
8686
def delete(self, *, name: str) -> executor.Result[None]:
8787
"""Delete a namespace.
8888
89+
The server marks the namespace for deletion and cleans up its classes,
90+
aliases, and users asynchronously, so this call returns as soon as the
91+
deletion has been accepted (HTTP 202), not when cleanup has finished.
92+
8993
Args:
9094
name: The name of the namespace to delete.
9195
"""
@@ -99,5 +103,5 @@ def resp(res: Response) -> None:
99103
method=self._connection.delete,
100104
path=f"/namespaces/{name}",
101105
error_msg=f"Could not delete namespace '{name}'",
102-
status_codes=_ExpectedStatusCodes(ok_in=[204], error="Delete namespace"),
106+
status_codes=_ExpectedStatusCodes(ok_in=[202], error="Delete namespace"),
103107
)

0 commit comments

Comments
 (0)