{"record":{"id":"100757a204fbd722","repo":"prestodb/presto","slug":"iceberg-invalid-metadata-100757","errorCode":"ICEBERG_INVALID_METADATA","errorMessage":"No metadata found at location %s","messagePattern":"No metadata found at location (.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-iceberg/src/main/java/com/facebook/presto/iceberg/procedure/RegisterTableProcedure.java","lineNumber":178,"sourceCode":"                    duplicateVersions = true;\n\n                    long modifiedTime = file.getModificationTime();\n                    if (modifiedTime > lastModifiedTime) {\n                        lastModifiedTime = modifiedTime;\n                        metadataFile = file.getPath();\n                    }\n                }\n            }\n        }\n        catch (IOException io) {\n            throw new PrestoException(ICEBERG_FILESYSTEM_ERROR, format(\"Unable to find metadata at location %s\", metadataPath), io);\n        }\n\n        if (duplicateVersions) {\n            clientSession.getWarningCollector().add(new PrestoWarning(MULTIPLE_TABLE_METADATA, format(\"Multiple metadata files of most recent version %d found at location %s. Using most recently modified version\", maxVersion, metadataPath)));\n        }\n        if (metadataFile == null) {\n            throw new PrestoException(ICEBERG_INVALID_METADATA, format(\"No metadata found at location %s\", metadataPath));\n        }\n\n        return metadataFile;\n    }\n\n    static int parseMetadataVersionFromFileName(String fileName)\n    {\n        Matcher matcher = METADATA_VERSION_PATTERN.matcher(fileName);\n        if (matcher.matches()) {\n            return parseInt(matcher.group(\"version\"));\n        }\n        matcher = HADOOP_METADATA_VERSION_PATTERN.matcher(fileName);\n        if (matcher.matches()) {\n            return parseInt(matcher.group(\"version\"));\n        }\n        return -1;\n    }\n}","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-iceberg/src/main/java/com/facebook/presto/iceberg/procedure/RegisterTableProcedure.java#L160-L196","documentation":"ICEBERG_INVALID_METADATA thrown by resolveLatestMetadataLocation when, after successfully listing the metadata path, no Iceberg metadata JSON file (e.g. v1.metadata.json / v2.metadata.json) with a parseable version is found. It indicates the location is not a valid Iceberg table metadata directory.","triggerScenarios":"register_table invoked on a location whose metadata directory contains no versioned metadata JSON files — empty directory, only data files, or metadata files with unparseable version names.","commonSituations":"Pointing register_table at the table root instead of the metadata/ subdirectory; wrong location (data-only directory); table written by a different tool with nonstandard metadata naming; metadata files deleted by orphan cleanup.","solutions":["Pass the correct location — typically the table's metadata/ directory, not the table root","Confirm files like 00001.metadata.json (vN.metadata.json) exist at the location","Check whether a retention/orphan-file cleanup job deleted the metadata files","If versions exist but aren't detected, verify filenames match the expected vN.metadata.json pattern"],"exampleFix":"// before\nCALL system.register_table(schema => 's', table => 't', table_location => 'hdfs://ns/warehouse/t')\n// after\nCALL system.register_table(schema => 's', table => 't', table_location => 'hdfs://ns/warehouse/t/metadata')","handlingStrategy":"validation","validationCode":"// Confirm versioned metadata JSON exists before invoking register_table\nboolean hasMetadata = fs.listStatus(new Path(location)).length > 0 &&\n    Arrays.stream(fs.listStatus(new Path(location)))\n          .anyMatch(f -> f.getPath().getName().matches(\"v\\\\d+\\.metadata\\.json\"));\nif (!hasMetadata) throw new IllegalStateException(\"No vN.metadata.json at \" + location);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Point table_location at the metadata/ directory, not the table root","Never let orphan-file cleanup delete vN.metadata.json files","Verify the writer tool produces standard Iceberg metadata file names","List the directory manually before running register_table"],"tags":["iceberg","metadata","validation","not-found"],"backgroundTag":"iceberg-metadata-not-found","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}