{"record":{"id":"1d9fb8065c305ddf","repo":"apache/iceberg","slug":"unsupported-file-type-file-getclass-getsimple","errorCode":null,"errorMessage":"Unsupported file type: ${file.getClass().getSimpleName()}","messagePattern":"Unsupported file type: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/SnapshotSummary.java","lineNumber":134,"sourceCode":"    }\n\n    public void addedFile(PartitionSpec spec, DataFile file) {\n      metrics.addedFile(file);\n      updatePartitions(spec, file, true);\n    }\n\n    public void addedFile(PartitionSpec spec, DeleteFile file) {\n      metrics.addedFile(file);\n      updatePartitions(spec, file, true);\n    }\n\n    public void deletedFile(PartitionSpec spec, ContentFile<?> file) {\n      if (file instanceof DataFile) {\n        deletedFile(spec, (DataFile) file);\n      } else if (file instanceof DeleteFile) {\n        deletedFile(spec, (DeleteFile) file);\n      } else {\n        throw new IllegalArgumentException(\n            \"Unsupported file type: \" + file.getClass().getSimpleName());\n      }\n    }\n\n    public void deletedFile(PartitionSpec spec, DataFile file) {\n      metrics.removedFile(file);\n      updatePartitions(spec, file, false);\n    }\n\n    public void deletedFile(PartitionSpec spec, DeleteFile file) {\n      metrics.removedFile(file);\n      updatePartitions(spec, file, false);\n    }\n\n    public void addedManifest(ManifestFile manifest) {\n      this.trustPartitionMetrics = false;\n      partitionMetrics.clear();\n      metrics.addedManifest(manifest);","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/SnapshotSummary.java#L116-L152","documentation":"SnapshotSummary's deletedFile(PartitionSpec, ContentFile) dispatches on the concrete file type and only accepts DataFile and DeleteFile. Any other ContentFile implementation (a custom or newer-spec ContentFile subtype) throws IllegalArgumentException. It indicates the producer was handed a file type this Iceberg version does not know how to summarize.","triggerScenarios":"Calling newDelete/newOverwrite/newRowDelta .deleteFile(...) (or a producer path that records deletions) with a ContentFile that is neither DataFile nor DeleteFile — e.g., a custom ContentFile implementation, or a file type from a newer format/spec read by an older Iceberg runtime.","commonSituations":"Custom engines/wrappers building their own ContentFile impls instead of Iceberg's GenericDataFile/GenericDeleteFile; classpath with an older Iceberg version than the one that wrote the table (version skew); generic file-rewrite frameworks passing wrapped files of the wrong type.","solutions":["Pass the concrete Iceberg types: use the file's DataFile or DeleteFile reference (e.g., from table.io / GenericDataFile) rather than a custom ContentFile.","Align Iceberg versions — upgrade the runtime to the version that matches the table's format version and the file classes in use.","Check the reported class name in the message; if it's your own class, make it extend GenericDataFile/GenericDeleteFile or convert it with DataFiles/transform builders."],"exampleFix":"// before\nContentFile<?> wrapped = myEngineFile.toContentFile(); // custom impl\ntable.newRowDelta().addDeletes((DeleteFile) wrapped); // or deleteFile(wrapped) -> IllegalArgumentException\n// after\nDeleteFile deleteFile = GenericDeleteFile.of(...); // or the original DataFile/DeleteFile instance\ntable.newRowDelta().addDeletes(deleteFile).commit();","handlingStrategy":"type-guard","validationCode":"// only pass concrete Iceberg file types to producers\nboolean supported = file instanceof DataFile || file instanceof DeleteFile;","typeGuard":"static DeleteFile asDeleteFile(ContentFile<?> f) {\n  Preconditions.checkArgument(f instanceof DeleteFile,\n      \"Expected DeleteFile, got %s\", f.getClass().getSimpleName());\n  return (DeleteFile) f;\n}","tryCatchPattern":"try {\n  producer.deletedFile(spec, contentFile);\n} catch (IllegalArgumentException e) {\n  throw new IllegalStateException(\"Unsupported ContentFile impl: \" + contentFile.getClass() +\n      \"; convert to DataFile/DeleteFile\", e);\n}","preventionTips":["Always construct files with Iceberg's builders (DataFiles.builder, GenericDeleteFile) instead of custom ContentFile implementations.","Keep the Iceberg runtime version aligned with the table's format version and writing engine.","Narrow to DataFile/DeleteFile at API boundaries rather than passing ContentFile<?> around generically.","Add an early instanceof assertion when adapting third-party file objects into Iceberg operations."],"tags":["illegal-argument","type-mismatch","file-type","summary"],"backgroundTag":"invalid-argument-value","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"}