{"record":{"id":"d7049099b78e7a64","repo":"deepset-ai/haystack","slug":"scale-must-be-a-number-between-1-and-3","errorCode":null,"errorMessage":"Scale must be a number between 1 and 3.","messagePattern":"Scale must be a number between 1 and 3\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"haystack/core/pipeline/draw.py","lineNumber":153,"sourceCode":"    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):\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","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/core/pipeline/draw.py#L135-L171","documentation":"The mermaid 'scale' parameter is only valid within 1..3 (inclusive). Haystack raises this when params['scale'] is outside that range or not a number.","triggerScenarios":"params={'scale': 0}, {'scale': 5}, or a non-numeric string like '2x'.","commonSituations":"Users expecting CLI-style zoom factors (>3) or fractional scaling; misreading scale as a percentage.","solutions":["Clamp scale into range: params['scale'] = max(1, min(3, int(params['scale'])))","Use width/height for larger outputs instead of scale","Remove 'scale' if not supported by your target format"],"exampleFix":"// before\npipeline.draw(path=\"g.png\", params={\"width\": 1600, \"scale\": 5})  # ValueError\n// after\npipeline.draw(path=\"g.png\", params={\"width\": 3200})","handlingStrategy":"validation","validationCode":"if \"scale\" in params and not 1 <= params[\"scale\"] <= 3:\n    params[\"scale\"] = max(1, min(3, params[\"scale\"]))","typeGuard":"def valid_scale(params: dict) -> bool:\n    return \"scale\" not in params or (isinstance(params[\"scale\"], (int, float)) and 1 <= params[\"scale\"] <= 3)","tryCatchPattern":"try:\n    pipeline.draw(path, params=params)\nexcept ValueError as e:\n    if \"Scale\" in str(e):\n        params.pop(\"scale\", None)\n        pipeline.draw(path, params=params)","preventionTips":["Treat scale as a small multiplier (1-3), not zoom percentage","Prefer width/height for large output"],"tags":["mermaid","validation","params"],"backgroundTag":"invalid-parameter-type","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}