{"record":{"id":"bffdead75efc5923","repo":"apache/flink","slug":"the-minimum-split-size-cannot-be-negative","errorCode":null,"errorMessage":"The minimum split size cannot be negative.","messagePattern":"The minimum split size cannot be negative\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/common/io/FileInputFormat.java","lineNumber":322,"sourceCode":"    /**\n     * Sets multiple paths of files to be read.\n     *\n     * @param filePaths The paths of the files to read.\n     */\n    public void setFilePaths(Path... filePaths) {\n        if (filePaths.length < 1) {\n            throw new IllegalArgumentException(\"At least one file path must be specified.\");\n        }\n        this.filePaths = filePaths;\n    }\n\n    public long getMinSplitSize() {\n        return minSplitSize;\n    }\n\n    public void setMinSplitSize(long minSplitSize) {\n        if (minSplitSize < 0) {\n            throw new IllegalArgumentException(\"The minimum split size cannot be negative.\");\n        }\n\n        this.minSplitSize = minSplitSize;\n    }\n\n    public int getNumSplits() {\n        return numSplits;\n    }\n\n    public void setNumSplits(int numSplits) {\n        if (numSplits < -1 || numSplits == 0) {\n            throw new IllegalArgumentException(\n                    \"The desired number of splits must be positive or -1 (= don't care).\");\n        }\n\n        this.numSplits = numSplits;\n    }\n","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/common/io/FileInputFormat.java#L304-L340","documentation":"minSplitSize is a lower bound on input split size used by the split assignment logic. A negative value has no physical meaning (splits cannot have negative size), so FileInputFormat.setMinSplitSize rejects it with IllegalArgumentException. Zero and positive values are accepted.","triggerScenarios":"Calling format.setMinSplitSize(-1) or any negative long.","commonSituations":"Computing min split size from a subtraction that underflows; passing -1 intending 'use default' (the format has no such sentinel — leave the setter uncalled instead); misconfiguring from a property that defaulted to -1.","solutions":["Pass a non-negative value, e.g. format.setMinSplitSize(0) to impose no minimum or a positive byte count.","Do not call setMinSplitSize if you want the default behavior.","Validate the computed value is >= 0 before calling."],"exampleFix":"// before\nformat.setMinSplitSize(minBytes); // minBytes == -1 -> throws\n\n// after\nlong min = minBytes >= 0 ? minBytes : 0;\nformat.setMinSplitSize(min);","handlingStrategy":"validation","validationCode":"long min = minSplitSize >= 0 ? minSplitSize : 0;\nformat.setMinSplitSize(min);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Coerce negative min split sizes to 0 (no minimum).","Leave the setter uncalled to keep the default.","Validate config-derived sizes at submission time."],"tags":["input-format","split-size","validation","illegal-argument"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}