{"record":{"id":"50756a628fe5b10d","repo":"BerriAI/litellm","slug":"prompt-id-is-required-for-gitlab-prompt-manager","errorCode":null,"errorMessage":"prompt_id is required for GitLab prompt manager","messagePattern":"prompt_id is required for GitLab prompt manager","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/gitlab/gitlab_prompt_manager.py","lineNumber":484,"sourceCode":"    def should_run_prompt_management(\n        self,\n        prompt_id: str | None,\n        prompt_spec: PromptSpec | None,\n        dynamic_callback_params: StandardCallbackDynamicParams,\n    ) -> bool:\n        return prompt_id is not None\n\n    def _compile_prompt_helper(\n        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        if prompt_id is None:\n            raise ValueError(\"prompt_id is required for GitLab prompt manager\")\n\n        try:\n            decoded_id: Final = decode_prompt_id(prompt_id)\n            if decoded_id not in self.prompt_manager.prompts:\n                git_ref: Final = (\n                    getattr(dynamic_callback_params, \"extra\", {}).get(\"git_ref\")\n                    if hasattr(dynamic_callback_params, \"extra\")\n                    else None\n                )\n                self.prompt_manager._load_prompt_from_gitlab(decoded_id, ref=git_ref)\n\n            rendered_prompt, prompt_metadata = self.get_prompt_template(prompt_id, prompt_variables)\n\n            messages: Final = self._parse_prompt_to_messages(rendered_prompt)\n            template_model: Final = prompt_metadata.get(\"model\")\n\n            optional_params: Final[dict[str, Any]] = {}\n            for param in [","sourceCodeStart":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/gitlab/gitlab_prompt_manager.py#L466-L502","documentation":"ValueError from CustomGitLabPromptManagement._compile_prompt_helper: the GitLab integration only supports loading prompts by id and requires a non-None prompt_id. prompt_spec-based compilation (used by some other prompt integrations) is not supported here.","triggerScenarios":"Invoking a chat completion routed through the GitLab prompt handler without prompt_id in kwargs — e.g. relying on prompt_spec, or calling completion() where no prompt_id was forwarded to the callback.","commonSituations":"Switching from Langfuse/PromptLayer-style integrations that accept prompt specs to GitLab without adding prompt_id; callbacks configured (litellm.callbacks=['gitlab_prompt']) but the request lacks prompt_id; incorrect callback class choice.","solutions":["Pass prompt_id (the template name from list_templates()) on the completion call","If you don't want GitLab prompt injection, remove the GitLab prompt callback from litellm.callbacks","Verify dynamic callback params actually route to this handler intentionally"],"exampleFix":"# before\nresponse = litellm.completion(model='gpt-4o', messages=messages)\n\n# after\nresponse = litellm.completion(\n    model='gpt-4o',\n    messages=[{'role': 'user', 'content': 'hi'}],\n    prompt_id='greeting',\n    prompt_variables={'name': 'A'},\n)","handlingStrategy":"validation","validationCode":"if prompt_id is None:\n    raise ValueError(\"GitLab prompt integration requires prompt_id\")\n# only then call completion","typeGuard":"def has_prompt_id(kwargs: dict) -> bool:\n    pid = kwargs.get(\"prompt_id\")\n    return isinstance(pid, str) and len(pid) > 0","tryCatchPattern":null,"preventionTips":["Always pair the GitLab prompt callback with prompt_id on calls","Remove the callback when not doing prompt injection","Centralize completion wrappers so prompt_id is never dropped"],"tags":["litellm","prompt-management","gitlab","validation"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}