{"record":{"id":"e9602dea67edc229","repo":"apache/iceberg","slug":"failed-to-write-spark-view-dependencies","errorCode":null,"errorMessage":"Failed to write Spark view dependencies","messagePattern":"Failed to write Spark view dependencies","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkViewDependenciesParser.java","lineNumber":74,"sourceCode":"        nameParts = ((TableDependency) dependency).nameParts();\n      } else if (dependency instanceof FunctionDependency) {\n        dependencyNode.put(TYPE, FUNCTION);\n        nameParts = ((FunctionDependency) dependency).nameParts();\n      } else {\n        throw new IllegalArgumentException(\n            \"Unsupported Spark view dependency: \" + dependency.getClass().getName());\n      }\n\n      ArrayNode namePartsNode = dependencyNode.putArray(NAME_PARTS);\n      for (String namePart : nameParts) {\n        namePartsNode.add(namePart);\n      }\n    }\n\n    try {\n      return MAPPER.writeValueAsString(dependenciesNode);\n    } catch (IOException e) {\n      throw new UncheckedIOException(\"Failed to write Spark view dependencies\", e);\n    }\n  }\n\n  static DependencyList fromJson(String json) {\n    JsonNode node;\n    try {\n      node = MAPPER.readTree(json);\n    } catch (IOException e) {\n      throw new UncheckedIOException(\"Failed to parse Spark view dependencies\", e);\n    }\n\n    Preconditions.checkArgument(\n        node.isArray(), \"Cannot parse Spark view dependencies from non-array: %s\", node);\n    ImmutableList.Builder<Dependency> dependenciesBuilder = ImmutableList.builder();\n    for (JsonNode dependency : node) {\n      String type = string(TYPE, dependency);\n      String[] nameParts = stringArray(NAME_PARTS, dependency);\n      switch (type) {","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkViewDependenciesParser.java#L56-L92","documentation":"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.","triggerScenarios":"MAPPER.writeValueAsString(dependenciesNode) throwing IOException during view metadata persistence — e.g. JsonMappingException on an incompatible node structure from custom code injecting bad values.","commonSituations":"Corrupt or custom-built JsonNode graphs; ObjectMapper misconfiguration via shading/classpath conflicts with duplicate Jackson versions.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { json = SparkViewDependenciesParser.toJson(deps); } catch (UncheckedIOException e) { log.error(\"View dependency serialization failed: {}\", e.getCause(), e); throw e; }","preventionTips":["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"],"tags":["spark","iceberg","views","json","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"}