{"record":{"id":"27763ce495f0e7e7","repo":"BerriAI/litellm","slug":"error-compiling-prompt-prompt-id-e-27763c","errorCode":null,"errorMessage":"Error compiling prompt '{prompt_id}': {e}","messagePattern":"Error compiling prompt '(.+?)': (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/generic_prompt_management/generic_prompt_manager.py","lineNumber":306,"sourceCode":"        cache_key: Final = self._get_cache_key(prompt_id, prompt_label, prompt_version)\n        try:\n            # Fetch from API\n            api_response: Final = self._fetch_prompt_from_api(prompt_id, prompt_spec)\n\n            # Parse the response\n            prompt_client = self._parse_api_response(prompt_id, prompt_spec, api_response)\n\n            # Cache the result\n            self._prompt_cache[cache_key] = prompt_client\n\n            # Apply variables if provided\n            if prompt_variables:\n                prompt_client = self._apply_variables(prompt_client, prompt_variables)\n\n            return prompt_client\n\n        except Exception as e:\n            raise ValueError(f\"Error compiling prompt '{prompt_id}': {e}\")\n\n    async def async_compile_prompt_helper(\n        self,\n        prompt_id: str | None,\n        prompt_variables: dict | None,\n        dynamic_callback_params: StandardCallbackDynamicParams,\n        prompt_spec: PromptSpec | None = None,\n        prompt_label: str | None = None,\n        prompt_version: int | None = None,\n    ) -> PromptManagementClient:\n        # Check cache first\n        cached_prompt: Final = self._common_caching_logic(\n            prompt_id=prompt_id,\n            prompt_label=prompt_label,\n            prompt_version=prompt_version,\n            prompt_variables=prompt_variables,\n        )\n        if cached_prompt:","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/generic_prompt_management/generic_prompt_manager.py#L288-L324","documentation":"Raised by GenericPromptManager.compile_prompt_helper (sync path) as a catch-all: any Exception raised during fetch, parsing, or variable substitution for a prompt is re-wrapped into ValueError with the prompt_id in the message. The original stack trace is preserved as the cause (__context__), but the original exception type is hidden.","triggerScenarios":"Any failure inside the sync compile pipeline: network error from _fetch_prompt_from_api, JSON decode error, an unexpected API response shape in _parse_api_response (e.g. missing keys), or a KeyError/ValueError from _apply_variables when template variables mismatch. Because the result is cached, this only fires on cache misses.","commonSituations":"First request after startup when the cache is cold and the prompt API is misconfigured or unreachable; the prompt template on the server referencing a variable the caller did not supply; the server response format changing after a prompt-management API upgrade.","solutions":["Read the inner text after the colon — it contains the underlying error ('Failed to fetch prompt ...', JSON parse error, etc.) which tells you which sub-step failed.","Fix that root cause: unreachable API -> network/api_base; parse errors -> response format; apply-variables errors -> supply all template variables.","Check the server response with curl for the same prompt_id to confirm the expected structure (required fields for _parse_api_response).","Ensure prompt_variables covers every {variable_name} placeholder defined in the stored template."],"exampleFix":"# before: template on server is \"Hello {name}, you are {age}\"\nresp = litellm.completion(model=\"prompt-model\", messages=[...])  # missing vars\n\n# after\nresp = litellm.completion(\n    model=\"prompt-model\",\n    messages=[...],\n    variables={\"name\": \"Ada\", \"age\": \"36\"},\n)","handlingStrategy":"try-catch","validationCode":"def validate_prompt_variables(template: str, variables: dict) -> None:\n    import string\n    needed = set(string.Formatter().parse(template and template or \"\")) and \\\n             {fname for _, fname, _, _ in string.Formatter().parse(template) if fname}\n    missing = needed - set(variables or {})\n    if missing:\n        raise ValueError(f\"Missing prompt variables: {sorted(missing)}\")","typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.completion(model=\"prompt-model\", messages=msgs, variables=vars)\nexcept ValueError as e:\n    if str(e).startswith(\"Error compiling prompt\"):\n        # inspect the suffix: fetch failure, parse failure, or variable mismatch\n        log_prompt_compile_failure(prompt_id, str(e))\n        raise\n    raise","preventionTips":["Pre-flight the prompt API with a curl/script that fetches and parses the prompt once before serving.","Keep template variable names and caller-supplied variables in one shared definition.","Warm the prompt cache after config changes so first user request is not the compile path."],"tags":["prompt-management","wrapper-exception","runtime"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}