{"record":{"id":"50137ae14855b973","repo":"deepset-ai/haystack","slug":"invalid-image-format-params-format-valid-op","errorCode":null,"errorMessage":"Invalid image format: {params['format']}. Valid options are: {valid_formats}.","messagePattern":"Invalid image format: (.+?)\\. Valid options are: (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"haystack/core/pipeline/draw.py","lineNumber":139,"sourceCode":"            - height: Height of the output image (integer).\n            - scale: Scaling factor (1–3). Only applicable if 'width' or 'height' is specified.\n            - fit: Whether to fit the diagram size to the page (PDF only, boolean).\n            - paper: Paper size for PDFs (e.g., 'a4', 'a3'). Ignored if 'fit' is true.\n            - landscape: Landscape orientation for PDFs (boolean). Ignored if 'fit' is true.\n\n    :raises ValueError:\n        If any parameter is invalid or does not match the expected format.\n    \"\"\"\n    valid_img_types = {\"jpeg\", \"png\", \"webp\"}\n    valid_themes = {\"default\", \"neutral\", \"dark\", \"forest\"}\n    valid_formats = {\"img\", \"svg\", \"pdf\"}\n\n    params.setdefault(\"format\", \"img\")\n    params.setdefault(\"type\", \"png\")\n    params.setdefault(\"theme\", \"neutral\")\n\n    if params[\"format\"] not in valid_formats:\n        raise ValueError(f\"Invalid image format: {params['format']}. Valid options are: {valid_formats}.\")\n\n    if params[\"format\"] == \"img\" and params[\"type\"] not in valid_img_types:\n        raise ValueError(f\"Invalid image type: {params['type']}. Valid options are: {valid_img_types}.\")\n\n    if params[\"theme\"] not in valid_themes:\n        raise ValueError(f\"Invalid theme: {params['theme']}. Valid options are: {valid_themes}.\")\n\n    if \"width\" in params and not isinstance(params[\"width\"], int):\n        raise ValueError(\"Width must be an integer.\")\n    if \"height\" in params and not isinstance(params[\"height\"], int):\n        raise ValueError(\"Height must be an integer.\")\n\n    if \"scale\" in params and not 1 <= params[\"scale\"] <= 3:\n        raise ValueError(\"Scale must be a number between 1 and 3.\")\n    if \"scale\" in params and not (\"width\" in params or \"height\" in params):\n        raise ValueError(\"Scale is only allowed when width or height is set.\")\n\n    if \"bgColor\" in params and not isinstance(params[\"bgColor\"], str):","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/core/pipeline/draw.py#L121-L157","documentation":"_to_mermaid_image validates mermaid.ink image parameters before rendering a pipeline diagram. Haystack raises this when the 'format' key in params is not one of the supported mermaid.ink output formats. It is an immediate fail-fast input validation error.","triggerScenarios":"Calling pipeline.draw(path, image_type=\"mermaid-image\"-style flow) with params={'format': 'jpeg'} or any format outside the valid list (e.g. 'png', 'jpg' misspellings) instead of a supported value such as 'img', 'svg', 'pdf'.","commonSituations":"Copying mermaid CLI options (which differ from mermaid.ink query params) into haystack draw params; typos like 'png' passed as format when it belongs in 'type'.","solutions":["Set params['format'] to one of the valid formats listed in the error message (e.g. 'img', 'svg', 'pdf')","Remove the 'format' key entirely and let it default to 'img'","If you meant a raster type, keep format='img' and set type='png' or 'jpeg'"],"exampleFix":"// before\npipeline.draw(path=\"graph.png\", params={\"format\": \"png\"})  # ValueError\n// after\npipeline.draw(path=\"graph.png\", params={\"format\": \"img\", \"type\": \"png\"})","handlingStrategy":"validation","validationCode":"VALID = {\"img\", \"svg\", \"pdf\"}\nif params.get(\"format\", \"img\") not in VALID:\n    raise ValueError(f\"format must be one of {sorted(VALID)}\")","typeGuard":"def has_valid_format(params: dict) -> bool:\n    return params.get(\"format\", \"img\") in {\"img\", \"svg\", \"pdf\"}","tryCatchPattern":"try:\n    pipeline.draw(path, params=params)\nexcept ValueError as e:\n    logger.error(\"draw params rejected: %s\", e)","preventionTips":["Only use formats listed in the raised error message","Don't confuse mermaid CLI flags with mermaid.ink params","Omit unknown keys and let haystack defaults apply"],"tags":["mermaid","validation","drawing","params"],"backgroundTag":"invalid-enum-parameter","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}