{"record":{"id":"92e16c2efaa52ae2","repo":"apache/iceberg","slug":"cannot-call-refresh-on-temporary-table-operations-92e16c","errorCode":null,"errorMessage":"Cannot call refresh on temporary table operations","messagePattern":"Cannot call refresh on temporary table operations","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/rest/RESTTableOperations.java","lineNumber":343,"sourceCode":"    return metadataFileLocation(current(), filename);\n  }\n\n  @Override\n  public LocationProvider locationProvider() {\n    return LocationProviders.locationsFor(current().location(), current().properties());\n  }\n\n  @Override\n  public TableOperations temp(TableMetadata uncommittedMetadata) {\n    return new TableOperations() {\n      @Override\n      public TableMetadata current() {\n        return uncommittedMetadata;\n      }\n\n      @Override\n      public TableMetadata refresh() {\n        throw new UnsupportedOperationException(\n            \"Cannot call refresh on temporary table operations\");\n      }\n\n      @Override\n      public void commit(TableMetadata base, TableMetadata metadata) {\n        throw new UnsupportedOperationException(\"Cannot call commit on temporary table operations\");\n      }\n\n      @Override\n      public String metadataFileLocation(String fileName) {\n        return RESTTableOperations.metadataFileLocation(uncommittedMetadata, fileName);\n      }\n\n      @Override\n      public LocationProvider locationProvider() {\n        return LocationProviders.locationsFor(\n            uncommittedMetadata.location(), uncommittedMetadata.properties());\n      }","sourceCodeStart":325,"sourceCodeEnd":361,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/rest/RESTTableOperations.java#L325-L361","documentation":"An UnsupportedOperationException thrown by the temporary TableOperations wrapper created during commit flows (an in-flight/uncommitted metadata holder). Its refresh() is intentionally unimplemented because the temporary operations have no backing table to re-read metadata from; calling refresh on it is a caller logic error.","triggerScenarios":"Calling table.operations().refresh() (or code paths that internally refresh) on the temporary TableOperations returned while a create/replace transaction is in progress via RESTTableOperations' temp operations object.","commonSituations":"Custom transaction or write code that touches operations().refresh() mid-transaction; frameworks that opportunistically refresh metadata between commits; debugging code calling refresh on the in-flight table.","solutions":["Do not call refresh on temporary operations; finish the transaction commit first, then reload the table via catalog.loadTable(...) which has real operations.","Restructure code so metadata reads during a transaction use the in-memory current() metadata instead of refresh.","Catch UnsupportedOperationException around mid-transaction refresh calls if the code path is shared.","Use the Table from catalog.loadTable after commit for any subsequent refresh-dependent logic."],"exampleFix":"// before\ntable.operations().refresh(); // table here is the temp in-transaction ops\n// after\nTable committed = catalog.loadTable(ident);\ncommitted.refresh();","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"boolean supportsRefresh(TableOperations ops) { try { ops.refresh(); return true; } catch (UnsupportedOperationException e) { return false; } } // prefer: only call refresh on ops from catalog.loadTable","tryCatchPattern":"try { ops.refresh(); } catch (UnsupportedOperationException e) { /* temporary in-transaction operations; use current() or reload table */ }","preventionTips":["Never call operations().refresh() during an open create/replace transaction","Use current() for in-flight metadata reads","Reload via catalog.loadTable(identifier) after commit for refresh semantics","Avoid generic frameworks that blindly refresh operations on any Table reference"],"tags":["rest","table-operations","unsupported-operation","transaction"],"backgroundTag":"method-not-implemented","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"}