{"record":{"id":"12065ab784960705","repo":"Comfy-Org/ComfyUI","slug":"expression-cannot-be-empty","errorCode":null,"errorMessage":"Expression cannot be empty.","messagePattern":"Expression cannot be empty\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"comfy_extras/nodes_math.py","lineNumber":93,"sourceCode":"                \"eval\", \"math\",\n            ],\n            inputs=[\n                io.String.Input(\"expression\", default=\"a + b\", multiline=True),\n                io.Autogrow.Input(\"values\", template=autogrow),\n            ],\n            outputs=[\n                io.Float.Output(display_name=\"FLOAT\"),\n                io.Int.Output(display_name=\"INT\"),\n                io.Boolean.Output(display_name=\"BOOL\"),\n            ],\n        )\n\n    @classmethod\n    def execute(\n        cls, expression: str, values: io.Autogrow.Type\n    ) -> io.NodeOutput:\n        if not expression.strip():\n            raise ValueError(\"Expression cannot be empty.\")\n\n        context: dict = dict(values)\n        context[\"values\"] = list(values.values())\n\n        result = simple_eval(expression, names=context, functions=MATH_FUNCTIONS)\n        # bool check must come first because bool is a subclass of int in Python\n        if not isinstance(result, (int, float)):\n            raise ValueError(\n                f\"Math Expression '{expression}' must evaluate to a numeric result, \"\n                f\"got {type(result).__name__}: {result!r}\"\n            )\n        try:\n            float_result = float(result)\n        except OverflowError:\n            raise ValueError(\n                f\"Math Expression '{expression}' produced a result too large to \"\n                f\"represent as a float: {result}\"\n            ) from None","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_extras/nodes_math.py#L75-L111","documentation":"Raised by the Math Expression node's execute() when the expression string, after strip(), is empty. An empty expression cannot be evaluated (simple_eval would raise a syntax error), so the node fails fast with an explicit, friendly message instead.","triggerScenarios":"Leaving the expression widget blank and running the workflow; an expression consisting only of whitespace; a workflow-loading path that clears the widget; pasting a value that starts with a newline only.","commonSituations":"Newly added nodes run before the user types anything; templates with unfilled placeholders; frontends that submit default empty strings.","solutions":["Type a valid expression, e.g. 'values[0] * 2' or 'a + b' with named Autogrow inputs.","If the node is not needed, bypass (Ctrl+B) or delete it instead of running it empty.","Check that a workflow variable substitution did not blank out the expression field."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if not expression or not expression.strip():\n    raise ValueError(\"Expression cannot be empty — type a numeric expression like 'values[0] * 2'\")","typeGuard":"def is_nonempty_expression(expr: str) -> bool:\n    return isinstance(expr, str) and len(expr.strip()) > 0","tryCatchPattern":null,"preventionTips":["Fill in the expression widget before running the node.","Bypass or delete unused math nodes instead of executing them blank.","Check template variable substitution did not blank the field."],"tags":["math","expression","validation","empty-input"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}