{"record":{"id":"833af930e81585f7","repo":"deepset-ai/haystack","slug":"landscape-must-be-a-boolean","errorCode":null,"errorMessage":"Landscape must be a boolean.","messagePattern":"Landscape must be a boolean\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"haystack/core/pipeline/draw.py","lineNumber":167,"sourceCode":"    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\n    if params[\"format\"] == \"pdf\":\n        if \"fit\" in params and not isinstance(params[\"fit\"], bool):\n            raise ValueError(\"Fit must be a boolean.\")\n        if \"paper\" in params and not isinstance(params[\"paper\"], str):\n            raise ValueError(\"Paper size must be a string (e.g., 'a4', 'a3').\")\n        if \"landscape\" in params and not isinstance(params[\"landscape\"], bool):\n            raise ValueError(\"Landscape must be a boolean.\")\n        if \"fit\" in params and (\"paper\" in params or \"landscape\" in params):\n            logger.warning(\"`fit` overrides `paper` and `landscape` for PDFs. Ignoring `paper` and `landscape`.\")\n\n\n# Magic-byte signatures used to verify a Mermaid server response matches the requested output format.\n_PNG_SIGNATURE = b\"\\x89PNG\\r\\n\\x1a\\n\"\n_JPEG_SIGNATURE = b\"\\xff\\xd8\\xff\"\n_PDF_SIGNATURE = b\"%PDF-\"\n_RIFF_SIGNATURE = b\"RIFF\"\n_WEBP_SIGNATURE = b\"WEBP\"\n_SVG_PREFIXES = (b\"<?xml\", b\"<svg\")\n\n\ndef _validate_image_response(resp: httpx.Response, params: dict[str, Any]) -> None:\n    \"\"\"\n    Validate that the Mermaid server response actually contains the expected image/SVG/PDF data.\n\n    `Pipeline.draw()` writes the raw response body to disk, so a misconfigured or malicious","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/core/pipeline/draw.py#L149-L185","documentation":"When rendering a pipeline diagram as PDF via Mermaid.ink, the optional 'landscape' parameter must be a boolean. _validate_mermaid_params raises this ValueError if a truthy/falsy non-boolean (e.g., the strings \"true\"/\"false\", or 1/0) is supplied.","triggerScenarios":"Calling Pipeline.draw() or show() with params like {'format': 'pdf', 'landscape': 'true'} or {'format': 'pdf', 'landscape': 1}.","commonSituations":"Values loaded from environment variables or CLI args are strings ('true'), JSON configs where landscape is 0/1, or users confusing Python bool semantics with string flags.","solutions":["Set params['landscape'] to the Python boolean True or False","Convert string flags with landscape = raw.lower() == 'true'","Note: 'fit': True overrides paper/landscape anyway; consider using fit instead"],"exampleFix":"// before\nparams = {\"format\": \"pdf\", \"landscape\": \"true\"}\n// after\nparams = {\"format\": \"pdf\", \"landscape\": True}","handlingStrategy":"type-guard","validationCode":"if params.get(\"format\") == \"pdf\" and \"landscape\" in params and not isinstance(params[\"landscape\"], bool):\n    params[\"landscape\"] = params[\"landscape\"] in (True, \"true\", 1)","typeGuard":"def is_bool(v) -> bool:\n    return isinstance(v, bool)","tryCatchPattern":"try:\n    pipeline.draw(path=\"graph.pdf\", params=params)\nexcept ValueError as e:\n    logger.error(\"Invalid Mermaid params: %s\", e)","preventionTips":["Coerce CLI/env string flags to real booleans before building params","Remember bool is not str/int in Python's isinstance checks","Consider using {'fit': True} which overrides paper/landscape"],"tags":["python","validation","mermaid","pipeline-drawing"],"backgroundTag":"invalid-parameter-type","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}