{"record":{"id":"baa06c0f87f280e9","repo":"BerriAI/litellm","slug":"failed-to-load-prompt-prompt-id-from-bitbucket","errorCode":null,"errorMessage":"Failed to load prompt '{prompt_id}' from BitBucket: {e}","messagePattern":"Failed to load prompt '(.+?)' from BitBucket: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/integrations/bitbucket/bitbucket_prompt_manager.py","lineNumber":108,"sourceCode":"            comment_start_string=\"{#\",\n            comment_end_string=\"#}\",\n        )\n\n        # Load prompts from BitBucket if prompt_id is provided\n        if self.prompt_id:\n            self._load_prompt_from_bitbucket(self.prompt_id)\n\n    def _load_prompt_from_bitbucket(self, prompt_id: str) -> None:\n        \"\"\"Load a specific .prompt file from BitBucket.\"\"\"\n        try:\n            # Fetch the .prompt file from BitBucket\n            prompt_content: Final = self.bitbucket_client.get_file_content(f\"{prompt_id}.prompt\")\n\n            if prompt_content:\n                template: Final = self._parse_prompt_file(prompt_content, prompt_id)\n                self.prompts[prompt_id] = template\n        except Exception as e:\n            raise Exception(f\"Failed to load prompt '{prompt_id}' from BitBucket: {e}\")\n\n    def _parse_prompt_file(self, content: str, prompt_id: str) -> BitBucketPromptTemplate:\n        \"\"\"Parse a .prompt file content and extract metadata and template.\"\"\"\n        # Split frontmatter and content\n        if content.startswith(\"---\"):\n            parts: Final = content.split(\"---\", 2)\n            if len(parts) >= 3:\n                frontmatter_str = parts[1].strip()\n                template_content = parts[2].strip()\n            else:\n                frontmatter_str = \"\"\n                template_content = content\n        else:\n            frontmatter_str = \"\"\n            template_content = content\n\n        # Parse YAML frontmatter\n        metadata: dict[str, Any] = {}","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/bitbucket/bitbucket_prompt_manager.py#L90-L126","documentation":"Raised by BitBucketPromptManager._load_prompt_from_bitbucket when fetching or parsing a {prompt_id}.prompt file fails. The inner exception is typically one of the BitBucketClient errors (auth, access denied, network) bubbled up through get_file_content, and this method flattens it into a generic Exception with the prompt_id in the message.","triggerScenarios":"Requesting a prompt_id whose .prompt file does not exist with credentials that yield 403 instead of 404, expired token (401), wrong branch configured (file exists on main but client points elsewhere), or network failure — any of these aborts the load and re-raises here.","commonSituations":"First request after deploying the BitBucket prompt integration with incomplete config; prompt file renamed without updating callers; branch set to a feature branch that was deleted after merge.","solutions":["Call bitbucket_client.test_connection() at startup to fail fast on config errors before serving traffic","Confirm {prompt_id}.prompt exists at the repo root (or the path you expect) on the configured branch in the BitBucket UI","Check the inner error text in the message — it carries the underlying HTTP status","Verify the branch config key matches where the prompt files live (default is 'main')"],"exampleFix":"# before\nmanager._load_prompt_from_bitbucket(\"summary\")  # raises on any infra error\n\n# after (startup validation)\nif not manager.bitbucket_client.test_connection():\n    raise RuntimeError(\"BitBucket prompt source misconfigured\")\nmanager._load_prompt_from_bitbucket(\"summary\")","handlingStrategy":"validation","validationCode":"if not manager.bitbucket_client.test_connection():\n    raise RuntimeError(\"BitBucket prompt source misconfigured; aborting load\")\nmanager._load_prompt_from_bitbucket(prompt_id)","typeGuard":null,"tryCatchPattern":"try:\n    manager._load_prompt_from_bitbucket(prompt_id)\nexcept Exception as e:\n    raise RuntimeError(f\"Prompt '{prompt_id}' unavailable from BitBucket: {e}\") from e","preventionTips":["Validate BitBucket connectivity at startup, not on first request","Keep a local fallback copy of critical prompts","Pin the branch config to the branch that actually holds prompt files"],"tags":["bitbucket","prompts","configuration"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}