{"record":{"id":"47289162f72369ac","repo":"apache/iceberg","slug":"unexpected-contentscantask-type","errorCode":null,"errorMessage":"Unexpected ContentScanTask type: ","messagePattern":"Unexpected ContentScanTask type: ","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"flink/v2.1/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/v2.1/flink/src/main/java/org/apache/iceberg/flink/maintenance/operator/EqualityConvertReader.java#L108-L144","documentation":"The EqualityConvertReader dispatches each ReadCommand's ContentScanTask to a processor by concrete type (data file task, staging task, or EqualityDeleteFileScanTask). If a task of an unknown ContentScanTask subtype arrives, the reader throws IllegalStateException naming the class. The exception is caught, logged, and forwarded on the ERROR_STREAM and READER_ABORT_STREAM so the maintenance task fails cleanly.","triggerScenarios":"processElement receives a ReadCommand whose scan task is neither an expected data-file scan task nor an EqualityDeleteFileScanTask — e.g. after an Iceberg/Flink version change introduces a new ContentScanTask implementation, or a command was serialized by a different planner version.","commonSituations":"Mixing maintenance job versions: a checkpoint/savepoint restored commands planned by an older or newer planner that emits a task type this reader does not know; custom scan task implementations injected upstream.","solutions":["Ensure the planner (EqualityConvertPlanner) and reader come from the same Iceberg/Flink build; do not restore from a savepoint taken with a different version.","Log the task class name (included in the message) and add the corresponding instanceof branch or upgrade Iceberg to the version that supports that task type.","Discard in-flight commands and re-trigger the maintenance cycle so the planner re-plans with current task types."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// before submitting commands downstream\nif (!(task instanceof IniCloseableIterable)) { /* see guard */ }\nif (!(task instanceof DataFileScanTask || task instanceof EqualityDeleteFileScanTask)) {\n  throw new IllegalArgumentException(\"Unsupported task type: \" + task.getClass());\n}","typeGuard":"static boolean isSupportedTask(ContentScanTask<?> task) {\n  return task instanceof DataFileScanTask\n      || task instanceof EqualityDeleteFileScanTask;\n}","tryCatchPattern":"try {\n  processElement(cmd, ctx, out);\n} catch (IllegalStateException e) {\n  LOG.error(\"Unsupported scan task {}; re-planning required\", e.getMessage());\n  ctx.output(TaskResultAggregator.ERROR_STREAM, e);\n}","preventionTips":["Keep planner and reader on the same Iceberg/Flink build","Avoid restoring savepoints across incompatible Iceberg versions","Re-trigger planning after upgrades instead of replaying old in-flight commands"],"tags":["flink","internal-invariant","dispatch","type-mismatch"],"backgroundTag":"unexpected-response-shape","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"}