{"record":{"id":"06d42cd20eae0aa9","repo":"apache/iceberg","slug":"invalid-partition-data-for-content-file-expected","errorCode":null,"errorMessage":"Invalid partition data for content file: expected array or object (%s)","messagePattern":"Invalid partition data for content file: expected array or object \\((.+?)\\)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/ContentFileParser.java","lineNumber":404,"sourceCode":"        Object partitionValue = SingleValueParser.fromJson(field.type(), partitionNode.get(pos));\n        partitionData.set(pos, partitionValue);\n      }\n    } else if (partitionNode.isObject()) {\n      // Handle partition struct object format, which serializes by field ID and skips\n      // null partition values\n      Preconditions.checkState(\n          partitionNode.size() <= fields.size(),\n          \"Invalid partition data size: expected <= %s, actual = %s\",\n          fields.size(),\n          partitionNode.size());\n\n      StructLike structLike = (StructLike) SingleValueParser.fromJson(partitionType, partitionNode);\n      for (int pos = 0; pos < partitionData.size(); ++pos) {\n        Class<?> javaClass = fields.get(pos).type().typeId().javaClass();\n        partitionData.set(pos, structLike.get(pos, javaClass));\n      }\n    } else {\n      throw new IllegalArgumentException(\n          String.format(\n              \"Invalid partition data for content file: expected array or object (%s)\",\n              partitionNode));\n    }\n\n    return partitionData;\n  }\n\n  private static FileContent fileContentFromJson(String content) {\n    switch (content) {\n      case CONTENT_DATA:\n        return FileContent.DATA;\n      case CONTENT_POSITION_DELETES:\n        return FileContent.POSITION_DELETES;\n      case CONTENT_EQUALITY_DELETES:\n        return FileContent.EQUALITY_DELETES;\n      default:\n        // In 1.10 and before, file content is serialized as the FileContent enum value","sourceCodeStart":386,"sourceCodeEnd":422,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/ContentFileParser.java#L386-L422","documentation":"When parsing a ContentFile from JSON, the partition field must be a JSON array (positional values) or object (field-id keyed values). Any other node type (string, number, null, etc.) cannot be converted into partition data, so this IllegalArgumentException is thrown with the offending node.","triggerScenarios":"ContentFileParser.fromJson given a data/delete file entry whose 'partition' value is a scalar or other non-array/non-object JSON node.","commonSituations":"Hand-edited metadata/stats JSON; external tools emitting partition values as strings; truncated or corrupted JSON payloads.","solutions":["Emit partition data as an array of positional values or an object keyed by field ID.","Regenerate the JSON with Iceberg's ContentFileParser.toJson.","Validate the JSON shape before feeding it to fromJson."],"exampleFix":"// before\n{\"partition\": \"2024-01-01\"}\n// after\n{\"partition\": [\"2024-01-01\"]}","handlingStrategy":"validation","validationCode":"if (partitionNode != null && !partitionNode.isArray() && !partitionNode.isObject()) {\n  throw new IllegalArgumentException(\"partition must be array or object\");\n}","typeGuard":null,"tryCatchPattern":"try { ContentFileParser.fromJson(json, type); } catch (IllegalArgumentException e) {\n  throw new IllegalArgumentException(\"bad partition payload\", e);\n}","preventionTips":["Validate JSON shape before parsing.","Emit partition as array or field-id object only.","Round-trip test parser toJson/fromJson in CI."],"tags":["json","partition","parsing"],"backgroundTag":"schema-validation-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"}