{"record":{"id":"f53f36248b161cd7","repo":"deepset-ai/haystack","slug":"width-must-be-an-integer","errorCode":null,"errorMessage":"Width must be an integer.","messagePattern":"Width must be an integer\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"haystack/core/pipeline/draw.py","lineNumber":148,"sourceCode":"    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\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):","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/core/pipeline/draw.py#L130-L166","documentation":"Width for mermaid image rendering must be an integer (pixels). Haystack raises this when params['width'] is present but is not an int.","triggerScenarios":"Passing params={'width': '800'} (string from CLI/env), {'width': 800.0} (float), or {'width': None}.","commonSituations":"Reading dimensions from config files or CLI args where everything is a string; JSON numbers decoded oddly.","solutions":["Cast the value: params['width'] = int(params['width']) before calling draw","Pass a plain int literal instead of a string/float","Remove 'width' if scaling is handled elsewhere"],"exampleFix":"// before\npipeline.draw(path=\"g.png\", params={\"width\": \"800\"})  # ValueError\n// after\npipeline.draw(path=\"g.png\", params={\"width\": int(\"800\")})","handlingStrategy":"type-guard","validationCode":"if \"width\" in params and (not isinstance(params[\"width\"], int) or isinstance(params[\"width\"], bool)):\n    params[\"width\"] = int(params[\"width\"])","typeGuard":"def is_int_width(v) -> bool:\n    return isinstance(v, int) and not isinstance(v, bool)","tryCatchPattern":"try:\n    pipeline.draw(path, params=params)\nexcept ValueError as e:\n    if \"Width must be an integer\" in str(e):\n        params[\"width\"] = int(params[\"width\"])\n        pipeline.draw(path, params=params)","preventionTips":["int() coerce CLI/config-sourced dimensions","Remember bool is an int subclass but not a pixel value"],"tags":["mermaid","validation","type-error","params"],"backgroundTag":"invalid-parameter-type","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}