{"record":{"id":"e1c674bfe3a4d79a","repo":"apache/iceberg","slug":"unexpected-contentscantask-type-task-getclass","errorCode":null,"errorMessage":"Unexpected ContentScanTask type: <task.getClass().getName()>","messagePattern":"Unexpected ContentScanTask type: <task\\.getClass\\(\\)\\.getName\\(\\)>","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/maintenance/operator/EqualityConvertReader.java","lineNumber":126,"sourceCode":"  @Override\n  public void processElement(ReadCommand cmd, Context ctx, Collector<IndexCommand> out)\n      throws Exception {\n    ContentScanTask<?> task = cmd.task();\n    ContentFile<?> file = task.file();\n    try {\n      if (task instanceof FileScanTask dataTask) {\n        processDataFile(\n            dataTask,\n            cmd.mainSnapshotId(),\n            cmd.indexGeneration(),\n            cmd.dataSequenceNumber(),\n            cmd.staging(),\n            out);\n      } else if (task instanceof EqualityDeleteFileScanTask deleteTask) {\n        processDeleteFile(\n            deleteTask, cmd.mainSnapshotId(), cmd.indexGeneration(), cmd.dataSequenceNumber(), out);\n      } else {\n        throw new IllegalStateException(\n            \"Unexpected ContentScanTask type: \" + task.getClass().getName());\n      }\n    } catch (Exception e) {\n      LOG.error(\"Reader failed to process command for file={}\", file.location(), e);\n      ctx.output(TaskResultAggregator.ERROR_STREAM, e);\n      ctx.output(READER_ABORT_STREAM, DVPosition.ABORT);\n    }\n  }\n\n  private void processDataFile(\n      FileScanTask task,\n      Long mainSnapshotId,\n      Long indexGeneration,\n      long dataSequenceNumber,\n      boolean staging,\n      Collector<IndexCommand> out)\n      throws IOException {\n    ContentFile<?> file = task.file();","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/maintenance/operator/EqualityConvertReader.java#L108-L144","documentation":"The reader operator received a ReadCommand whose scan task is of a ContentScanTask subtype it cannot process (neither a data-file task it recognizes nor an EqualityDeleteFileScanTask). This is an internal contract violation between the planner's emitted tasks and the reader's supported types. The operator logs the failure, emits to the error stream, and signals ABORT on READER_ABORT_STREAM.","triggerScenarios":"A planner (or custom code feeding the reader input stream) emits a scan task type outside {DataFileScanTask-like, EqualityDeleteFileScanTask}, e.g. a position-delete scan task or a new task class introduced by an upgrade.","commonSituations":"Mixed Iceberg connector versions in the job jar; a V2 positional-delete task reaching the reader after misconfiguration; custom operators injecting tasks into the reader stream.","solutions":["Align all Iceberg Flink maintenance classes to a single version - check the deployed jar for duplicates/multiple Iceberg versions on the classpath.","Check the TaskResultAggregator error stream for the offending task class name and trace which operator emitted it.","Ensure the planner only feeds supported tasks (data files and equality delete scan tasks) into the reader stream.","If you added a new task type, extend EqualityConvertReader.processElement to handle it explicitly."],"exampleFix":"// before: reader knows only DataFile/EqualityDelete tasks\n// after: add explicit handling or reject early in the planner\nif (!(task instanceof DataFileScanTask || task instanceof EqualityDeleteFileScanTask)) {\n  throw new IllegalStateException(\"Planner emitted unsupported task type: \" + task.getClass());\n}","handlingStrategy":"type-guard","validationCode":"// validate before pushing commands into the reader stream\ncheckState(task instanceof DataFileScanTask || task instanceof EqualityDeleteFileScanTask,\n    \"Unsupported task type: \" + task.getClass());","typeGuard":"boolean isReaderSupportedTask(ContentScanTask<?> task) {\n  return task instanceof DataFileScanTask || task instanceof EqualityDeleteFileScanTask;\n}","tryCatchPattern":"// reader already aborts via READER_ABORT_STREAM; monitor it\nREADER_ABORT_STREAM.process((ctx, abort) -> {\n  if (abort == DVPosition.ABORT) failJob(\"reader aborted: unsupported scan task\");\n});","preventionTips":["Keep planner and reader classes from the same connector build.","Do not add custom scan-task producers upstream of EqualityConvertReader.","Watch the error/abort side streams in tests after upgrading Iceberg.","Grep your classpath for multiple org.apache.iceberg versions."],"tags":["flink","internal-error","type-mismatch"],"backgroundTag":"internal-invariant-violation","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"}