{"record":{"id":"cde9f3fa59b6108e","repo":"deepset-ai/haystack","slug":"fit-must-be-a-boolean","errorCode":null,"errorMessage":"Fit must be a boolean.","messagePattern":"Fit must be a boolean\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"haystack/core/pipeline/draw.py","lineNumber":163,"sourceCode":"        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\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:","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/core/pipeline/draw.py#L145-L181","documentation":"For PDF output, the mermaid 'fit' option must be a boolean. Haystack validates this before requesting the PDF from mermaid.ink.","triggerScenarios":"params={'format': 'pdf', 'fit': 'true'} or {'fit': 1} when drawing a pipeline as PDF.","commonSituations":"Reading fit from CLI flags/env vars where it arrives as a string; JSON config with string booleans.","solutions":["Pass a real boolean: params['fit'] = True","Convert strings: params['fit'] = str(params['fit']).lower() == 'true'","Remove 'fit' and rely on paper/landscape sizing"],"exampleFix":"// before\npipeline.draw(path=\"g.pdf\", params={\"format\": \"pdf\", \"fit\": \"true\"})  # ValueError\n// after\npipeline.draw(path=\"g.pdf\", params={\"format\": \"pdf\", \"fit\": True})","handlingStrategy":"type-guard","validationCode":"if \"fit\" in params and not isinstance(params[\"fit\"], bool):\n    params[\"fit\"] = bool(params[\"fit\"])","typeGuard":"def is_bool_fit(params: dict) -> bool:\n    return \"fit\" not in params or isinstance(params[\"fit\"], bool)","tryCatchPattern":"try:\n    pipeline.draw(path, params=params)\nexcept ValueError as e:\n    if \"Fit must be a boolean\" in str(e):\n        params[\"fit\"] = params[\"fit\"] in (\"true\", 1, True)\n        pipeline.draw(path, params=params)","preventionTips":["Parse string booleans ('true'/'false') before passing","Note that bool(1) is True but int 1 passes isinstance int, keep it as True"],"tags":["mermaid","validation","type-error","pdf","params"],"backgroundTag":"invalid-parameter-type","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}