{"record":{"id":"140a757b326bd2c0","repo":"apache/iceberg","slug":"managing-snapshots-is-not-supported-by-getclass","errorCode":null,"errorMessage":"Managing snapshots is not supported by + getClass().getName()","messagePattern":"Managing snapshots is not supported by \\+ getClass\\(\\)\\.getName\\(\\)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/org/apache/iceberg/Transaction.java","lineNumber":175,"sourceCode":"  default UpdatePartitionStatistics updatePartitionStatistics() {\n    throw new UnsupportedOperationException(\n        \"Updating partition statistics is not supported by \" + getClass().getName());\n  }\n\n  /**\n   * Create a new {@link ExpireSnapshots expire API} to expire snapshots in this table.\n   *\n   * @return a new {@link ExpireSnapshots}\n   */\n  ExpireSnapshots expireSnapshots();\n\n  /**\n   * Create a new {@link ManageSnapshots manage snapshot API} to manage snapshots in this table.\n   *\n   * @return a new {@link ManageSnapshots}\n   */\n  default ManageSnapshots manageSnapshots() {\n    throw new UnsupportedOperationException(\n        \"Managing snapshots is not supported by \" + getClass().getName());\n  }\n\n  /**\n   * Apply the pending changes from all actions and commit.\n   *\n   * @throws ValidationException If any update cannot be applied to the current table metadata.\n   * @throws CommitFailedException If the updates cannot be committed due to conflicts.\n   */\n  void commitTransaction();\n}\n","sourceCodeStart":157,"sourceCodeEnd":187,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/api/src/main/java/org/apache/iceberg/Transaction.java#L157-L187","documentation":"Transaction.manageSnapshots() is a default API method that throws UnsupportedOperationException because the concrete Transaction implementation does not support snapshot management operations. Iceberg uses this pattern for optional API surface: only implementations that can manage snapshots (e.g. a full table-backed transaction) override it. The message includes the class name so you can see which implementation lacks support.","triggerScenarios":"Calling transaction.manageSnapshots() (or table.transaction().manageSnapshots()) on a Transaction implementation that does not override the default method, e.g. transactions obtained from contexts that only support schema/partition updates.","commonSituations":"Wrapping table changes in a transaction and then attempting to cherry-pick, rollback, or set current snapshot through the same transaction; using a custom or catalog-provided Transaction class that implements only a subset of operations.","solutions":["Manage snapshots directly on the Table (table.manageSnapshots()) instead of through the Transaction.","Use separate transactions: commit data/schema changes first, then manage snapshots on the committed table.","Check the concrete Transaction implementation to confirm which operations it supports before using optional APIs.","Upgrade Iceberg if a newer version added snapshot-management support to your implementation."],"exampleFix":"// before\nTransaction tx = table.newTransaction();\ntx.manageSnapshots().cherrypick();\n\n// after\nTransaction tx = table.newTransaction();\ntx.newAppend().appendFile(file).commit();\ntx.commitTransaction();\ntable.manageSnapshots().cherrypick(snapshotId).commit();","handlingStrategy":"try-catch","validationCode":"if (tx.getClass().getSimpleName().toLowerCase().contains(\"transaction\") && tx instanceof Transaction) {\n  // only call manageSnapshots() on implementations known to support it\n}","typeGuard":"boolean supportsSnapshotMgmt = !tx.getClass().getName().contains(\"BaseTransaction\") && tx.manageSnapshotsIfSupported(); // feature-check via implementation docs","tryCatchPattern":"try {\n  tx.manageSnapshots().cherrypick(id).commit();\n} catch (UnsupportedOperationException e) {\n  // fall back to table.manageSnapshots()\n  table.manageSnapshots().cherrypick(id).commit();\n}","preventionTips":["Manage snapshots on the Table, not inside a Transaction.","Do not mix snapshot management with transactional multi-operation commits.","Check the implementation class before using optional default API methods."],"tags":["unsupported-operation","transaction","snapshots","api"],"backgroundTag":"unsupported-operation","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"}