apache/iceberg · error · UncheckedIOException
UncheckedIOException wrapping IOException from JSON generati
Error message
UncheckedIOException wrapping IOException from JSON generation
What it means
ExpressionParser's internal generate(Task) helper runs JSON-generation tasks against a Jackson JsonGenerator; IOException from Jackson is converted to UncheckedIOException because the parser's public fromJson/toJson API does not declare checked exceptions. The message documents the wrapping; the real diagnostic is the cause.
Source
Thrown at core/src/main/java/org/apache/iceberg/expressions/ExpressionParser.java:94
/**
* A convenience method to make code more readable by calling {@code toJson} instead of {@code
* get()}
*/
private void toJson(Supplier<Void> child) {
child.get();
}
@FunctionalInterface
private interface Task {
void run() throws IOException;
}
private Void generate(Task task) {
try {
task.run();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
return null;
}
@Override
public Void alwaysTrue() {
return generate(() -> gen.writeBoolean(true));
}
@Override
public Void alwaysFalse() {
return generate(() -> gen.writeBoolean(false));
}
@Override
public Void not(Supplier<Void> child) {
return generate(View on GitHub (pinned to 86d9c8fc54)
Solutions
- Catch UncheckedIOException at the toJson call site and inspect getCause() for the real IOException.
- Ensure the Writer/OutputStream passed to toJson is open and writable.
- Verify you are using the standard ExpressionParser.toJson(expression, generator) entry points rather than building custom generator tasks.
Example fix
// before
String json = ExpressionParser.toJson(expr);
// after
try {
String json = ExpressionParser.toJson(expr);
} catch (UncheckedIOException e) {
throw new RuntimeException("expression serialization failed: " + e.getCause(), e);
} Defensive patterns
Strategy: try-catch
Try / catch
try {
String json = ExpressionParser.toJson(expr);
} catch (UncheckedIOException e) {
throw new RuntimeException("expression JSON generation failed", e.getCause());
} Prevention
- Pass a healthy, open Writer/OutputStream to toJson.
- Do not write custom generator Tasks against the parser internals.
- Log the cause chain, not just the wrapper message.
When it happens
Trigger: Any ExpressionParser.toJson call whose underlying JsonGenerator raises IOException — e.g. writing to a failing Writer/output stream, or generator misuse such as writing a field outside an object.
Common situations: Serializing expressions to a file/socket-backed Writer that fails mid-write; custom generator configurations that violate Jackson invariants.
Understand the failure class
Background: "JSON serialization failed", "not JSON serializable", "Failed to serialize": why JSON marshaling errors happen and how to fix them — this error's family across 46 libraries.
Related errors
- Failed to encode request body: %s
- Unsupported task type:
- Cannot write unknown type:
- Failed to write json for: %s
- Cannot convert update requirement to json. Unrecognized type
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/2aebe21e99f7fc8f.
Report an issue: GitHub.