apache/seatunnel · error · IllegalArgumentException

Binary chunk size must be positive, got

Error message

Binary chunk size must be positive, got: %s

What it means

BinaryReadStrategy.init reads the optional binary_chunk_size option and validates that it is a positive integer. Values <= 0 would break chunked reads (infinite loop or no progress), so a plain IllegalArgumentException is thrown immediately with the offending value.

Solutions

  1. Set binary_chunk_size to a positive integer number of bytes, e.g. 8192.
  2. Remove the option to use the connector default chunk size.
  3. If the intent was a small value, use at least 1 byte; realistically use a few KB or more.

Example fix

// before
binary_chunk_size = 0
// after
binary_chunk_size = 8192
Defensive patterns

Strategy: validation

Validate before calling

// Java
int chunk = config.getInt("binary_chunk_size", DEFAULT_CHUNK);
if (chunk <= 0) {
    throw new IllegalArgumentException("binary_chunk_size must be positive, got: " + chunk);
}

Prevention

When it happens

Trigger: Configuring binary_chunk_size = 0 or a negative integer (e.g. -1024) in the file source config before a binary read.

Common situations: Users attempting to 'disable' chunking by setting 0; sign errors in generated configs; unit confusion expecting the value in KB instead of bytes.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/d625af6e01d6f0cf. Report an issue: GitHub.

Appendix: source

Thrown at seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/source/reader/BinaryReadStrategy.java:78

    public void init(HadoopConf conf) {
        super.init(conf);
        basePath = pluginConfig.getString(FileBaseSourceOptions.FILE_PATH.key());
        try {
            basePathIsFile = hadoopFileSystemProxy.isFile(basePath);
        } catch (IOException e) {
            throw new FileConnectorException(
                    SeaTunnelAPIErrorCode.CONFIG_VALIDATION_FAILED,
                    "Failed to determine whether file source path is a file or directory: "
                            + basePath,
                    e);
        }

        // Load binary chunk size configuration
        if (pluginConfig.hasPath(FileBaseSourceOptions.BINARY_CHUNK_SIZE.key())) {
            binaryChunkSize = pluginConfig.getInt(FileBaseSourceOptions.BINARY_CHUNK_SIZE.key());
            // Validate chunk size - should be positive and reasonable
            if (binaryChunkSize <= 0) {
                throw new IllegalArgumentException(
                        "Binary chunk size must be positive, got: " + binaryChunkSize);
            }
            if (binaryChunkSize > 100 * 1024 * 1024) { // 100MB limit
                throw new IllegalArgumentException(
                        "Binary chunk size too large (max 100MB), got: " + binaryChunkSize);
            }
        }

        // Load complete file mode configuration
        if (pluginConfig.hasPath(FileBaseSourceOptions.BINARY_COMPLETE_FILE_MODE.key())) {
            completeFileMode =
                    pluginConfig.getBoolean(FileBaseSourceOptions.BINARY_COMPLETE_FILE_MODE.key());
        }
    }

    @Override
    public void read(String path, String tableId, Collector<SeaTunnelRow> output)
            throws IOException, FileConnectorException {

View on GitHub (pinned to cf67b549a7)