{"record":{"id":"9bcbab5fa2aaf2da","repo":"BerriAI/litellm","slug":"file-must-have-prompt-extension","errorCode":null,"errorMessage":"File must have .prompt extension","messagePattern":"File must have \\.prompt extension","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"litellm/proxy/prompts/prompt_endpoints.py","lineNumber":1334,"sourceCode":")\nasync def convert_prompt_file_to_json(\n    file: UploadFile = File(...),\n    user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),\n) -> dict[str, Any]:\n    \"\"\"\n    Convert a .prompt file to JSON format.\n\n    This endpoint accepts a .prompt file upload and returns the equivalent JSON representation\n    that can be stored in a database or used programmatically.\n\n    Returns the JSON structure with 'content' and 'metadata' fields.\n    \"\"\"\n    global general_settings\n    from litellm.integrations.dotprompt.prompt_manager import PromptManager\n\n    # Validate file extension\n    if not file.filename or not file.filename.endswith(\".prompt\"):\n        raise HTTPException(status_code=400, detail=\"File must have .prompt extension\")\n\n    temp_file_path = None\n    try:\n        # Read file content\n        file_content: Final = await file.read()\n\n        # Create temporary file — use safe_filename to prevent path traversal\n        temp_file_path = Path(tempfile.mkdtemp()) / safe_filename(file.filename)\n        temp_file_path.write_bytes(file_content)\n\n        # Create a PromptManager instance just for conversion\n        prompt_manager: Final = PromptManager()\n\n        # Convert to JSON\n        json_data: Final = prompt_manager.prompt_file_to_json(temp_file_path)\n\n        # Extract prompt ID from filename\n        prompt_id: Final = temp_file_path.stem","sourceCodeStart":1316,"sourceCodeEnd":1352,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/prompts/prompt_endpoints.py#L1316-L1352","documentation":"Upload validation on the .prompt file conversion endpoint: the uploaded file's name does not end with the '.prompt' extension, so it is not recognized as a dotprompt file and conversion is refused with 400 before the file is parsed.","triggerScenarios":"Thrown at litellm/proxy/prompts/prompt_endpoints.py:1334 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Upload a file with the .prompt extension; rename the file if necessary."],"exampleFix":null,"handlingStrategy":"validation","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"}