{"record":{"id":"ccc96663fe6fa77c","repo":"microsoft/autogen","slug":"reset-not-allowed-set-allow-reset-true-in-config","errorCode":null,"errorMessage":"Reset not allowed. Set allow_reset=True in config to enable.","messagePattern":"Reset not allowed\\. Set allow_reset=True in config to enable\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/memory/chromadb/_chromadb.py","lineNumber":440,"sourceCode":"            raise RuntimeError(\"Failed to initialize ChromaDB\")\n\n        try:\n            results = self._collection.get()\n            if results and results[\"ids\"]:\n                self._collection.delete(ids=results[\"ids\"])\n        except Exception as e:\n            logger.error(f\"Failed to clear ChromaDB collection: {e}\")\n            raise\n\n    async def close(self) -> None:\n        \"\"\"Clean up ChromaDB client and resources.\"\"\"\n        self._collection = None\n        self._client = None\n\n    async def reset(self) -> None:\n        self._ensure_initialized()\n        if not self._config.allow_reset:\n            raise RuntimeError(\"Reset not allowed. Set allow_reset=True in config to enable.\")\n\n        if self._client is not None:\n            try:\n                self._client.reset()\n            except Exception as e:\n                logger.error(f\"Error during ChromaDB reset: {e}\")\n            finally:\n                self._collection = None\n\n    def _to_config(self) -> ChromaDBVectorMemoryConfig:\n        \"\"\"Serialize the memory configuration.\"\"\"\n\n        return self._config\n\n    @classmethod\n    def _from_config(cls, config: ChromaDBVectorMemoryConfig) -> Self:\n        \"\"\"Deserialize the memory configuration.\"\"\"\n","sourceCodeStart":422,"sourceCodeEnd":458,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/memory/chromadb/_chromadb.py#L422-L458","documentation":"reset() is a destructive operation (wipes the whole ChromaDB client, all collections), so it is gated by the allow_reset flag in ChromaDBMemoryConfig (default False). Calling reset() without allow_reset=True raises RuntimeError to prevent accidental data loss.","triggerScenarios":"await memory.reset() on a ChromaDBVectorMemory whose config was built with default allow_reset=False; explicitly constructing ChromaDBVectorMemoryConfig(allow_reset=False) and then resetting; calling reset() in test teardown on a production-configured memory.","commonSituations":"Test helpers that reset state between cases while reusing a production config; copying example config into tests without noticing the safety flag; assuming reset() only clears one collection (it resets the entire client).","solutions":["If a full wipe is intended, construct the config with ChromaDBVectorMemoryConfig(..., allow_reset=True) — ideally only in tests.","If you only want to empty one collection, use clear() instead of reset(); it does not require the flag.","Keep allow_reset=True scoped to test/dev configs and never enable it for persistent production stores."],"exampleFix":"# before\nconfig = ChromaDBVectorMemoryConfig(collection_name='memos')\nmemory = ChromaDBVectorMemory(config=config)\nawait memory.reset()  # RuntimeError\n\n# after (tests only)\nconfig = ChromaDBVectorMemoryConfig(collection_name='memos', allow_reset=True)\nmemory = ChromaDBVectorMemory(config=config)\nawait memory.reset()","handlingStrategy":"validation","validationCode":"def can_reset(memory) -> bool:\n    return bool(memory._config.allow_reset) and getattr(memory, '_client', None) is not None","typeGuard":null,"tryCatchPattern":"try:\n    await memory.reset()\nexcept RuntimeError as e:\n    if 'Reset not allowed' in str(e):\n        await memory.clear()  # non-destructive fallback for one collection\n    else:\n        raise","preventionTips":["Default to clear() for per-collection wipes; reserve reset() for tests","Set allow_reset=True only in test/dev configs","Never wire reset() into production request paths"],"tags":["chromadb","data-safety","configuration","memory"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}