{"record":{"id":"f50c7e434ea90705","repo":"cocoindex-io/cocoindex","slug":"settings-db-path-must-be-provided","errorCode":null,"errorMessage":"Settings.db_path must be provided","messagePattern":"Settings\\.db_path must be provided","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/cocoindex/_internal/environment.py","lineNumber":222,"sourceCode":"    _settings: setting.Settings\n    _context_provider: ContextProvider\n    _loop_runner: _LoopRunner\n    _async_context: core.AsyncContext\n    _exception_handler: ExceptionHandler | None\n    _info: EnvironmentInfo\n\n    def __init__(\n        self,\n        settings: setting.Settings,\n        *,\n        name: str | None = None,\n        context_provider: ContextProvider | None = None,\n        event_loop: asyncio.AbstractEventLoop | None = None,\n        exception_handler: ExceptionHandler | None = None,\n        info: EnvironmentInfo | None = None,\n    ):\n        if not settings.db_path:\n            raise ValueError(\"Settings.db_path must be provided\")\n        self._name = name or \"\"\n        self._settings = settings\n        self._context_provider = context_provider or ContextProvider()\n\n        if event_loop is None:\n            event_loop = get_event_loop_or_default()\n\n        if event_loop.is_running():\n            self._loop_runner = _LoopRunner.from_running_loop(event_loop)\n        else:\n            # Keep a loop running for sync users (needed for async callbacks).\n            runner = _LoopRunner(event_loop)\n            runner.ensure_running()\n            self._loop_runner = runner\n\n        self._async_context = core.AsyncContext(self._loop_runner.loop)\n        self._core_env = core.Environment(\n            settings._to_engine_dict(), self._async_context","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/cocoindex-io/cocoindex/blob/e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b/python/cocoindex/_internal/environment.py#L204-L240","documentation":"Environment.__init__ requires Settings.db_path to be set — the environment needs a database location for its state. If settings.db_path is falsy at construction time, a ValueError is raised immediately.","triggerScenarios":"Calling Environment(name, Settings(...)) directly with a Settings object whose db_path is empty/None. Note _get_env normally fills db_path from COCOINDEX_DB; constructing Settings manually bypasses that defaulting.","commonSituations":"Hand-constructing Settings in tests or scripts and forgetting db_path; copying Settings-building code that relies on the env var; refactors that removed db_path assignment.","solutions":["Set db_path explicitly: Settings(db_path=\"/path/to/db\")","Set the COCOINDEX_DB environment variable and build settings via the builder path (_get_env) instead of constructing Settings by hand","Check that the variable holding db_path isn't accidentally empty/None"],"exampleFix":"# before\nenv = coco.Environment(\"myenv\", coco.Settings())\n\n# after\nenv = coco.Environment(\"myenv\", coco.Settings(db_path=\"./cocoindex.db\"))","handlingStrategy":"validation","validationCode":"settings = coco.Settings(db_path=db_path)\nassert settings.db_path, \"Settings.db_path must be set before creating Environment\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass db_path when constructing Settings manually","Prefer the builder/_get_env path which applies the COCOINDEX_DB default","Assert db_path truthiness in test fixtures that build Environments"],"tags":["python","configuration","database"],"backgroundTag":"missing-required-config-field","analyzedSha":"e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b","analyzedAt":"2026-09-08T15:59:19.997Z","contentChangedAt":"2026-09-08T15:59:19.997Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}