{"record":{"id":"00fc56bcb9298f88","repo":"deepset-ai/haystack","slug":"paper-size-must-be-a-string-e-g-a4-a3","errorCode":null,"errorMessage":"Paper size must be a string (e.g., 'a4', 'a3').","messagePattern":"Paper size must be a string \\(e\\.g\\., 'a4', 'a3'\\)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"haystack/core/pipeline/draw.py","lineNumber":165,"sourceCode":"    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:\n    \"\"\"\n    Validate that the Mermaid server response actually contains the expected image/SVG/PDF data.","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/core/pipeline/draw.py#L147-L183","documentation":"Haystack validates Mermaid.ink query parameters before rendering a pipeline diagram. When the output format is 'pdf', the optional 'paper' parameter (page size such as 'a4' or 'a3') must be a string. This ValueError is raised in _validate_mermaid_params when a non-string value (e.g., a list or int) is passed for 'paper'.","triggerScenarios":"Calling Pipeline.draw() or show() with a Mermaid config whose format is 'pdf' and paper set to a non-string value, e.g. {'format': 'pdf', 'paper': ['a4']} or paper=4.","commonSituations":"Users copy JavaScript/CLI examples where paper sizes are arrays, build params programmatically from config files (YAML/JSON) where a paper size list is parsed as a list, or confuse the 'paper' key with the 'format' key.","solutions":["Ensure params['paper'] is a single string like 'a4' or 'a3'","If passing multiple sizes, pick one instead of a list","Validate/normalize the config value with str() before calling draw()"],"exampleFix":"// before\nparams = {\"format\": \"pdf\", \"paper\": [\"a4\"]}\n// after\nparams = {\"format\": \"pdf\", \"paper\": \"a4\"}","handlingStrategy":"validation","validationCode":"params = {\"format\": \"pdf\", \"paper\": \"a4\"}\nif params.get(\"format\") == \"pdf\" and \"paper\" in params and not isinstance(params[\"paper\"], str):\n    raise TypeError(\"paper must be a string, e.g. 'a4'\")","typeGuard":"def is_str(v) -> bool:\n    return isinstance(v, str)","tryCatchPattern":"try:\n    pipeline.draw(path=\"graph.pdf\", params=params)\nexcept ValueError as e:\n    logger.error(\"Invalid Mermaid params: %s\", e)","preventionTips":["Validate Mermaid params dicts at config load time","Use literals 'a4'/'a3' rather than parsed config values without coercion","Add a small schema check (e.g., pydantic) for draw params"],"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"}