apache/iceberg · error · UnsupportedOperationException
Cannot serialize an eager input file
Error message
Cannot serialize an eager input file: <location>
What it means
EagerInputFile cannot serialize a Hadoop Configuration supplier because the eager wrapper does not preserve the delegate's configurable behavior. Calling serializeConfWith on the EagerInputFileConfigurable subclass throws UnsupportedOperationException to prevent broken serialization when shipping the input file to a remote task.
Solutions
- Use the delegate (original HadoopInputFile) for serialization instead of the eager wrapper.
- Avoid wrapping in EagerInputFile before the serializeConfWith step.
- Extract needed configuration eagerly and pass a SerializableSupplier yourself.
- If this is framework-internal, gate the call with instanceof checks.
Example fix
// before
file.serializeConfWith(conf -> () -> conf); // UnsupportedOperationException on eager file
// after
if (file instanceof EagerInputFile) {
delegateInputFile.serializeConfWith(conf -> () -> conf);
} else {
file.serializeConfWith(conf -> () -> conf);
} Defensive patterns
Strategy: type-guard
Validate before calling
boolean serializable = !(inputFile instanceof EagerInputFile);
if (!serializable) { unwrapAndUseDelegate(inputFile); } Type guard
static InputFile serializableInputFile(InputFile f) {
if (f instanceof EagerInputFile) {
throw new UnsupportedOperationException("Use the delegate for serialization");
}
return f;
} Try / catch
try {
file.serializeConfWith(supplier);
} catch (UnsupportedOperationException e) {
delegateOf(file).serializeConfWith(supplier);
} Prevention
- Keep a reference to the original InputFile before wrapping in EagerInputFile
- Apply serializeConfWith before eager caching in framework code
- Gate with instanceof EagerInputFile when handling arbitrary InputFiles
- Don't distribute eager wrappers across task boundaries
When it happens
Trigger: Calling serializeConfWith(Function<Configuration, SerializableSupplier<Configuration>>) on an eager input file instance, typically in code paths that prepare Hadoop-backed FileIO for serialization to executors.
Common situations: Distributing an eagerly-cached InputFile with Spark/Flink that was wrapped from a HadoopInputFile; framework code unconditionally calling serializeConfWith on all input files.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Cannot serialize a Hadoop input file: " + location()
- Cannot serialize FileIO
- Cannot serialize type: + typeId
- Cannot write unsupported term
- Configuration was not serialized on purpose but was not set…
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/a98ca866c5fec54a.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/apache/iceberg/io/EagerInputFile.java:116
EagerInputFileConfigurable(InputFile delegate, long length) {
super(delegate, length);
Preconditions.checkArgument(
delegate instanceof HadoopConfigurable,
"Cannot create Hadoop Configurable Eager Input File because %s does not implement HadoopConfigurable",
delegate.getClass().getName());
this.delegate = (HadoopConfigurable) delegate;
}
@Override
public Configuration getConf() {
return delegate.getConf();
}
@Override
public void serializeConfWith(
Function<Configuration, SerializableSupplier<Configuration>> confSerializer) {
throw new UnsupportedOperationException(
"Cannot serialize an eager input file: " + location());
}
}
}
View on GitHub (pinned to 86d9c8fc54)