{"record":{"id":"a9f065804178e2a6","repo":"FoundationAgents/MetaGPT","slug":"delete-collection-collection-name-failed","errorCode":null,"errorMessage":"Delete collection {collection_name} failed.","messagePattern":"Delete collection (.+?) failed\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"metagpt/document_store/qdrant_store.py","lineNumber":76,"sourceCode":"            self.client.get_collection(collection_name)\n            if force_recreate:\n                res = self.client.recreate_collection(collection_name, vectors_config=vectors_config, **kwargs)\n                return res\n            return True\n        except:  # noqa: E722\n            return self.client.recreate_collection(collection_name, vectors_config=vectors_config, **kwargs)\n\n    def has_collection(self, collection_name: str):\n        try:\n            self.client.get_collection(collection_name)\n            return True\n        except:  # noqa: E722\n            return False\n\n    def delete_collection(self, collection_name: str, timeout=60):\n        res = self.client.delete_collection(collection_name, timeout=timeout)\n        if not res:\n            raise Exception(f\"Delete collection {collection_name} failed.\")\n\n    def add(self, collection_name: str, points: List[PointStruct]):\n        \"\"\"\n        add some vector data to qdrant\n        Args:\n            collection_name: collection name\n            points: list of PointStruct object, about PointStruct detail in https://github.com/qdrant/qdrant-client\n\n        Returns: NoneX\n\n        \"\"\"\n        # self.client.upload_records()\n        self.client.upsert(\n            collection_name,\n            points,\n        )\n\n    def search(","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/FoundationAgents/MetaGPT/blob/11cdf466d042aece04fc6cfd13b28e1a70341b1f/metagpt/document_store/qdrant_store.py#L58-L94","documentation":"QdrantStore.delete_collection calls client.delete_collection(...) and treats a falsy return as failure, raising 'Delete collection {name} failed.'. The qdrant-client update_collection-style APIs return an operation result/bool; when the server reports the deletion did not succeed (or the client returns None/False), this guard fires. Note the f-string interpolates the literal '{collection_name}' only if the raise is re-raised from source; in practice the actual name is embedded.","triggerScenarios":"Calling delete_collection(name, timeout=...) when the collection does not exist or is already being deleted; a server-side error swallowed by the client and returned as a non-truthy result; a timeout shorter than the deletion time for large collections.","commonSituations":"Cleanup code running twice (second run targets an already-deleted collection); force_recreate flows in create_collection where has/deleted state races; self-hosted Qdrant under load where deletion exceeds the default 60s timeout.","solutions":["Check existence first: if not store.has_collection(name): skip — has_collection already wraps server errors as False.","Increase the timeout: store.delete_collection(name, timeout=300) for large collections.","Retry once after verifying the collection still exists, since transient server errors can return falsy results.","Inspect Qdrant server logs for the underlying reason the operation was rejected."],"exampleFix":"# before\nstore.delete_collection(\"docs\")  # Exception: Delete collection docs failed.\n\n# after\nif store.has_collection(\"docs\"):\n    store.delete_collection(\"docs\", timeout=300)\nelse:\n    logger.info(\"collection 'docs' already absent\")","handlingStrategy":"try-catch","validationCode":"if store.has_collection(collection_name):\n    store.delete_collection(collection_name, timeout=300)","typeGuard":null,"tryCatchPattern":"try:\n    store.delete_collection(name, timeout=300)\nexcept Exception as e:\n    if \"failed\" not in str(e).lower() or store.has_collection(name):\n        raise  # real failure only if the collection still exists\n    logger.warning(\"collection %s already gone\", name)","preventionTips":["Check has_collection() before delete_collection() so cleanup is idempotent.","Pass a generous timeout for large collections (the default is 60s).","Log the collection name and server state when deletion fails so root causes in Qdrant logs can be correlated."],"tags":["python","qdrant","vector-store","cleanup","idempotency"],"backgroundTag":null,"analyzedSha":"11cdf466d042aece04fc6cfd13b28e1a70341b1f","analyzedAt":"2026-08-14T23:20:02.994Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}