{"record":{"id":"c02582b6d909ad79","repo":"apache/flink","slug":"the-fetch-size-s-must-be-0-but-is-d","errorCode":null,"errorMessage":"The fetch size (%s) must be > 0, but is %d","messagePattern":"The fetch size \\((.+?)\\) must be > 0, but is (.+?)","errorType":"exception","errorClass":"IllegalConfigurationException","httpStatus":null,"severity":"error","filePath":"flink-connectors/flink-connector-files/src/main/java/org/apache/flink/connector/file/src/impl/StreamFormatAdapter.java","lineNumber":162,"sourceCode":"        return streamFormat.isSplittable();\n    }\n\n    @Override\n    public TypeInformation<T> getProducedType() {\n        return streamFormat.getProducedType();\n    }\n\n    private static TrackingFsDataInputStream openStream(\n            final Path file, final Configuration config, final long seekPosition)\n            throws IOException {\n\n        final FileSystem fs = file.getFileSystem();\n        final long fileLength = fs.getFileStatus(file).getLen();\n\n        final int fetchSize =\n                MathUtils.checkedDownCast(config.get(StreamFormat.FETCH_IO_SIZE).getBytes());\n        if (fetchSize <= 0) {\n            throw new IllegalConfigurationException(\n                    String.format(\n                            \"The fetch size (%s) must be > 0, but is %d\",\n                            StreamFormat.FETCH_IO_SIZE.key(), fetchSize));\n        }\n\n        final InflaterInputStreamFactory<?> deCompressor =\n                StandardDeCompressors.getDecompressorForFileName(file.getPath());\n\n        final FSDataInputStream inStream = fs.open(file);\n        return doWithCleanupOnException(\n                inStream,\n                () -> {\n                    final FSDataInputStream in =\n                            deCompressor == null\n                                    ? inStream\n                                    : new InputStreamFSInputWrapper(deCompressor.create(inStream));\n                    in.seek(seekPosition);\n                    return new TrackingFsDataInputStream(in, fileLength, fetchSize);","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-connectors/flink-connector-files/src/main/java/org/apache/flink/connector/file/src/impl/StreamFormatAdapter.java#L144-L180","documentation":"StreamFormatAdapter.openStream reads StreamFormat.FETCH_IO_SIZE from the configuration and casts it to an int via MathUtils.checkedDownCast. If the resulting fetchSize is zero or negative, it throws IllegalConfigurationException. FETCH_IO_SIZE is a MemorySize option that controls the I/O buffer size for reading streams; a value of 0 bytes or any value that truncates to <= 0 is invalid.","triggerScenarios":"The configuration option StreamFormat.FETCH_IO_SIZE is set to 0 bytes, a negative value, or a value that overflows when cast to int. The check is `fetchSize <= 0` after checkedDownCast, so even a very large value that doesn't overflow but is somehow 0 after cast would trigger it (though the realistic trigger is an explicit 0-byte configuration).","commonSituations":"Explicitly setting the fetch I/O size to 0 bytes in table or pipeline configuration. Misconfiguration where a MemorySize option is set to '0' or '0b'. Copy-paste error in config templates.","solutions":["Set StreamFormat.FETCH_IO_SIZE to a positive value, e.g. '1mb' or larger. The default is typically sufficient; remove the override if unsure.","If configuring programmatically, ensure MemorySize.ofBytes(N) where N > 0.","Search configuration files and table DDL options for any 'fetch-io-size' or equivalent key set to 0."],"exampleFix":"// before\nConfigOption<MemorySize> fetchSize = ...;\nconfig.set(StreamFormat.FETCH_IO_SIZE, MemorySize.parse(\"0\"));\n\n// after\nconfig.set(StreamFormat.FETCH_IO_SIZE, MemorySize.parse(\"1mb\"));\n// or simply omit the option to use the default","handlingStrategy":"validation","validationCode":"// Validate FETCH_IO_SIZE before starting the source\nMemorySize fetchSize = config.get(StreamFormat.FETCH_IO_SIZE);\nif (fetchSize.getBytes() <= 0) {\n    throw new IllegalArgumentException(\n        \"StreamFormat.FETCH_IO_SIZE must be > 0, got: \" + fetchSize);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never set StreamFormat.FETCH_IO_SIZE to 0 or a negative value.","Use the default value unless there is a specific reason to change it.","Validate MemorySize options in configuration builders before job submission."],"tags":["config","stream-format","fetch-size","illegal-config","flink"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}