{"record":{"id":"e5d612e7d70b19b8","repo":"apache/iceberg","slug":"cannot-call-refresh-on-temporary-table-operations-e5d612","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/hadoop/HadoopTableOperations.java","lineNumber":199,"sourceCode":"    return LocationProviders.locationsFor(current().location(), current().properties());\n  }\n\n  @Override\n  public String metadataFileLocation(String fileName) {\n    return metadataPath(fileName).toString();\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 HadoopTableOperations.this.metadataFileLocation(fileName);\n      }\n\n      @Override\n      public LocationProvider locationProvider() {\n        return LocationProviders.locationsFor(\n            uncommittedMetadata.location(), uncommittedMetadata.properties());\n      }","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/hadoop/HadoopTableOperations.java#L181-L217","documentation":"During commit, HadoopTableOperations builds a temporary TableOperations wrapper holding uncommitted metadata to compute the new state. Its refresh() is intentionally unsupported because there is no on-disk state to refresh from; calling it throws UnsupportedOperationException. It is an internal API-misuse guard, not a runtime condition.","triggerScenarios":"Calling refresh() on the temporary operations instance exposed during a commit transaction; code that generically calls ops.refresh() on any TableOperations it holds, including the transient one from within a commit callback.","commonSituations":"Custom commit listeners or hooks that refresh the table mid-commit; reflection-driven or generic framework code treating all TableOperations uniformly.","solutions":["Do not call refresh() on operations instances obtained during a commit; only refresh the outer HadoopTableOperations","Capture needed state (e.g., uncommittedMetadata via current()) instead of refreshing","Restructure code so refresh happens before commit() begins, not inside it"],"exampleFix":"// before: inside a commit-time callback\ntempOps.refresh();\n// after\nTableMetadata pending = tempOps.current(); // use in-memory state instead","handlingStrategy":"type-guard","validationCode":"if (isTemporaryOps(ops)) { /* skip refresh */ }","typeGuard":"boolean isRefreshable(TableOperations ops) { return ops instanceof HadoopTableOperations; }","tryCatchPattern":null,"preventionTips":["Never call refresh() inside commit-time hooks or on transient operations instances","Read in-memory state via current() on temporary operations","Centralize refresh logic to operate only on the outer operations object"],"tags":["unsupported-operation","commit","internal"],"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"}