{"record":{"id":"844fe3be064e0d58","repo":"invoke-ai/InvokeAI","slug":"stop-must-be-greater-than-start","errorCode":null,"errorMessage":"stop must be greater than start","messagePattern":"stop must be greater than start","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/app/invocations/collections.py","lineNumber":25,"sourceCode":"from invokeai.app.invocations.baseinvocation import BaseInvocation, invocation\nfrom invokeai.app.invocations.fields import InputField\nfrom invokeai.app.invocations.primitives import IntegerCollectionOutput\nfrom invokeai.app.services.shared.invocation_context import InvocationContext\nfrom invokeai.app.util.misc import SEED_MAX\n\n\n@invocation(\"range\", title=\"Integer Range\", tags=[\"collection\", \"integer\", \"range\"], category=\"batch\", version=\"1.0.0\")\nclass RangeInvocation(BaseInvocation):\n    \"\"\"Creates a range of numbers from start to stop with step\"\"\"\n\n    start: int = InputField(default=0, description=\"The start of the range\")\n    stop: int = InputField(default=10, description=\"The stop of the range\")\n    step: int = InputField(default=1, description=\"The step of the range\")\n\n    @field_validator(\"stop\")\n    def stop_gt_start(cls, v: int, info: ValidationInfo):\n        if \"start\" in info.data and v <= info.data[\"start\"]:\n            raise ValueError(\"stop must be greater than start\")\n        return v\n\n    def invoke(self, context: InvocationContext) -> IntegerCollectionOutput:\n        return IntegerCollectionOutput(collection=list(range(self.start, self.stop, self.step)))\n\n\n@invocation(\n    \"range_of_size\",\n    title=\"Integer Range of Size\",\n    tags=[\"collection\", \"integer\", \"size\", \"range\"],\n    category=\"batch\",\n    version=\"1.0.0\",\n)\nclass RangeOfSizeInvocation(BaseInvocation):\n    \"\"\"Creates a range from start to start + (size * step) incremented by step\"\"\"\n\n    start: int = InputField(default=0, description=\"The start of the range\")\n    size: int = InputField(default=1, gt=0, description=\"The number of values\")","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/collections.py#L7-L43","documentation":"A Pydantic field_validator on the RangeInvocation enforces that stop is strictly greater than start whenever start is present in the validated data. This runs at input validation time, before invoke().","triggerScenarios":"Creating/queueing a Range node with stop <= start (e.g. start=10, stop=10, or start=5, stop=2). Note a reversed range like start=10, stop=1 with step=-1 also fails because the check requires strict inequality.","commonSituations":"Computing start/stop from variables where a swap accidentally reversed them; default edits in the UI; users expecting Python-style descending range() with negative step.","solutions":["Swap the values so stop > start.","If a descending range is intended, this node does not support it via validation — build the collection in code instead.","Add UI/client-side validation so start/stop are checked before submitting the graph."],"exampleFix":"// before\nRangeInvocation(start=10, stop=1, step=-1)\n// after\nRangeInvocation(start=1, stop=10, step=1)  # then reverse the collection if needed","handlingStrategy":"validation","validationCode":"if stop <= start:\n    raise ValueError(f\"stop ({stop}) must be greater than start ({start})\")","typeGuard":null,"tryCatchPattern":"try:\n    node = RangeInvocation(start=start, stop=stop, step=step)\nexcept ValidationError as e:\n    log_and_correct_range_bounds(e)","preventionTips":["Compute stop as start + count rather than independently","Validate bounds at the client before submitting graphs","Remember descending ranges are rejected by the validator"],"tags":["validation","pydantic","collections"],"backgroundTag":"schema-validation-failed","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}