{"record":{"id":"b64b6197c4c0bacf","repo":"deepset-ai/haystack","slug":"invalid-format-endpoint-format-valid-options-a","errorCode":null,"errorMessage":"Invalid format: {endpoint_format}. Valid options are 'img', 'svg', or 'pdf'.","messagePattern":"Invalid format: (.+?)\\. Valid options are 'img', 'svg', or 'pdf'\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"haystack/core/pipeline/draw.py","lineNumber":296,"sourceCode":"\n    _validate_mermaid_params(params)\n\n    theme = params.get(\"theme\")\n    init_params = json.dumps({\"theme\": theme})\n\n    # Copy the graph to avoid modifying the original\n    graph_styled = _to_mermaid_text(graph.copy(), init_params, super_component_mapping)\n    json_string = json.dumps({\"code\": graph_styled})\n\n    # Compress the JSON string with zlib (RFC 1950)\n    compressor = zlib.compressobj(level=9, wbits=15)\n    compressed_data = compressor.compress(json_string.encode(\"utf-8\")) + compressor.flush()\n    compressed_url_safe_base64 = base64.urlsafe_b64encode(compressed_data).decode(\"utf-8\").strip()\n\n    # Determine the correct endpoint\n    endpoint_format = params.get(\"format\", \"img\")  # Default to /img endpoint\n    if endpoint_format not in {\"img\", \"svg\", \"pdf\"}:\n        raise ValueError(f\"Invalid format: {endpoint_format}. Valid options are 'img', 'svg', or 'pdf'.\")\n\n    # Construct the URL without query parameters\n    url = f\"{server_url}/{endpoint_format}/pako:{compressed_url_safe_base64}\"\n\n    # Add query parameters adhering to mermaid.ink documentation\n    query_params = []\n    for key, value in params.items():\n        if key not in {\"theme\", \"format\"}:  # Exclude theme (handled in init_params) and format (endpoint-specific)\n            if value is True:\n                query_params.append(f\"{key}\")\n            else:\n                query_params.append(f\"{key}={value}\")\n\n    if query_params:\n        url += \"?\" + \"&\".join(query_params)\n\n    logger.debug(\"Rendering graph at {url}\", url=url)\n    try:","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/core/pipeline/draw.py#L278-L314","documentation":"The Mermaid endpoint is chosen from the 'format' parameter ('img', 'svg', or 'pdf' map to mermaid.ink endpoints). _to_mermaid_image raises this ValueError when format is anything else, before any network request is made.","triggerScenarios":"Calling Pipeline.draw() or show() with a Mermaid params dict like {'format': 'png'}, {'format': 'jpeg'}, or {'format': 'jpg'} — formats that are valid image types but not valid endpoint formats.","commonSituations":"Users confuse the 'type' parameter (png/jpeg for img endpoint) with 'format'; older Haystack versions had different format options; building params from docs for a different tool.","solutions":["Use format in {'img', 'svg', 'pdf'}; for JPEG set {'format': 'img', 'type': 'jpeg'}","Omit 'format' entirely for the default PNG image","Check the current draw() docstring for valid values"],"exampleFix":"// before\nparams = {\"format\": \"png\"}\n// after\nparams = {\"format\": \"img\", \"type\": \"png\"}","handlingStrategy":"validation","validationCode":"VALID = {\"img\", \"svg\", \"pdf\"}\nfmt = params.get(\"format\", \"img\")\nif fmt not in VALID:\n    raise ValueError(f\"format must be one of {VALID}, got {fmt!r}\")","typeGuard":"def is_valid_format(fmt) -> bool:\n    return fmt in {\"img\", \"svg\", \"pdf\"}","tryCatchPattern":"try:\n    pipeline.draw(path=\"graph.png\", params=params)\nexcept ValueError as e:\n    logger.error(\"Bad format param: %s\", e)","preventionTips":["Use format='img' with type='png'/'jpeg' for raster images","Validate params against a Literal/enum at config boundaries","Consult the current draw() docstring — valid formats changed across versions"],"tags":["python","validation","mermaid","pipeline-drawing"],"backgroundTag":"invalid-enum-value","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}