{"record":{"id":"95110e2e9b3efe4e","repo":"BerriAI/litellm","slug":"prompt-id-is-required-for-bitbucket-prompt-manager","errorCode":null,"errorMessage":"prompt_id is required for BitBucket prompt manager","messagePattern":"prompt_id is required for BitBucket prompt manager","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/bitbucket/bitbucket_prompt_manager.py","lineNumber":443,"sourceCode":"        self,\n        prompt_id: str | None,\n        prompt_spec: PromptSpec | None,\n        prompt_variables: dict | None,\n        dynamic_callback_params: StandardCallbackDynamicParams,\n        prompt_label: str | None = None,\n        prompt_version: int | None = None,\n    ) -> PromptManagementClient:\n        \"\"\"\n        Compile a BitBucket prompt template into a PromptManagementClient structure.\n\n        This method:\n        1. Loads the prompt template from BitBucket\n        2. Renders it with the provided variables\n        3. Converts the rendered text into chat messages\n        4. Extracts model and optional parameters from metadata\n        \"\"\"\n        if prompt_id is None:\n            raise ValueError(\"prompt_id is required for BitBucket prompt manager\")\n\n        try:\n            # Load the prompt from BitBucket if not already loaded\n            if prompt_id not in self.prompt_manager.prompts:\n                self.prompt_manager._load_prompt_from_bitbucket(prompt_id)\n\n            # Get the rendered prompt and metadata\n            rendered_prompt, prompt_metadata = self.get_prompt_template(prompt_id, prompt_variables)\n\n            # Convert rendered content to chat messages\n            messages: Final = self._parse_prompt_to_messages(rendered_prompt)\n\n            # Extract model from metadata (if specified)\n            template_model: Final = prompt_metadata.get(\"model\")\n\n            # Extract optional parameters from metadata\n            optional_params: Final = {}\n            for param in [","sourceCodeStart":425,"sourceCodeEnd":461,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/bitbucket/bitbucket_prompt_manager.py#L425-L461","documentation":"ValueError raised at the top of the sync _compile_prompt_helper: BitBucket prompt compilation is meaningless without a prompt_id because templates are keyed by file name, and unlike database-backed prompt managers there is no prompt_spec fallback to derive one from. Passing prompt_id=None is treated as a caller bug, not a runtime failure.","triggerScenarios":"Calling compile_prompt_helper with prompt_id=None and no prompt_spec; forwarding an unset request parameter (e.g. a 'prompt' field absent from the request body) straight into the helper; generic prompt-routing code that handles multiple backends passing None for BitBucket.","commonSituations":"Shared router code paths where other prompt integrations accept None; config files where the prompt id key is misspelled so it reads as None; API requests missing the prompt field.","solutions":["Always pass a concrete prompt_id string matching a .prompt file name in the repository","Validate at the call site before invoking: if prompt_id is None: raise early with your own context","Check request/config parsing for misspelled keys that silently default to None","If you meant to use a DB-backed prompt, use the PromptManagementClient path that accepts prompt_spec instead"],"exampleFix":"# before\nresult = await client.async_compile_prompt_helper(None, vars, dynamic_params)\n\n# after\nif prompt_id is None:\n    raise ValueError(\"Request is missing 'prompt' id; BitBucket prompts require it\")\nresult = await client.async_compile_prompt_helper(prompt_id, vars, dynamic_params)","handlingStrategy":"validation","validationCode":"def require_prompt_id(prompt_id: str | None) -> str:\n    if not isinstance(prompt_id, str) or not prompt_id.strip():\n        raise ValueError(\"Request must include a non-empty BitBucket prompt id\")\n    return prompt_id.strip()","typeGuard":"def is_valid_prompt_id(prompt_id) -> bool:\n    return isinstance(prompt_id, str) and bool(prompt_id.strip())","tryCatchPattern":"try:\n    compiled = client._compile_prompt_helper(prompt_id, variables, dynamic_params)\nexcept ValueError as e:\n    if \"prompt_id is required\" in str(e):\n        raise TypeError(\"Caller bug: prompt_id missing\") from e\n    raise","preventionTips":["Validate request payloads for required prompt ids at the API boundary","Add schema validation (pydantic) on incoming prompt requests","Unit-test that your router never forwards None ids"],"tags":["bitbucket","prompts","validation","programming-error"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}