{"record":{"id":"a90e2ff12c26ada5","repo":"Comfy-Org/ComfyUI","slug":"keyframe-times-must-be-finite-numbers-in-seconds","errorCode":null,"errorMessage":"Keyframe times must be finite numbers in seconds; got '{value}'.","messagePattern":"Keyframe times must be finite numbers in seconds; got '(.+?)'\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_api_nodes/nodes_bfl.py","lineNumber":1068,"sourceCode":"        raise ValueError(f\"FLUX 3 supports at most {_FLUX3_MAX_IMAGES} {field_name}, got {len(flat)}.\")\n    for tensor in flat:\n        _flux3_validate_image(tensor)\n    return flat\n\n\ndef _flux3_parse_times(value: str, image_count: int, duration: int | str) -> list[float]:\n    \"\"\"Parse one keyframe time in seconds per image: increasing, inside the clip.\"\"\"\n    parts = [part.strip() for part in value.split(\",\") if part.strip()]\n    if len(parts) != image_count:\n        raise ValueError(\n            f\"Give one time per keyframe image: got {len(parts)} time(s) for {image_count} image(s).\"\n        )\n    try:\n        times = [float(part) for part in parts]\n    except ValueError as exc:\n        raise ValueError(f\"Keyframe times must be numbers in seconds, comma-separated; got '{value}'.\") from exc\n    if not all(math.isfinite(time) for time in times):\n        raise ValueError(f\"Keyframe times must be finite numbers in seconds; got '{value}'.\")\n    if any(later <= earlier for earlier, later in zip(times, times[1:])):\n        raise ValueError(f\"Keyframe times must increase; got {times}.\")\n    if times[0] < 0:\n        raise ValueError(f\"Keyframe times cannot be negative; got {times[0]}.\")\n    cap = _FLUX3_MAX_DURATION if duration == \"auto\" else int(duration)\n    if times[-1] > cap:\n        raise ValueError(f\"Keyframe time {times[-1]}s is past the end of a {cap}s clip.\")\n    return times\n\n\nclass Flux3VideoNodeBase(IO.ComfyNode):\n    \"\"\"Shared widgets, request plumbing and polling for the FLUX 3 generation modes.\"\"\"\n\n    RATE_HD: float\n    RATE_FHD: float\n\n    @classmethod\n    def common_inputs(cls) -> list:","sourceCodeStart":1050,"sourceCodeEnd":1086,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api_nodes/nodes_bfl.py#L1050-L1086","documentation":"Keyframe times must be finite floats; math.isfinite rejects nan and inf. These would otherwise pass float() parsing but make clip timing undefined, so they are rejected explicitly.","triggerScenarios":"Passing 'nan', 'inf', '-inf', or arithmetic that evaluates to them (e.g. division by zero when building the string programmatically) in the keyframe times string.","commonSituations":"Computing times from user parameters where a zero duration divides to inf; string-building bugs producing 'nan'.","solutions":["Sanitize computed times: skip or clamp non-finite values before formatting the string.","Guard divisions: t = a / b if b else 0.0.","Validate with math.isfinite before wiring the value in."],"exampleFix":"# before\ntimes = [t / duration for t in offsets]  # duration=0 -> inf -> ValueError\n\n# after\ntimes = [t / duration if duration else 0.0 for t in offsets]\ntimes = [min(t, cap) if math.isfinite(t) else 0.0 for t in times]","handlingStrategy":"validation","validationCode":"import math\ntimes = [float(p) for p in value.split(\",\")]\nassert all(math.isfinite(t) for t in times), \"non-finite keyframe time\"","typeGuard":"def times_finite(value: str) -> bool:\n    import math\n    try:\n        return all(math.isfinite(float(p)) for p in value.split(\",\"))\n    except ValueError:\n        return False","tryCatchPattern":null,"preventionTips":["Guard divisions used to compute times.","Clamp or replace non-finite values before formatting.","Check math.isfinite on computed offsets."],"tags":["bfl","flux3","keyframes","nan","infinity","validation"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}