BerriAI/litellm · error · HTTPException

Error converting prompt file: {e}

Error message

Error converting prompt file: {e}

What it means

Catch-all from the prompt-file conversion endpoint: writing the upload to a temp file or running PromptManager.prompt_file_to_json over it raised (malformed frontmatter, unreadable content, or filesystem error); the original exception text is embedded in the 400/500 detail.

Source

Thrown at litellm/proxy/prompts/prompt_endpoints.py:1360

        temp_file_path = Path(tempfile.mkdtemp()) / safe_filename(file.filename)
        temp_file_path.write_bytes(file_content)

        # Create a PromptManager instance just for conversion
        prompt_manager: Final = PromptManager()

        # Convert to JSON
        json_data: Final = prompt_manager.prompt_file_to_json(temp_file_path)

        # Extract prompt ID from filename
        prompt_id: Final = temp_file_path.stem

        return {
            "prompt_id": prompt_id,
            "json_data": json_data,
        }

    except Exception as e:
        raise HTTPException(status_code=500, detail=f"Error converting prompt file: {e}")

    finally:
        # Clean up temp file
        if temp_file_path and temp_file_path.exists():
            temp_file_path.unlink()
            # Also try to remove the temp directory if it's empty
            try:
                temp_file_path.parent.rmdir()
            except OSError:
                pass  # Directory not empty or other error

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Fix the .prompt file syntax per the error detail (frontmatter YAML, template placeholders) and re-upload.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at litellm/proxy/prompts/prompt_endpoints.py:1360 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/a7f76bb1f39ff109. Report an issue: GitHub.