{"record":{"id":"3af07b8f2c5354a3","repo":"apache/iceberg","slug":"duplicate-id","errorCode":null,"errorMessage":"Duplicate id: ","messagePattern":"Duplicate id: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/sink/dynamic/CompareSchemasVisitor.java","lineNumber":284,"sourceCode":"      if (listField != null) {\n        return listField.type().asListType().fields().get(0).fieldId();\n      }\n\n      return null;\n    }\n  }\n\n  public enum Result {\n    SAME(0),\n    DATA_CONVERSION_NEEDED(1),\n    SCHEMA_UPDATE_NEEDED(2);\n\n    private static final Map<Integer, Result> BY_ID = Maps.newHashMap();\n\n    static {\n      for (Result e : Result.values()) {\n        if (BY_ID.put(e.id, e) != null) {\n          throw new IllegalArgumentException(\"Duplicate id: \" + e.id);\n        }\n      }\n    }\n\n    private final int id;\n\n    Result(int id) {\n      this.id = id;\n    }\n\n    private Result merge(Result other) {\n      return BY_ID.get(Math.max(this.id, other.id));\n    }\n  }\n}\n","sourceCodeStart":266,"sourceCodeEnd":300,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/sink/dynamic/CompareSchemasVisitor.java#L266-L300","documentation":"CompareSchemasVisitor.Result builds a BY_ID lookup map in its static initializer and throws IllegalArgumentException if two enum constants share the same numeric id. This is an internal invariant check — users never cause it directly; it indicates a bug or binary-mixing in the Iceberg code itself.","triggerScenarios":"Loading a modified/duplicated CompareSchemasVisitor class where two Result constants have equal ids — practically only from code changes or classpath conflicts loading two versions of the class.","commonSituations":"Patched Iceberg jars on the classpath; custom forks; mixing iceberg-flink-runtime versions across the job classpath so conflicting definitions load.","solutions":["Ensure a single, unmodified iceberg-flink/iceberg-core jar set is on the classpath (remove duplicate/shaded copies)","If running a patched build, restore the original enum ids so each Result has a unique id","Report upstream if a released Iceberg version reproduces this — it is an internal invariant violation"],"exampleFix":"// before\nenum Result {\n  SAME(0), DIFFERENT(0); // duplicate id\n// after\nenum Result {\n  SAME(0), DIFFERENT(1);","handlingStrategy":"validation","validationCode":"// Classpath sanity check before job submission\nSet<String> copies = new LinkedHashSet<>();\nClassLoader cl = Thread.currentThread().getContextClassLoader();\nfor (String jar : System.getProperty(\"java.class.path\").split(File.pathSeparator)) {\n  if (jar.contains(\"iceberg-flink-runtime\") && !copies.add(new File(jar).getName())) {\n    throw new IllegalStateException(\"multiple iceberg-flink-runtime jars on classpath: \" + copies);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never ship more than one iceberg-flink-runtime jar version in the job/cluster classpath","Avoid patching enum ids in forked Iceberg code; bump ids uniquely when adding constants","Report releases reproducing this to the Iceberg project — it is a code-level invariant, not user error"],"tags":["flink","schema","internal-invariant","classpath"],"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-23T08:17:48.524Z"}