{"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/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/bitbucket/bitbucket_prompt_manager.py#L425-L461","documentation":"ValueError raised by BitBucketPromptManager._compile_prompt_helper when prompt_id is None. The BitBucket prompt manager has no way to infer which prompt to use — unlike database-backed prompt managers it cannot look up by spec/label/version alone — so a request that reaches compilation without a concrete prompt_id fails fast here.","triggerScenarios":"Configuring the BitBucket prompt management handler but issuing a completion call without a 'prompt_id' parameter; passing prompt_label/prompt_version without prompt_id and no prompt_spec that resolves to an id; programmatic callers invoking the helper with None.","commonSituations":"Migrating from LiteLLM's prompt registry (where label/version lookups work) to BitBucket-backed prompts and assuming the same lookup semantics; config yaml referencing prompt_id only in some routes; SDK calls that drop unset optional params to None.","solutions":["Pass prompt_id explicitly in the completion request params (e.g. {\"prompt_id\": \"my-prompt\"})","If you meant to use the LiteLLM prompt registry, use that handler instead — BitBucket mode requires the literal id","Guard call sites: assert prompt_id is not None before invoking the helper","Check that routing/prompt-spec config actually resolves to a prompt_id for this request"],"exampleFix":"// before\nresponse = litellm.completion(model=\"gpt-4o\", messages=[{\"role\": \"user\", \"content\": \"hi\"}], prompt_variables={\"t\": t})\n\n// after\nresponse = litellm.completion(\n    model=\"gpt-4o\",\n    messages=[{\"role\": \"user\", \"content\": \"hi\"}],\n    prompt_id=\"my-prompt\",          # required for BitBucket prompt manager\n    prompt_variables={\"t\": t},\n)","handlingStrategy":"validation","validationCode":"if prompt_id is None:\n    raise ValueError(\"BitBucket prompt manager requires an explicit prompt_id in request params\")\nresult = manager._compile_prompt_helper(prompt_id, prompt_variables, dynamic_callback_params)","typeGuard":"def has_prompt_id(params: dict) -> bool:\n    return bool(params.get(\"prompt_id\"))","tryCatchPattern":"try:\n    result = await manager.async_compile_prompt_helper(prompt_id, variables, params)\nexcept ValueError as e:\n    if \"prompt_id is required\" in str(e):\n        ...  # reject the request early with a 4xx explaining the missing param\n    raise","preventionTips":["Always send prompt_id in completion params for routes bound to the BitBucket handler","Add request-level validation rejecting prompt-bound routes without prompt_id","Don't assume label/version lookups work — the BitBucket manager only accepts literal ids"],"tags":["bitbucket","prompt-management","missing-argument","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}