{"record":{"id":"a07b3dc467a7ca99","repo":"apache/iceberg","slug":"failed-to-write-streamingoffset-to-json-a07b3d","errorCode":null,"errorMessage":"Failed to write StreamingOffset to json","messagePattern":"Failed to write StreamingOffset to json","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/source/StreamingOffset.java","lineNumber":99,"sourceCode":"    }\n\n    return fromJsonNode(node);\n  }\n\n  @Override\n  public String json() {\n    StringWriter writer = new StringWriter();\n    try (JsonGenerator generator = JsonUtil.factory().createGenerator(writer)) {\n      generator.writeStartObject();\n      generator.writeNumberField(VERSION, CURR_VERSION);\n      generator.writeNumberField(SNAPSHOT_ID, snapshotId);\n      generator.writeNumberField(POSITION, position);\n      generator.writeBooleanField(SCAN_ALL_FILES, scanAllFiles);\n      generator.writeEndObject();\n      generator.flush();\n\n    } catch (IOException e) {\n      throw new UncheckedIOException(\"Failed to write StreamingOffset to json\", e);\n    }\n\n    return writer.toString();\n  }\n\n  long snapshotId() {\n    return snapshotId;\n  }\n\n  long position() {\n    return position;\n  }\n\n  boolean shouldScanAllFiles() {\n    return scanAllFiles;\n  }\n\n  @Override","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/source/StreamingOffset.java#L81-L117","documentation":"StreamingOffset.json() serializes the offset to JSON with a JsonGenerator and throws UncheckedIOException with this message if an IOException occurs during generation. Since generation is in-memory over a StringWriter this is rare and usually indicates a JVM/Jackson-level problem.","triggerScenarios":"Calling json() to persist a StreamingOffset into Spark's checkpoint while the underlying JsonGenerator/StringWriter throws an IOException (very rare in-memory failure).","commonSituations":"Rare — seen during checkpoint writes when serialization machinery misbehaves; effectively an internal error wrapper rather than a user-fixable condition.","solutions":["Retry the streaming batch; the failure is typically transient","If reproducible, report the full stack trace (wrapped IOException cause) to the Iceberg project","Confirm the Iceberg and Jackson versions are compatible and not mixed on the classpath"],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  String json = offset.json();\n} catch (UncheckedIOException e) {\n  // retry the batch; escalate if reproducible\n}","preventionTips":["Keep Jackson on the classpath at the version Iceberg expects","Avoid mixing Jackson versions in shaded/fat jars","Retry streaming batches on transient serialization failures"],"tags":["spark","streaming","json","serialization","io"],"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"}