{"record":{"id":"773e88b84f44b3cb","repo":"invoke-ai/InvokeAI","slug":"begin-step-percent-must-be-less-than-or-equal-to-e","errorCode":null,"errorMessage":"Begin step percent must be less than or equal to end step percent","messagePattern":"Begin step percent must be less than or equal to end step percent","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/app/invocations/util.py","lineNumber":14,"sourceCode":"from typing import Union\n\n\ndef validate_weights(weights: Union[float, list[float]]) -> None:\n    \"\"\"Validate that all control weights in the valid range\"\"\"\n    to_validate = weights if isinstance(weights, list) else [weights]\n    if any(i < -1 or i > 2 for i in to_validate):\n        raise ValueError(\"Control weights must be within -1 to 2 range\")\n\n\ndef validate_begin_end_step(begin_step_percent: float, end_step_percent: float) -> None:\n    \"\"\"Validate that begin_step_percent is less than or equal to end_step_percent\"\"\"\n    if begin_step_percent > end_step_percent:\n        raise ValueError(\"Begin step percent must be less than or equal to end step percent\")\n","sourceCodeStart":1,"sourceCodeEnd":15,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/util.py#L1-L15","documentation":"validate_begin_end_step enforces that a conditioning adapter's begin_step_percent is <= end_step_percent, i.e. the percent window must be ordered. An inverted window (start after end) is rejected with ValueError.","triggerScenarios":"Calling validate_begin_end_step_percent with begin_step_percent=0.8, end_step_percent=0.2 when configuring a ControlNet/IP-Adapter's step window.","commonSituations":"Swapping the two fields in a workflow node or UI; computing percentages dynamically and dividing by the wrong base; copying begin/end values into the wrong inputs.","solutions":["Ensure begin_step_percent <= end_step_percent (e.g. begin=0.2, end=0.8)","Swap the two values if they were entered in the wrong order","Clamp with min/max when computing programmatically"],"exampleFix":"// before\nvalidate_begin_end_step(0.8, 0.2)\n// after\nvalidate_begin_end_step(min(a, b), max(a, b))  # e.g. (0.2, 0.8)","handlingStrategy":"validation","validationCode":"if not (0.0 <= begin_step_percent <= end_step_percent <= 1.0):\n    raise ValueError(\"require 0 <= begin <= end <= 1\")","typeGuard":"def is_valid_step_window(b: float, e: float) -> bool:\n    return isinstance(b, float) and isinstance(e, float) and 0.0 <= b <= e <= 1.0","tryCatchPattern":"try:\n    validate_begin_end_step_percent(begin, end)\nexcept ValueError as e:\n    if \"Begin step percent\" in str(e):\n        begin, end = min(begin, end), max(begin, end)\n    else:\n        raise","preventionTips":["Enter begin/end values in order in the UI and double-check after edits","Use min/max when the percentages are computed dynamically","Keep both values within [0, 1]"],"tags":["validation","invokeai","scheduling"],"backgroundTag":"parameter-value-out-of-range","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}