apache/iceberg · error · IllegalArgumentException
Invalid rewrite job order name: %s
Error message
Invalid rewrite job order name: %s
What it means
RewriteJobOrder.fromName(String) converts a user-supplied order name (e.g. "bytes-asc", "files-desc") into the RewriteJobOrder enum. If the name, after replacing the first hyphen with an underscore and uppercasing, does not match an enum constant, the underlying valueOf IllegalArgumentException is rethrown with this message naming the invalid input.
Source
Thrown at api/src/main/java/org/apache/iceberg/RewriteJobOrder.java:64
private final String orderName;
RewriteJobOrder(String orderName) {
this.orderName = orderName;
}
public String orderName() {
return orderName;
}
public static RewriteJobOrder fromName(String orderName) {
Preconditions.checkArgument(orderName != null, "Invalid rewrite job order name: null");
// Replace the hyphen in order name with underscore to map to the enum value. For example:
// bytes-asc to BYTES_ASC
try {
return RewriteJobOrder.valueOf(orderName.replaceFirst("-", "_").toUpperCase(Locale.ROOT));
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(
String.format("Invalid rewrite job order name: %s", orderName), e);
}
}
}
View on GitHub (pinned to 86d9c8fc54)
Solutions
- Use one of the valid names: bytes-asc, bytes-desc, files-asc, files-desc, content-asc, content-desc (enum constants BYTES_ASC, BYTES_DESC, FILES_ASC, FILES_DESC, CONTENT_ASC, CONTENT_DESC).
- Check for typos and casing; the parser is case-insensitive but requires the exact word and single hyphen separator.
- Call RewriteJobOrder.values() or read the enum to list accepted names when unsure.
Example fix
// before
RewriteJobOrder order = RewriteJobOrder.fromName("size-asc"); // invalid
// after
RewriteJobOrder order = RewriteJobOrder.fromName("bytes-asc"); Defensive patterns
Strategy: validation
Validate before calling
static boolean isValidOrder(String name) {
if (name == null) return false;
try { RewriteJobOrder.valueOf(name.replaceFirst("-", "_").toUpperCase(Locale.ROOT)); return true; }
catch (IllegalArgumentException e) { return false; }
} Try / catch
try {
order = RewriteJobOrder.fromName(name);
} catch (IllegalArgumentException e) {
order = RewriteJobOrder.BYTES_ASC; // documented default with warning
} Prevention
- Restrict user-facing options to the documented names: bytes-asc/desc, files-asc/desc, content-asc/desc.
- Validate order names from config files at load time.
- Reuse RewriteJobOrder enum constants instead of hand-writing strings.
When it happens
Trigger: Passing an unrecognized rewrite.jobs order string to fromName — e.g. ordering config set to "bytes ascending", "size-asc", "bytes-ascending", or a typo like "bytes-acc" in table or procedure configuration.
Common situations: Misconfigured rewrite procedure options (rewrite_data_files / rewrite_delete_files sort orders) in Spark SQL, YAML job configs, or CLI flags where the order name was hand-typed.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- String.format("Invalid snapshot ref type: %s", snapshotRefTy
- Unknown row-level operation mode:
- Unrecognized ${WRITE_DISTRIBUTION_MODE}: ${writeMode}
- Unrecognized ${WRITE_DISTRIBUTION_MODE}: ${mode}
- Invalid file format: %s
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/7456ba6f9ba1d917.
Report an issue: GitHub.