{"record":{"id":"bb7c702f039ddae5","repo":"Comfy-Org/ComfyUI","slug":"cannot-convert-non-finite-value-to-number-float","errorCode":null,"errorMessage":"Cannot convert non-finite value to number: {float_val}","messagePattern":"Cannot convert non-finite value to number: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_extras/nodes_number_convert.py","lineNumber":64,"sourceCode":"            int_val = 1 if value else 0\n        elif isinstance(value, int):\n            float_val = float(value)\n            int_val = value\n        elif isinstance(value, float):\n            float_val = value\n            int_val = int(value)\n        elif isinstance(value, str):\n            text = value.strip()\n            if not text:\n                raise ValueError(\"Cannot convert empty string to number.\")\n            try:\n                float_val = float(text)\n            except ValueError:\n                raise ValueError(\n                    f\"Cannot convert string to number: {value!r}\"\n                ) from None\n            if not math.isfinite(float_val):\n                raise ValueError(\n                    f\"Cannot convert non-finite value to number: {float_val}\"\n                )\n            try:\n                int_val = int(text)\n            except ValueError:\n                int_val = int(float_val)\n        else:\n            raise TypeError(\n                f\"Unsupported input type: {type(value).__name__}\"\n            )\n\n        if not math.isfinite(float_val):\n            raise ValueError(\n                f\"Cannot convert non-finite value to number: {float_val}\"\n            )\n\n        return io.NodeOutput(float_val, int_val)\n","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_extras/nodes_number_convert.py#L46-L82","documentation":"Raised inside the string branch of the number-conversion node when float(text) succeeds but the result is NaN or ±Infinity (math.isfinite fails). This catches strings like 'nan', 'inf', '-infinity' which parse but cannot represent a usable workflow number.","triggerScenarios":"Input strings 'nan', 'NaN', 'inf', '-inf', '+Infinity', or float-overflowing scientific notation such as '1e999' (parses to inf). Only in the string branch, immediately after float_val is computed.","commonSituations":"Upstream math or data pipelines emitting NaN/Inf as text; placeholder sentinel values like 'inf' used for 'no limit'; hand-typed scientific notation that overflows float64.","solutions":["Replace the value with a finite number (e.g. a large but finite bound like 1e6 instead of 'inf').","Sanitize upstream computations that produce NaN so they emit a real default.","Use the node's plain number inputs instead of strings when you need large values."],"exampleFix":"// before\nNumberConvert(value=\"inf\")\n// after\nNumberConvert(value=\"1000000\")","handlingStrategy":"validation","validationCode":"import math\ntext = text.strip()\ntry:\n    v = float(text)\nexcept ValueError:\n    raise ValueError(f\"not a number: {text!r}\")\nif not math.isfinite(v):\n    raise ValueError(f\"non-finite value not allowed: {text!r}\")","typeGuard":"def is_finite_number_string(text: str) -> bool:\n    try:\n        return math.isfinite(float(text.strip()))\n    except ValueError:\n        return False","tryCatchPattern":null,"preventionTips":["Never use 'inf'/'nan' strings as sentinels through this node.","Bound 'unlimited' values with large finite constants like 1e6."],"tags":["type-conversion","nan","infinity","number","validation"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}