{"record":{"id":"02a2710ece4c2416","repo":"BerriAI/litellm","slug":"prompt-directory-does-not-exist-self-prompt-dire","errorCode":null,"errorMessage":"Prompt directory does not exist: {self.prompt_directory}","messagePattern":"Prompt directory does not exist: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/dotprompt/prompt_manager.py","lineNumber":96,"sourceCode":"        # Load prompts from directory if provided\n        if self.prompt_directory:\n            self._load_prompts()\n\n        if self.prompt_file:\n            if not prompt_id:\n                raise ValueError(\"prompt_id is required when prompt_file is provided\")\n\n            template: Final = self._load_prompt_file(self.prompt_file, prompt_id)\n            self.prompts[prompt_id] = template\n\n        # Load prompts from JSON data if provided\n        if prompt_data:\n            self._load_prompts_from_json(prompt_data, prompt_id)\n\n    def _load_prompts(self) -> None:\n        \"\"\"Load all .prompt files from the prompt directory.\"\"\"\n        if not self.prompt_directory or not self.prompt_directory.exists():\n            raise ValueError(f\"Prompt directory does not exist: {self.prompt_directory}\")\n\n        prompt_files: Final = list(self.prompt_directory.glob(\"*.prompt\"))\n\n        for prompt_file in prompt_files:\n            try:\n                prompt_id = prompt_file.stem  # filename without extension\n                template = self._load_prompt_file(prompt_file, prompt_id)\n                self.prompts[prompt_id] = template\n                # Optional: print(f\"Loaded prompt: {prompt_id}\")\n            except Exception:\n                # Optional: print(f\"Error loading prompt file {prompt_file}\")\n                pass\n\n    def _load_prompts_from_json(self, prompt_data: dict[str, dict[str, Any]], prompt_id: str | None = None) -> None:\n        \"\"\"Load prompts from JSON data structure.\n\n        Expected format:\n        {","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/dotprompt/prompt_manager.py#L78-L114","documentation":"PromptManager._load_prompts, called automatically from __init__ whenever prompt_directory is set, raises ValueError if the directory is falsy or does not exist on disk. The message interpolates the stored path (which prints 'None' if the value was empty). This makes construction itself fail before any prompts are read.","triggerScenarios":"PromptManager(prompt_directory='prompts') when the folder does not exist or the process cwd differs (relative paths resolve against cwd at construction time); a path sourced from an env var or config that is wrong; a directory that was deleted between deployments.","commonSituations":"Running the proxy/service from a different working directory (systemd unit, Docker WORKDIR) so a relative path no longer resolves; CI checkout missing the prompts folder; typo in the configured path; packaging the app without the prompts directory.","solutions":["Verify the directory exists (and correct the path) before constructing PromptManager","Use an absolute path anchored to code location: Path(__file__).parent / 'prompts'","Create the directory if it may legitimately be empty: Path(dir).mkdir(parents=True, exist_ok=True)","If you only need one file, use prompt_file + prompt_id so no directory is required"],"exampleFix":"# before\nmanager = PromptManager(prompt_directory='prompts')\n\n# after\nfrom pathlib import Path\nPROMPT_DIR = Path(__file__).parent / 'prompts'\nassert PROMPT_DIR.is_dir(), f'missing prompt directory: {PROMPT_DIR}'\nmanager = PromptManager(prompt_directory=str(PROMPT_DIR))","handlingStrategy":"validation","validationCode":"from pathlib import Path\nprompt_dir = Path(prompt_directory) if prompt_directory else None\nif prompt_directory and not prompt_dir.is_dir():\n    raise FileNotFoundError(f'prompt directory missing: {prompt_dir}')\nmanager = PromptManager(prompt_directory=str(prompt_dir) if prompt_dir else None)","typeGuard":null,"tryCatchPattern":"try:\n    manager = PromptManager(prompt_directory=str(PROMPT_DIR))\nexcept ValueError as e:\n    if 'Prompt directory does not exist' in str(e):\n        logger.error('prompts folder missing at %s — check deployment layout', PROMPT_DIR)\n    raise","preventionTips":["Anchor prompt directories to __file__, never to cwd","Include the prompts directory in the Docker image / package and assert presence at startup","Add a CI check that the configured prompt directory exists in the built artifact"],"tags":["litellm","dotprompt","prompt","filesystem","path"],"backgroundTag":"file-not-found","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}