{"record":{"id":"6434e52f7d8ab3d1","repo":"apache/iceberg","slug":"unsupported-isolation-level-isolationlevel-6434e5","errorCode":null,"errorMessage":"Unsupported isolation level: + isolationLevel","messagePattern":"Unsupported isolation level: \\+ isolationLevel","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/source/SparkWrite.java","lineNumber":484,"sourceCode":"\n      int numAddedFiles = 0;\n      for (DataFile file : files(messages)) {\n        numAddedFiles += 1;\n        overwriteFiles.addFile(file);\n      }\n\n      // the scan may be null if the optimizer replaces it with an empty relation (e.g. false cond)\n      // no validation is needed in this case as the command does not depend on the table state\n      if (scan != null) {\n        switch (isolationLevel) {\n          case SERIALIZABLE:\n            commitWithSerializableIsolation(overwriteFiles, numOverwrittenFiles, numAddedFiles);\n            break;\n          case SNAPSHOT:\n            commitWithSnapshotIsolation(overwriteFiles, numOverwrittenFiles, numAddedFiles);\n            break;\n          default:\n            throw new IllegalArgumentException(\"Unsupported isolation level: \" + isolationLevel);\n        }\n\n      } else {\n        commitOperation(\n            overwriteFiles,\n            String.format(\n                Locale.ROOT, \"overwrite with %d new data files (no validation)\", numAddedFiles));\n      }\n    }\n\n    private void commitWithSerializableIsolation(\n        OverwriteFiles overwriteFiles, int numOverwrittenFiles, int numAddedFiles) {\n      Long scanSnapshotId = scan.snapshotId();\n      if (scanSnapshotId != null) {\n        overwriteFiles.validateFromSnapshot(scanSnapshotId);\n      }\n\n      Expression conflictDetectionFilter = conflictDetectionFilter();","sourceCodeStart":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/source/SparkWrite.java#L466-L502","documentation":"SparkWrite's OverwriteByFilter/OverwritePartitions commit only supports Serializable and Snapshot isolation levels. An IsolationLevel value outside this switch (default branch) is rejected with IllegalArgumentException before any commit operation runs.","triggerScenarios":"Calling commit on a SparkWrite overwrite operation whose write.isolation-level property resolves to something other than 'serializable' or 'snapshot'.","commonSituations":"Typo'd or invalid value for write.isolation-level table property or spark SQL conf; programmatic construction of SparkWrite with a custom IsolationLevel; version drift where a new level was added upstream but not handled.","solutions":["Set write.isolation-level to 'serializable' or 'snapshot' (case-insensitive) on the table or Spark conf","If set programmatically, pass only IsolationLevel.SERIALIZABLE or IsolationLevel.SNAPSHOT","Verify no engine/connector upgrade introduced an unrecognized isolation level"],"exampleFix":"// before\nALTER TABLE t SET TBLPROPERTIES ('write.isolation-level'='strict');\n// after\nALTER TABLE t SET TBLPROPERTIES ('write.isolation-level'='serializable');","handlingStrategy":"validation","validationCode":"String level = table.properties().getOrDefault(\"write.isolation-level\", \"serializable\").toLowerCase(Locale.ROOT);\nif (!level.equals(\"serializable\") && !level.equals(\"snapshot\")) {\n  throw new IllegalArgumentException(\"write.isolation-level must be 'serializable' or 'snapshot', got: \" + level);\n}","typeGuard":null,"tryCatchPattern":"try {\n  write.commit();\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Unsupported isolation level\")) {\n    // correct the write.isolation-level property and retry\n  } else throw e;\n}","preventionTips":["Only set write.isolation-level to 'serializable' or 'snapshot'","Validate table properties after any catalog migration or version upgrade","Parse isolation levels through the same code path the writer uses before committing"],"tags":["invalid-enum-value","spark","isolation-level","write"],"backgroundTag":"invalid-enum-value","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"}