{"record":{"id":"8ea374162fd67537","repo":"chroma-core/chroma","slug":"resetting-the-database-is-not-allowed-set-allow","errorCode":null,"errorMessage":"Resetting the database is not allowed. Set `allow_reset` to true in the config in tests or other non-production environments where reset should be permitted.","messagePattern":"Resetting the database is not allowed\\. Set `allow_reset` to true in the config in tests or other non-production environments where reset should be permitted\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/db/impl/sqlite.py","lineNumber":150,"sourceCode":"    @override\n    def migration_scope() -> str:\n        return \"sqlite\"\n\n    @override\n    def migration_dirs(self) -> Sequence[Traversable]:\n        return self._migration_imports\n\n    @override\n    def tx(self) -> TxWrapper:\n        if not hasattr(self._tx_stack, \"stack\"):\n            self._tx_stack.stack = []\n        return TxWrapper(self._conn_pool, stack=self._tx_stack)\n\n    @trace_method(\"SqliteDB.reset_state\", OpenTelemetryGranularity.ALL)\n    @override\n    def reset_state(self) -> None:\n        if not self._settings.require(\"allow_reset\"):\n            raise ValueError(\n                \"Resetting the database is not allowed. Set `allow_reset` to true in the config in tests or other non-production environments where reset should be permitted.\"\n            )\n        with self.tx() as cur:\n            # Drop all tables\n            cur.execute(\n                \"\"\"\n                    SELECT name FROM sqlite_master\n                    WHERE type='table'\n                    \"\"\"\n            )\n            for row in cur.fetchall():\n                cur.execute(f\"DROP TABLE IF EXISTS {row[0]}\")\n        self._conn_pool.close()\n        self.start()\n        super().reset_state()\n\n    @trace_method(\"SqliteDB.setup_migrations\", OpenTelemetryGranularity.ALL)\n    @override","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/db/impl/sqlite.py#L132-L168","documentation":"SqliteDB.reset_state (chromadb/db/impl/sqlite.py) drops every table in the SQLite catalog file. It independently re-checks the same guard as System-level reset - settings.require('allow_reset') - and raises ValueError when the flag is unset. So even direct, component-level resets honor the allow_reset=False default; this is the error you see from client.reset() on an embedded/persistent deployment.","triggerScenarios":"client.reset() on a PersistentClient without allow_reset=True (the reset cascades down to SqliteDB.reset_state); custom harnesses calling the SqliteDB component's reset_state directly.","commonSituations":"Integration-test teardown that resets the embedded database between tests; dev scripts that want a clean slate but reuse the app's Settings.","solutions":["Enable the guard for the test/dev process: Settings(allow_reset=True) or env ALLOW_RESET=TRUE.","For local development, deleting the persist directory / .sqlite files is an alternative that needs no flag.","Keep allow_reset out of production configs entirely - the guard exists to protect persisted data."],"exampleFix":"// before\nsettings = chromadb.Settings(persist_directory='./data')\nclient = chromadb.PersistentClient(settings=settings)\nclient.reset()  # ValueError: Resetting the database is not allowed\n\n// after (tests only)\nsettings = chromadb.Settings(persist_directory='./data', allow_reset=True)\nclient = chromadb.PersistentClient(settings=settings)\nclient.reset()","handlingStrategy":"validation","validationCode":"if not settings.allow_reset:\n    settings = settings.model_copy(update={'allow_reset': True})  # tests/dev only\nclient = chromadb.PersistentClient(path='./data', settings=settings)\nclient.reset()  # reaches SqliteDB.reset_state with the guard satisfied","typeGuard":null,"tryCatchPattern":"try:\n    client.reset()\nexcept ValueError as e:\n    if 'Resetting the database is not allowed' in str(e):\n        # alternative for local dev: just delete the files\n        raise RuntimeError('set allow_reset=True, or delete the ./data sqlite files instead') from e\n    raise","preventionTips":["In local dev, deleting the persist directory avoids enabling reset at all.","Keep allow_reset absent from every production settings file; add a CI lint that fails if it appears.","Reset via client.reset() (cascades properly) rather than poking component internals."],"tags":["sqlite","reset","configuration","guard"],"backgroundTag":"reset-not-allowed","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}