{"record":{"id":"66b2f1648dd37525","repo":"apache/iceberg","slug":"cannot-load-metadata-metadata-file-location-is-nu","errorCode":null,"errorMessage":"Cannot load metadata: metadata file location is null","messagePattern":"Cannot load metadata: metadata file location is null","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/SerializableTable.java","lineNumber":138,"sourceCode":"  }\n\n  private String metadataFileLocation(Table table) {\n    if (table instanceof HasTableOperations) {\n      TableOperations ops = ((HasTableOperations) table).operations();\n      return ops.current().metadataFileLocation();\n    } else if (table instanceof BaseMetadataTable) {\n      return ((BaseMetadataTable) table).table().operations().current().metadataFileLocation();\n    } else {\n      return null;\n    }\n  }\n\n  private Table lazyTable() {\n    if (lazyTable == null) {\n      synchronized (this) {\n        if (lazyTable == null) {\n          if (metadataFileLocation == null) {\n            throw new UnsupportedOperationException(\n                \"Cannot load metadata: metadata file location is null\");\n          }\n\n          TableOperations ops =\n              new StaticTableOperations(metadataFileLocation, io, locationProvider());\n          this.lazyTable = newTable(ops, name);\n        }\n      }\n    }\n\n    return lazyTable;\n  }\n\n  protected Table newTable(TableOperations ops, String tableName) {\n    return new BaseTable(ops, tableName);\n  }\n\n  @Override","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/SerializableTable.java#L120-L156","documentation":"SerializableTable lazily reconstructs the underlying Table from its serialized metadata file location on first access. If the instance was built without a metadata file location, lazyTable() cannot load anything and throws this UnsupportedOperationException, wrapped as the load failure message.","triggerScenarios":"Accessing any lazy-delegating method (newScan(), schema(), io() consumers, etc.) on a SerializableTable that was constructed without a metadata file location.","commonSituations":"A table without a persisted metadata file (e.g., created via newTable on StaticTableOperations with null location) shipped to executors; tasks then fail when they try to touch the table.","solutions":["Serialize the table from a catalog-loaded Table that has a metadata file location","Do not wrap tables lacking a metadata file in SerializableTable for distribution","Re-create the table instance with explicit StaticTableOperations pointing at a valid metadata JSON path"],"exampleFix":"// before\nSerializableTable.of(inMemoryTable); // no metadata file\n// after\nTable t = catalog.loadTable(identifier); // has metadata location\nSerializableTable.of(t);","handlingStrategy":"validation","validationCode":"if (table.operations().current().metadataFileLocation() == null) { throw new IllegalStateException(\"Table has no metadata file; cannot serialize\"); }","typeGuard":null,"tryCatchPattern":"try { Table t = serializableTable.newScan().table(); } catch (UnsupportedOperationException e) { /* reload from catalog */ }","preventionTips":["Only distribute tables loaded from a catalog with persisted metadata","Avoid wrapping StaticTableOperations-based tables with null metadata location","Test serialization round-trips in CI"],"tags":["iceberg","serialization","null"],"backgroundTag":"missing-required-argument","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"}