prestodb/presto · error · IllegalArgumentException
max-file-size-bytes must be non-negative, got: %s
Error message
max-file-size-bytes must be non-negative, got: %s
What it means
The max-file-size-bytes optimize option caps file sizes for rewrite planning; a negative byte value is invalid, so the parser throws IllegalArgumentException with the offending value interpolated. Null means unset and returns 0.
Source
Thrown at presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergUtil.java:1839
}
}
/**
* Parses and validates the max-file-size-bytes option value.
* Returns the parsed long value, or 0 if the option is not present.
*
* @throws IllegalArgumentException if the value is invalid
*/
public static long parseMaxFileSize(Map<String, String> options)
{
String maxFileSizeStr = options.get("max-file-size-bytes");
if (maxFileSizeStr == null) {
return 0;
}
try {
long maxFileSize = Long.parseLong(maxFileSizeStr);
if (maxFileSize < 0) {
throw new IllegalArgumentException(
String.format("max-file-size-bytes must be non-negative, got: %s", maxFileSize));
}
return maxFileSize;
}
catch (NumberFormatException e) {
throw new IllegalArgumentException(
String.format("max-file-size-bytes must be a valid long, got: %s", maxFileSizeStr), e);
}
}
/**
* Parses and validates the rewrite-all option value.
* Returns true if the option is set to "true", false otherwise.
*/
public static boolean parseRewriteAll(Map<String, String> options)
{
String rewriteAllStr = options.get("rewrite-all");
if (rewriteAllStr == null) {View on GitHub (pinned to 55bb57d202)
Solutions
- Pass a non-negative value (0 means unset/no cap).
- Omit the option entirely if no cap is desired.
- Clamp in generating code: Math.max(0, configuredBytes).
Example fix
// before
CALL system.optimize('db.t', map(ARRAY['max_file_size_bytes'], ARRAY['-1']));
// after
CALL system.optimize('db.t', map(ARRAY['max_file_size_bytes'], ARRAY['0'])); Defensive patterns
Strategy: validation
Validate before calling
long maxFileSize = Long.parseLong(raw);
if (maxFileSize < 0) throw new IllegalArgumentException("max-file-size-bytes must be >= 0"); Prevention
- Use 0 or omit the option for 'no cap' — negatives are always invalid.
- Clamp values with Math.max(0, bytes) when generating options programmatically.
- Validate whole option maps with a shared validator before calls.
When it happens
Trigger: Calling the optimize/rewrite procedure with max-file-size-bytes='-1024' or any negative long.
Common situations: Overflow/sign bugs in generated configuration; sign typos; misunderstanding that 0 means 'no cap' rather than accepting negatives.
Related errors
- min-input-files must be at least 1, got: %s
- min-file-size-bytes must be non-negative, got: %s
- min-input-files must be a valid integer, got: %s
- min-file-size-bytes must be a valid long, got: %s
- max-file-size-bytes must be a valid long, got: %s
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/eaf6e1b239380c25.
Report an issue: GitHub.