{"record":{"id":"cef9fa110dbd4325","repo":"apache/flink","slug":"the-to-value-must-not-be-smaller-than-the-from-cef9fa","errorCode":null,"errorMessage":"The 'to' value must not be smaller than the 'from' value.","messagePattern":"The 'to' value must not be smaller than the 'from' value\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/util/NumberSequenceIterator.java","lineNumber":50,"sourceCode":"\n    private static final long serialVersionUID = 1L;\n\n    /** The last number returned by the iterator. */\n    private final long to;\n\n    /** The next number to be returned. */\n    private long current;\n\n    /**\n     * Creates a new splittable iterator, returning the range [from, to]. Both boundaries of the\n     * interval are inclusive.\n     *\n     * @param from The first number returned by the iterator.\n     * @param to The last number returned by the iterator.\n     */\n    public NumberSequenceIterator(long from, long to) {\n        if (from > to) {\n            throw new IllegalArgumentException(\n                    \"The 'to' value must not be smaller than the 'from' value.\");\n        }\n\n        this.current = from;\n        this.to = to;\n    }\n\n    /**\n     * Internal constructor to allow for empty iterators.\n     *\n     * @param from The first number returned by the iterator.\n     * @param to The last number returned by the iterator.\n     * @param unused A dummy parameter to disambiguate the constructor.\n     */\n    private NumberSequenceIterator(long from, long to, boolean unused) {\n        this.current = from;\n        this.to = to;\n    }","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/util/NumberSequenceIterator.java#L32-L68","documentation":"NumberSequenceIterator(from, to) emits the inclusive range [from, to] and refuses from > to with IllegalArgumentException. It backs env.generateSequence(from, to) and other sequence sources. The guard catches inverted bounds before any split/iteration happens.","triggerScenarios":"new NumberSequenceIterator(10, 1); env.generateSequence(end, start) with swapped variables; from/to derived from config where the lower bound defaulted higher than the upper.","commonSituations":"Swapped constructor arguments; generated source parameters where 'from' exceeds 'to'; refactoring renaming bounds and inverting their assignment.","solutions":["Fix the argument order so from <= to.","If bounds come from config, validate/normalize (min/max) before constructing.","For an intentionally empty source, use 0 elements (e.g. from=1, to=0 is invalid too — skip creating the source instead)."],"exampleFix":"// before\nNumberSequenceIterator it = new NumberSequenceIterator(end, start); // swapped\n\n// after\nNumberSequenceIterator it = new NumberSequenceIterator(start, end);","handlingStrategy":"validation","validationCode":"Preconditions.checkArgument(from <= to, \"from (%s) must be <= to (%s)\", from, to);\nNumberSequenceIterator it = new NumberSequenceIterator(from, to);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Name bounds explicitly (lower/upper) to avoid swapped arguments.","Validate user-supplied bounds before building sources."],"tags":["iterator","validation","flink-core"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}