{"record":{"id":"7e98fec3778407f5","repo":"deepset-ai/haystack","slug":"scale-is-only-allowed-when-width-or-height-is-set","errorCode":null,"errorMessage":"Scale is only allowed when width or height is set.","messagePattern":"Scale is only allowed when width or height is set\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"haystack/core/pipeline/draw.py","lineNumber":155,"sourceCode":"\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\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\"","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/core/pipeline/draw.py#L137-L173","documentation":"mermaid.ink ignores scale unless explicit width or height is provided; haystack enforces this by raising when 'scale' is set but neither dimension is.","triggerScenarios":"Calling draw with params={'scale': 2} and no 'width'/'height' keys.","commonSituations":"Users copy a scale option from mermaid CLI docs without realizing haystack requires a dimension for it to take effect.","solutions":["Add a width or height alongside scale (e.g. {'width': 1024, 'scale': 2})","Drop 'scale' if you don't need it"],"exampleFix":"// before\npipeline.draw(path=\"g.png\", params={\"scale\": 2})  # ValueError\n// after\npipeline.draw(path=\"g.png\", params={\"scale\": 2, \"width\": 1024})","handlingStrategy":"validation","validationCode":"if \"scale\" in params and \"width\" not in params and \"height\" not in params:\n    params[\"width\"] = params.get(\"width\", 1024)","typeGuard":"def scale_has_dimension(params: dict) -> bool:\n    return \"scale\" not in params or \"width\" in params or \"height\" in params","tryCatchPattern":"try:\n    pipeline.draw(path, params=params)\nexcept ValueError as e:\n    if \"Scale is only allowed\" in str(e):\n        params.pop(\"scale\", None)\n        pipeline.draw(path, params=params)","preventionTips":["Always pair scale with an explicit width or height","Drop scale when relying on auto sizing"],"tags":["mermaid","validation","params"],"backgroundTag":"invalid-parameter-combination","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}