{"record":{"id":"2aebe21e99f7fc8f","repo":"apache/iceberg","slug":"uncheckedioexception-wrapping-ioexception-from-jso","errorCode":null,"errorMessage":"UncheckedIOException wrapping IOException from JSON generation","messagePattern":"UncheckedIOException wrapping IOException from JSON generation","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/expressions/ExpressionParser.java","lineNumber":94,"sourceCode":"\n    /**\n     * A convenience method to make code more readable by calling {@code toJson} instead of {@code\n     * get()}\n     */\n    private void toJson(Supplier<Void> child) {\n      child.get();\n    }\n\n    @FunctionalInterface\n    private interface Task {\n      void run() throws IOException;\n    }\n\n    private Void generate(Task task) {\n      try {\n        task.run();\n      } catch (IOException e) {\n        throw new UncheckedIOException(e);\n      }\n\n      return null;\n    }\n\n    @Override\n    public Void alwaysTrue() {\n      return generate(() -> gen.writeBoolean(true));\n    }\n\n    @Override\n    public Void alwaysFalse() {\n      return generate(() -> gen.writeBoolean(false));\n    }\n\n    @Override\n    public Void not(Supplier<Void> child) {\n      return generate(","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/expressions/ExpressionParser.java#L76-L112","documentation":"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.","triggerScenarios":"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.","commonSituations":"Serializing expressions to a file/socket-backed Writer that fails mid-write; custom generator configurations that violate Jackson invariants.","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."],"exampleFix":"// before\nString json = ExpressionParser.toJson(expr);\n// after\ntry {\n  String json = ExpressionParser.toJson(expr);\n} catch (UncheckedIOException e) {\n  throw new RuntimeException(\"expression serialization failed: \" + e.getCause(), e);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  String json = ExpressionParser.toJson(expr);\n} catch (UncheckedIOException e) {\n  throw new RuntimeException(\"expression JSON generation failed\", e.getCause());\n}","preventionTips":["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."],"tags":["jackson","json","serialization","expressions"],"backgroundTag":"json-serialization-failed","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}