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

  1. Catch UncheckedIOException at the toJson call site and inspect getCause() for the real IOException.
  2. Ensure the Writer/OutputStream passed to toJson is open and writable.
  3. 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

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


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/2aebe21e99f7fc8f. Report an issue: GitHub.