{"record":{"id":"cd3b26eb3ab9e761","repo":"BerriAI/litellm","slug":"prompt-prompt-id-not-found-in-environment-envir","errorCode":null,"errorMessage":"Prompt {prompt_id} not found in environment {environment}","messagePattern":"Prompt (.+?) not found in environment (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"litellm/proxy/prompts/prompt_endpoints.py","lineNumber":688,"sourceCode":"            where=where_clause,\n            order={\"version\": \"desc\"},\n            take=1,\n        )\n        if env_prompts:\n            prompt_spec = create_versioned_prompt_spec(db_prompt=env_prompts[0])\n\n    # Fallback: use in-memory registry (no environment filter)\n    if prompt_spec is None and environment is None:\n        prompt_spec = IN_MEMORY_PROMPT_REGISTRY.get_prompt_by_id(prompt_id)\n        if prompt_spec is None:\n            latest_prompt_id: Final = get_latest_version_prompt_id(\n                prompt_id=prompt_id,\n                all_prompt_ids=IN_MEMORY_PROMPT_REGISTRY.IN_MEMORY_PROMPTS,\n            )\n            prompt_spec = IN_MEMORY_PROMPT_REGISTRY.get_prompt_by_id(latest_prompt_id)\n\n    if prompt_spec is None:\n        raise HTTPException(\n            status_code=400,\n            detail=f\"Prompt {prompt_id} not found\" + (f\" in environment {environment}\" if environment else \"\"),\n        )\n\n    # Extract version number from the prompt_id\n    version_number: Final = get_version_number(prompt_id=prompt_spec.prompt_id)\n\n    # Create a copy of the prompt spec with the base prompt ID (stripped of version)\n    prompt_spec_response: Final = PromptSpec(\n        prompt_id=get_base_prompt_id(prompt_id=prompt_spec.prompt_id),\n        litellm_params=prompt_spec.litellm_params,\n        prompt_info=prompt_spec.prompt_info,\n        created_at=prompt_spec.created_at,\n        updated_at=prompt_spec.updated_at,\n        version=version_number,\n        environment=prompt_spec.environment,\n        created_by=prompt_spec.created_by,\n    )","sourceCodeStart":670,"sourceCodeEnd":706,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/prompts/prompt_endpoints.py#L670-L706","documentation":"Prompt fetch fallback exhausted: neither the DB query for the prompt in the requested environment nor the in-memory registry lookup (including latest-version resolution) produced a prompt with that prompt_id, so nothing can be returned for the given environment.","triggerScenarios":"Thrown at litellm/proxy/prompts/prompt_endpoints.py:688 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the prompt exists in the requested environment (e.g. production vs staging); promote or create it there."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}