BerriAI/litellm · error · Exception

Failed to load prompt

Error message

Failed to load prompt '{encode_prompt_id(prompt_id)}' from GitLab: {e}

What it means

Loading a .prompt file from GitLab for the decoded prompt_id failed (network, auth, or missing-repo error interpolated); the manager re-raises so the prompt-loading failure is visible instead of silently skipping the template.

Solutions

  1. Check that the prompt_id maps to an existing file in the GitLab repository.
  2. Verify GitLab credentials and repository configuration in gitlab_config.
  3. Retry after resolving the underlying GitLab client error shown in the message.

Example fix

prompt = gitlab_prompt_manager.get_prompt('prompts/support_bot.prompt')
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Loading a prompt from GitLab fails because the file is missing, the ref is wrong, or the API request errors.

Common situations: Misconfigured gitlab_config, missing prompt file in the repo, or insufficient token scope.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/f3ce7c29dcb6dbc7. Report an issue: GitHub.

Appendix: source

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

        path = repo_path.strip("/")
        if self.prompts_path and path.startswith(self.prompts_path.strip("/") + "/"):
            path = path[len(self.prompts_path.strip("/")) + 1 :]
        path = path.removesuffix(".prompt")
        return encode_prompt_id(path)

    # ---------- loading ----------

    def _load_prompt_from_gitlab(self, prompt_id: str, *, ref: str | None = None) -> None:
        """Load a specific .prompt file from GitLab (scoped under prompts_path if set)."""
        try:
            # prompt_id = decode_prompt_id(prompt_id)
            file_path: Final = self._id_to_repo_path(prompt_id)
            prompt_content: Final = self.gitlab_client.get_file_content(file_path, ref=ref)
            if prompt_content:
                template: Final = self._parse_prompt_file(prompt_content, prompt_id)
                self.prompts[prompt_id] = template
        except Exception as e:
            raise Exception(f"Failed to load prompt '{encode_prompt_id(prompt_id)}' from GitLab: {e}")

    def load_all_prompts(self, *, recursive: bool = True) -> list[str]:
        """
        Eagerly load all .prompt files from prompts_path. Returns loaded IDs.
        """
        files: Final = self.list_templates(recursive=recursive)
        loaded: Final[list[str]] = []
        for pid in files:
            if pid not in self.prompts:
                self._load_prompt_from_gitlab(pid)
            loaded.append(pid)
        return loaded

    # ---------- parsing & rendering ----------

    def _parse_prompt_file(self, content: str, prompt_id: str) -> GitLabPromptTemplate:
        if content.startswith("---"):
            parts: Final = content.split("---", 2)

View on GitHub (pinned to 77b7c6c40c)