Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
fix(storage): propagate Volcengine deletion request failures (#5268)
Lusen Dongf0743df9e4f6
diff --git a/openviking/storage/vectordb/collection/volcengine_collection.py b/openviking/storage/vectordb/collection/volcengine_collection.pyindex a7fdbf929..7ff1b569a 100644--- a/openviking/storage/vectordb/collection/volcengine_collection.py+++ b/openviking/storage/vectordb/collection/volcengine_collection.py@@ -453,7 +453,7 @@ class VolcengineCollection(ICollection):"collection_name": self.collection_name,"ids": primary_keys,}- return self._data_post(path, data)+ return self._data_post(path, data, raise_for_status=True)def delete_all_data(self):path = "/api/vikingdb/data/delete"@@ -462,7 +462,7 @@ class VolcengineCollection(ICollection):"collection_name": self.collection_name,"del_all": True,}- return self._data_post(path, data)+ return self._data_post(path, data, raise_for_status=True)def _parse_fetch_result(self, data: Dict[str, Any]) -> FetchDataInCollectionResult:result = FetchDataInCollectionResult()@@ -647,7 +647,7 @@ class VolcengineCollection(ICollection):"offset": offset,"ignore_unknown_fields": True,}- resp_data = self._data_post(path, data)+ resp_data = self._data_post(path, data, raise_for_status=True)return self._parse_search_result(resp_data)def _parse_aggregate_result(diff --git a/tests/storage/test_volcengine_clients.py b/tests/storage/test_volcengine_clients.pyindex f83a974b2..b5fb1fc13 100644--- a/tests/storage/test_volcengine_clients.py+++ b/tests/storage/test_volcengine_clients.py@@ -326,6 +326,56 @@ def test_volcengine_collection_update_data_posts_to_update_endpoint(monkeypatch)}[email protected]("failure_path", ["/search/scalar", "/delete"])[email protected]("response_kind", [429, 500, "invalid_json", "success"])+def test_volcengine_delete_propagates_request_failures(monkeypatch, failure_path, response_kind):+ collection = VolcengineCollection(+ ak="test-ak",+ sk="test-sk",+ region="cn-beijing",+ meta_data={"ProjectName": "default", "CollectionName": "context"},+ )+ adapter = VolcengineCollectionAdapter.from_config(+ VectorDBBackendConfig(+ backend="volcengine",+ name="context",+ volcengine=VolcengineConfig(ak="test-ak", sk="test-sk", region="cn-beijing"),+ )+ )+ adapter._collection = Collection(collection)+ deleted_ids = []++ def fake_request(method, path, req_body):+ response = requests.Response()+ response.status_code = 200+ if path.endswith("/search/scalar"):+ response._content = (+ b'{"result":{"data":[{"id":"doc-1"}]}}'+ if req_body["offset"] == 0+ else b'{"result":{"data":[]}}'+ )+ else:+ assert path.endswith("/delete")+ deleted_ids.extend(req_body["ids"])+ response._content = b'{"result":{}}'+ if path.endswith(failure_path) and response_kind != "success":+ response.status_code = response_kind if isinstance(response_kind, int) else 200+ response._content = b"invalid JSON" if response_kind == "invalid_json" else b"{}"+ return response++ monkeypatch.setattr(collection.data_client, "do_req", fake_request)+ scope = {"op": "must", "field": "uri", "conds": ["/resources/expired"]}+ if response_kind == "success":+ assert adapter.delete(filter=scope) == 1+ assert deleted_ids == ["doc-1"]+ else:+ message = "invalid JSON" if response_kind == "invalid_json" else str(response_kind)+ with pytest.raises(ConnectionError, match=message):+ adapter.delete(filter=scope)+ if failure_path == "/search/scalar":+ assert deleted_ids == []++def test_volcengine_collection_update_data_sanitizes_uri_fields(monkeypatch):captured = {}