{"record":{"id":"d7dad9dc1482f907","repo":"apache/iceberg","slug":"unsupported-isolation-level-isolationlevel","errorCode":null,"errorMessage":"Unsupported isolation level: ${isolationLevel}","messagePattern":"Unsupported isolation level: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/source/SparkWrite.java","lineNumber":460,"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":442,"sourceCodeEnd":478,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/source/SparkWrite.java#L442-L478","documentation":"SparkWrite.commit() dispatches to a commit strategy based on the configured IsolationLevel. Only SERIAL and SNAPSHOT isolation levels are recognized for branch writes; any other value throws IllegalArgumentException, indicating a corrupted or unknown isolation-level configuration.","triggerScenarios":"Committing a write whose isolationLevel resolved (from write.*.isolation-level table properties via IsolationLevel.fromName) to something other than SERIAL or SNAPSHOT — typically an unrecognized string mapping to an unexpected enum/null value.","commonSituations":"A typo'd isolation-level property value, a new IsolationLevel added in a newer version used with an older write path, or programmatic construction with a bogus value.","solutions":["Set write.*.isolation-level table properties only to 'serializable' or 'snapshot'.","Fix typos in the isolation-level property so IsolationLevel.fromName resolves to a known value.","Align Iceberg versions so the write path knows every IsolationLevel value."],"exampleFix":"// before\nALTER TABLE t SET TBLPROPERTIES ('write.merge.isolation-level' = 'serial');\n\n// after\nALTER TABLE t SET TBLPROPERTIES ('write.merge.isolation-level' = 'serializable');","handlingStrategy":"validation","validationCode":"String level = table.properties().getOrDefault(\"write.merge.isolation-level\", \"serializable\");\nif (!level.equals(\"serializable\") && !level.equals(\"snapshot\")) {\n  throw new IllegalArgumentException(\"Invalid isolation level: \" + level);\n}","typeGuard":null,"tryCatchPattern":"try {\n  write.commit();\n} catch (IllegalArgumentException e) {\n  logger.error(\"Bad write.*.isolation-level property\", e);\n}","preventionTips":["Only set isolation-level values to 'serializable' or 'snapshot'.","Validate table properties after imports/migrations.","Keep write path and enum versions in sync."],"tags":["spark","isolation-level","commit","invalid-enum-value"],"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"}