{"record":{"id":"8393901036c0609b","repo":"deepset-ai/haystack","slug":"invalid-image-type-params-type-valid-option","errorCode":null,"errorMessage":"Invalid image type: {params['type']}. Valid options are: {valid_img_types}.","messagePattern":"Invalid image type: (.+?)\\. Valid options are: (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"haystack/core/pipeline/draw.py","lineNumber":142,"sourceCode":"            - 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):\n        raise ValueError(\"Background color must be a string.\")\n\n    # PDF specific parameters","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/core/pipeline/draw.py#L124-L160","documentation":"When format is 'img', mermaid.ink accepts only certain raster image types. Haystack raises this if params['type'] is not in that list. It validates before making the network request so failures happen locally.","triggerScenarios":"Passing params={'format': 'img', 'type': 'svg'} or 'jpg'/'webp'; only raster types accepted for 'img' (e.g. 'png', 'jpeg').","commonSituations":"Users want a vector image and set type='svg' but forgot format must be 'svg'; confusion between the two params.","solutions":["Set type to one of the listed valid_img_types (e.g. 'png', 'jpeg')","For vector output use params={'format': 'svg'} instead of format='img' with type='svg'","Omit 'type' to use the default 'png'"],"exampleFix":"// before\npipeline.draw(path=\"g\", params={\"format\": \"img\", \"type\": \"svg\"})  # ValueError\n// after\npipeline.draw(path=\"g\", params={\"format\": \"svg\"})","handlingStrategy":"validation","validationCode":"if params.get(\"format\", \"img\") == \"img\" and params.get(\"type\", \"png\") not in {\"png\", \"jpeg\"}:\n    raise ValueError(\"for format=img use type png or jpeg\")","typeGuard":"def valid_img_type(params: dict) -> bool:\n    return params.get(\"format\", \"img\") != \"img\" or params.get(\"type\", \"png\") in {\"png\", \"jpeg\"}","tryCatchPattern":"try:\n    pipeline.draw(path, params=params)\nexcept ValueError as e:\n    if \"image type\" in str(e):\n        params[\"type\"] = \"png\"\n        pipeline.draw(path, params=params)","preventionTips":["Remember svg is a format, not a type","Keep type as png/jpeg for raster output"],"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"}