{"record":{"id":"ec15b755d6fea547","repo":"BerriAI/litellm","slug":"failed-to-fetch-prompt-version-prompt-version-id","errorCode":null,"errorMessage":"Failed to fetch prompt version '{prompt_version_id}': {e}","messagePattern":"Failed to fetch prompt version '(.+?)': (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/integrations/arize/arize_phoenix_client.py","lineNumber":90,"sourceCode":"            response.raise_for_status()\n\n            data: Final = response.json()\n            return data.get(\"data\")\n\n        except Exception as e:\n            # Check if it's an HTTP error\n            response = getattr(e, \"response\", None)\n            if response is not None and hasattr(response, \"status_code\"):\n                if response.status_code == 404:\n                    return None\n                elif response.status_code == 403:\n                    raise Exception(\n                        f\"Access denied to prompt version '{prompt_version_id}'. Check your Arize Phoenix permissions.\"\n                    )\n                elif response.status_code == 401:\n                    raise Exception(\"Authentication failed. Check your Arize Phoenix API key and permissions.\")\n                else:\n                    raise Exception(f\"Failed to fetch prompt version '{prompt_version_id}': {e}\")\n            else:\n                raise Exception(f\"Error fetching prompt version '{prompt_version_id}': {e}\")\n\n    def test_connection(self) -> bool:\n        \"\"\"\n        Test the connection to the Arize Phoenix API.\n\n        Returns:\n            True if connection is successful, False otherwise\n        \"\"\"\n        try:\n            # Try to access the prompt_versions endpoint to test connection\n            url: Final = f\"{self.api_base}/prompt_versions\"\n            response: Final = self.http_handler.client.get(url, headers=self.headers)\n            response.raise_for_status()\n            return True\n        except Exception:\n            return False","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/arize/arize_phoenix_client.py#L72-L108","documentation":"Catch-all for HTTP errors in ArizePhoenixClient.get_prompt_version that are not 401/403/404: the request reached Phoenix, authentication passed, but the server returned another error status (500, 502, 429, …). The original exception is embedded in the message so the status code and body are preserved.","triggerScenarios":"Phoenix backend returns 5xx while fetching /prompt_versions/<id>; rate limiting (429) on Phoenix Cloud; malformed request producing 400; gateway timeouts (504) behind a proxy. Surfaces via the prompt manager as 'Failed to load prompt version …' when litellm tries to use the prompt.","commonSituations":"Phoenix Cloud incidents or throttling during bursts of prompt loads; self-hosted Phoenix restarting or out of memory; a proxy in front of Phoenix returning 502 because the upstream is down.","solutions":["Inspect the embedded exception/status in the message to identify the actual code before acting","For 429/5xx transient errors, retry with backoff — the fetch is a read-only GET and is safe to repeat","Check Phoenix status page / server logs for 5xx; for self-hosted, verify the service is healthy and the api_base proxy is up","Cache loaded prompts so transient Phoenix outages do not break request serving"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"import httpx, os\n\nresp = httpx.get(\n    f\"{api_base}/prompt_versions/{prompt_version_id}\",\n    headers={\"Authorization\": f\"Bearer {os.environ['PHOENIX_API_KEY']}\"},\n    timeout=5,\n)\nif resp.status_code >= 500 or resp.status_code == 429:\n    log.warning(\"Phoenix transient status %s — will retry\", resp.status_code)","typeGuard":null,"tryCatchPattern":"from tenacity import retry, wait_exponential, retry_if_exception_message\n\n@retry(\n    retry=retry_if_exception_message(match=\".*Failed to fetch prompt version.*\"),\n    wait=wait_exponential(multiplier=1, max=30),\n    stop=stop_after_attempt(4),\n)\ndef load_prompt(pid: str):\n    return manager.compile(prompt_id=pid, prompt_variables=vars)","preventionTips":["Cache compiled prompts with a TTL so transient Phoenix 5xx/429 does not affect request serving","Alert on repeated fetch failures to distinguish incidents from config problems"],"tags":["arize-phoenix","http-error","prompts","remote-api","retryable"],"backgroundTag":"remote-api-http-error","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}