BerriAI/litellm · error · ValueError

prompt_id is required for GitLab prompt manager

Error message

prompt_id is required for GitLab prompt manager

What it means

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.

Source

Thrown at litellm/integrations/gitlab/gitlab_prompt_manager.py:484

    def should_run_prompt_management(
        self,
        prompt_id: str | None,
        prompt_spec: PromptSpec | None,
        dynamic_callback_params: StandardCallbackDynamicParams,
    ) -> bool:
        return prompt_id is not None

    def _compile_prompt_helper(
        self,
        prompt_id: str | None,
        prompt_spec: PromptSpec | None,
        prompt_variables: dict | None,
        dynamic_callback_params: StandardCallbackDynamicParams,
        prompt_label: str | None = None,
        prompt_version: int | None = None,
    ) -> PromptManagementClient:
        if prompt_id is None:
            raise ValueError("prompt_id is required for GitLab prompt manager")

        try:
            decoded_id: Final = decode_prompt_id(prompt_id)
            if decoded_id not in self.prompt_manager.prompts:
                git_ref: Final = (
                    getattr(dynamic_callback_params, "extra", {}).get("git_ref")
                    if hasattr(dynamic_callback_params, "extra")
                    else None
                )
                self.prompt_manager._load_prompt_from_gitlab(decoded_id, ref=git_ref)

            rendered_prompt, prompt_metadata = self.get_prompt_template(prompt_id, prompt_variables)

            messages: Final = self._parse_prompt_to_messages(rendered_prompt)
            template_model: Final = prompt_metadata.get("model")

            optional_params: Final[dict[str, Any]] = {}
            for param in [

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Pass prompt_id (the template name from list_templates()) on the completion call
  2. If you don't want GitLab prompt injection, remove the GitLab prompt callback from litellm.callbacks
  3. Verify dynamic callback params actually route to this handler intentionally

Example fix

# before
response = litellm.completion(model='gpt-4o', messages=messages)

# after
response = litellm.completion(
    model='gpt-4o',
    messages=[{'role': 'user', 'content': 'hi'}],
    prompt_id='greeting',
    prompt_variables={'name': 'A'},
)
Defensive patterns

Strategy: validation

Validate before calling

if prompt_id is None:
    raise ValueError("GitLab prompt integration requires prompt_id")
# only then call completion

Type guard

def has_prompt_id(kwargs: dict) -> bool:
    pid = kwargs.get("prompt_id")
    return isinstance(pid, str) and len(pid) > 0

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/50756a628fe5b10d. Report an issue: GitHub.