{"record":{"id":"8ed0a9d12f92ef06","repo":"apache/iceberg","slug":"failed-to-write-streamingoffset-to-json-8ed0a9","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.0/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.0/spark/src/main/java/org/apache/iceberg/spark/source/StreamingOffset.java#L81-L117","documentation":"Wrapping error in StreamingOffset.json: serializing the offset's fields (version, snapshotId, position, scanAllFiles) to JSON via the Jackson generator threw an IOException, rethrown as UncheckedIOException. Because output is a StringWriter, an IO failure here is essentially a serialization bug, not a storage problem.","triggerScenarios":"Calling StreamingOffset.json when the internal JsonFactory/generator fails (e.g. I/O error writing to the underlying writer, or invalid field values during generation).","commonSituations":"Rare JVM/Jackson-level failures during offset serialization when committing micro-batch progress; custom subclasses writing invalid fields.","solutions":["Inspect the wrapped cause for the generator failure","Retry the serialization — transient failures typically resolve","Verify the offset's snapshotId/position values are sane (no corrupt longs) before serialization","Report to Iceberg if it recurs, since this path should not fail under normal conditions"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  String json = offset.json();\n} catch (UncheckedIOException e) {\n  throw new RuntimeException(\"Offset serialization failed; abort batch commit\", e);\n}","preventionTips":["Keep offset field values within valid ranges (sane snapshotId/position)","Avoid custom offsets that write invalid JSON field shapes","Pin a stable Jackson version compatible with the Iceberg build"],"tags":["json-serialization-failed","spark","streaming"],"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-23T08:17:48.524Z"}