Skip to content

Commit b3bafa2

Browse files
committed
fix: neutral error message for property index deletion (#2098)
The static delete_property_index error prefix asserted a single cause ("Property may not exist") but the DELETE 422 also covers an invalid index type and the in-flight-reindex mutation guard, whose server message the prefix contradicted. Name the failed operation instead and let the appended response body carry the cause, matching the file's phrasing style. Pin the behavior with a mock test surfacing a server-style 422 in-flight-reindex message.
1 parent ce26136 commit b3bafa2

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

mock_tests/test_property_reindex.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,29 @@ def test_get_property_indexes(
393393
weaviate_139_mock.check_assertions()
394394

395395

396+
def test_delete_property_index_surfaces_server_message(
397+
weaviate_139_mock: HTTPServer, client_139: weaviate.WeaviateClient
398+
) -> None:
399+
"""A DELETE rejection surfaces the server's cause behind a neutral prefix.
400+
401+
The 422 mutation guard (in-flight reindex task) carries an actionable server message;
402+
the client prefix must only name the failed operation, not assert a cause.
403+
"""
404+
server_message = "cannot delete index: a reindex task is in progress for property 'name'"
405+
weaviate_139_mock.expect_request(
406+
f"{SCHEMA_PATH}/properties/name/index/searchable",
407+
method="DELETE",
408+
).respond_with_json({"error": [{"message": server_message}]}, status=422)
409+
410+
with pytest.raises(weaviate.exceptions.UnexpectedStatusCodeError) as e:
411+
client_139.collections.use(COLLECTION).config.delete_property_index("name", "searchable")
412+
assert e.value.status_code == 422
413+
assert "Property index may not have been deleted." in e.value.message
414+
assert server_message in e.value.message
415+
assert "may not exist" not in e.value.message
416+
weaviate_139_mock.check_assertions()
417+
418+
396419
def test_property_reindex_invalid_input(
397420
weaviate_139_mock: HTTPServer, client_139: weaviate.WeaviateClient
398421
) -> None:

weaviate/collections/config/executor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,8 @@ def resp(res: Response) -> bool:
704704
response_callback=resp,
705705
method=self._connection.delete,
706706
path=path,
707-
error_msg="Property may not exist",
708-
status_codes=_ExpectedStatusCodes(ok_in=[200], error="property exists"),
707+
error_msg="Property index may not have been deleted.",
708+
status_codes=_ExpectedStatusCodes(ok_in=[200], error="Delete property index"),
709709
)
710710

711711
def __check_property_reindex_support(self, feature: str) -> None:

0 commit comments

Comments
 (0)