apache/iceberg · error · UncheckedIOException
Failed to write Spark view dependencies
Error message
Failed to write Spark view dependencies
What it means
SparkViewDependenciesParser.toJson() wraps Jackson serialization in try/catch and rethrows IOException as UncheckedIOException('Failed to write Spark view dependencies', e). It indicates the JSON tree could not be serialized, which is practically an internal failure since JsonNode-based generation rarely throws.
Source
Thrown at spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkViewDependenciesParser.java:74
nameParts = ((TableDependency) dependency).nameParts();
} else if (dependency instanceof FunctionDependency) {
dependencyNode.put(TYPE, FUNCTION);
nameParts = ((FunctionDependency) dependency).nameParts();
} else {
throw new IllegalArgumentException(
"Unsupported Spark view dependency: " + dependency.getClass().getName());
}
ArrayNode namePartsNode = dependencyNode.putArray(NAME_PARTS);
for (String namePart : nameParts) {
namePartsNode.add(namePart);
}
}
try {
return MAPPER.writeValueAsString(dependenciesNode);
} catch (IOException e) {
throw new UncheckedIOException("Failed to write Spark view dependencies", e);
}
}
static DependencyList fromJson(String json) {
JsonNode node;
try {
node = MAPPER.readTree(json);
} catch (IOException e) {
throw new UncheckedIOException("Failed to parse Spark view dependencies", e);
}
Preconditions.checkArgument(
node.isArray(), "Cannot parse Spark view dependencies from non-array: %s", node);
ImmutableList.Builder<Dependency> dependenciesBuilder = ImmutableList.builder();
for (JsonNode dependency : node) {
String type = string(TYPE, dependency);
String[] nameParts = stringArray(NAME_PARTS, dependency);
switch (type) {View on GitHub (pinned to 86d9c8fc54)
Solutions
- Read the cause (getCause()) to see the underlying IOException/JsonMappingException
- Check for duplicate/mismatched Jackson jars on the classpath (jackson-databind version conflicts)
- Avoid mutating the dependenciesNode with non-serializable values in custom code paths
- If persistent, capture the full stack trace and report with the Iceberg/Spark versions
Defensive patterns
Strategy: try-catch
Try / catch
try { json = SparkViewDependenciesParser.toJson(deps); } catch (UncheckedIOException e) { log.error("View dependency serialization failed: {}", e.getCause(), e); throw e; } Prevention
- Log and inspect getCause() — the root is a Jackson IOException
- Keep a single jackson-databind version on the classpath
- Don't hand-build malformed JsonNode structures for view metadata
When it happens
Trigger: MAPPER.writeValueAsString(dependenciesNode) throwing IOException during view metadata persistence — e.g. JsonMappingException on an incompatible node structure from custom code injecting bad values.
Common situations: Corrupt or custom-built JsonNode graphs; ObjectMapper misconfiguration via shading/classpath conflicts with duplicate Jackson versions.
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 write Spark view query column names
- Failed to parse Spark view dependencies
- Unsupported Spark view dependency type:
- Failed to read StreamingOffset from json
- Renaming a view is not supported by catalog: ${catalogName}
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/e9602dea67edc229.
Report an issue: GitHub.