{"record":{"id":"f3ce7c29dcb6dbc7","repo":"BerriAI/litellm","slug":"failed-to-load-prompt-encode-prompt-id-prompt-id","errorCode":null,"errorMessage":"Failed to load prompt '{encode_prompt_id(prompt_id)}' from GitLab: {e}","messagePattern":"Failed to load prompt '(.+?)' from GitLab: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/integrations/gitlab/gitlab_prompt_manager.py","lineNumber":142,"sourceCode":"        path = repo_path.strip(\"/\")\n        if self.prompts_path and path.startswith(self.prompts_path.strip(\"/\") + \"/\"):\n            path = path[len(self.prompts_path.strip(\"/\")) + 1 :]\n        path = path.removesuffix(\".prompt\")\n        return encode_prompt_id(path)\n\n    # ---------- loading ----------\n\n    def _load_prompt_from_gitlab(self, prompt_id: str, *, ref: str | None = None) -> None:\n        \"\"\"Load a specific .prompt file from GitLab (scoped under prompts_path if set).\"\"\"\n        try:\n            # prompt_id = decode_prompt_id(prompt_id)\n            file_path: Final = self._id_to_repo_path(prompt_id)\n            prompt_content: Final = self.gitlab_client.get_file_content(file_path, ref=ref)\n            if prompt_content:\n                template: Final = self._parse_prompt_file(prompt_content, prompt_id)\n                self.prompts[prompt_id] = template\n        except Exception as e:\n            raise Exception(f\"Failed to load prompt '{encode_prompt_id(prompt_id)}' from GitLab: {e}\")\n\n    def load_all_prompts(self, *, recursive: bool = True) -> list[str]:\n        \"\"\"\n        Eagerly load all .prompt files from prompts_path. Returns loaded IDs.\n        \"\"\"\n        files: Final = self.list_templates(recursive=recursive)\n        loaded: Final[list[str]] = []\n        for pid in files:\n            if pid not in self.prompts:\n                self._load_prompt_from_gitlab(pid)\n            loaded.append(pid)\n        return loaded\n\n    # ---------- parsing & rendering ----------\n\n    def _parse_prompt_file(self, content: str, prompt_id: str) -> GitLabPromptTemplate:\n        if content.startswith(\"---\"):\n            parts: Final = content.split(\"---\", 2)","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/gitlab/gitlab_prompt_manager.py#L124-L160","documentation":"Wrapper exception from GitLabPromptManager._load_prompt_from_gitlab. Any failure while resolving the repo path, fetching file content, or parsing the .prompt file is re-raised with this message naming the encoded prompt id. The real cause (any of errors 460-462, or a parse error) is chained in the text.","triggerScenarios":"Calling _load_prompt_from_gitlab, load_all_prompts, get_prompt_template, or compile_prompt_helper for a prompt id whose underlying file fetch or _parse_prompt_file raises: bad credentials, missing access, network failure, or malformed .prompt file content.","commonSituations":"Bulk-loading all prompts where one file has invalid frontmatter; a renamed/deleted .prompt file still referenced by id; CI environment missing the GitLab token env var so the first fetch 401s; wrong prompts_path prefix.","solutions":["Read the chained exception text to find the underlying cause","Verify the prompt id maps to a real file: check _id_to_repo_path output and list_templates()","Fix token/permissions if the inner error is 401/403","Validate the .prompt file frontmatter if the inner error comes from parsing"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"ids = manager.list_templates(recursive=True)\nif my_prompt_id not in ids:\n    raise LookupError(f\"{my_prompt_id} not in repo; available: {ids}\")","typeGuard":null,"tryCatchPattern":"try:\n    manager._load_prompt_from_gitlab(pid)\nexcept Exception as e:\n    if \"404\" in str(e):\n        skip(pid)  # tolerate deleted files during bulk load\n    else:\n        raise","preventionTips":["Validate prompt ids against list_templates() before loading","During bulk loads, isolate per-file failures instead of aborting all","Parse chained exception text to find root cause"],"tags":["gitlab","prompt-management","litellm","wrapper-exception"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}