{"record":{"id":"869e3018d752f613","repo":"microsoft/graphrag","slug":"base-dir-must-be-specified-for-file-based-template","errorCode":null,"errorMessage":"base_dir must be specified for file-based template managers.","messagePattern":"base_dir must be specified for file-based template managers\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/graphrag-llm/graphrag_llm/config/template_engine_config.py","lineNumber":49,"sourceCode":"        default=None,\n        description=\"The base directory for file-based template managers.\",\n    )\n\n    template_extension: str | None = Field(\n        default=None,\n        description=\"The file extension for locating templates in file-based template managers.\",\n    )\n\n    encoding: str | None = Field(\n        default=None,\n        description=\"The file encoding for reading templates in file-based template managers.\",\n    )\n\n    def _validate_file_template_manager_config(self) -> None:\n        \"\"\"Validate parameters for file-based template managers.\"\"\"\n        if self.base_dir is not None and self.base_dir.strip() == \"\":\n            msg = \"base_dir must be specified for file-based template managers.\"\n            raise ValueError(msg)\n\n        if (\n            self.template_extension is not None\n            and self.template_extension.strip() == \"\"\n        ):\n            msg = \"template_extension cannot be an empty string for file-based template managers.\"\n            raise ValueError(msg)\n\n        if (\n            self.template_extension is not None\n            and not self.template_extension.startswith(\".\")\n        ):\n            self.template_extension = f\".{self.template_extension}\"\n\n    @model_validator(mode=\"after\")\n    def _validate_model(self):\n        \"\"\"Validate the template engine configuration based on its type.\"\"\"\n        if self.template_manager == TemplateManagerType.File:","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/microsoft/graphrag/blob/f40e9a26ce62ba0b3fef8837d24aafdcc6e6c704/packages/graphrag-llm/graphrag_llm/config/template_engine_config.py#L31-L67","documentation":"TemplateEngineConfig validation rejects a base_dir that is set but whitespace-only for file-based template managers. The field must be a real directory path, not an empty/blank string.","triggerScenarios":"TemplateEngineConfig with base_dir=\"\" or base_dir=\"   \" while using a file-based template manager type (e.g. filesystem manager).","commonSituations":"YAML settings with an empty base_dir: value; template strings passed in base_dir by mistake; whitespace from templating/jinja rendering of the config.","solutions":["Set base_dir to an existing directory path containing your templates, e.g. base_dir: \"prompts\"","If using inline/in-memory templates, switch to the non-file template manager type so base_dir is not validated"],"exampleFix":"# before\nTemplateEngineConfig(type=<file manager>, base_dir=\"\")\n# after\nTemplateEngineConfig(type=<file manager>, base_dir=\"prompts\")","handlingStrategy":"validation","validationCode":"bd = tmpl_cfg.get(\"base_dir\")\nif using_file_manager and (bd is None or not bd.strip()):\n    raise ValueError(\"base_dir must be a non-empty path for file template managers\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Point base_dir at a directory checked into the repo and verify with Path(bd).is_dir() at startup","Prefer inline template managers for tests"],"tags":["templates","config-validation","path"],"backgroundTag":"invalid-config-value","analyzedSha":"f40e9a26ce62ba0b3fef8837d24aafdcc6e6c704","analyzedAt":"2026-08-27T11:16:29.677Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}