{"record":{"id":"5055e704f24dd212","repo":"prestodb/presto","slug":"iceberg-invalid-metadata-5055e7","errorCode":"ICEBERG_INVALID_METADATA","errorMessage":"Cannot read manifest files. Manifests may be written by a newer Iceberg version.","messagePattern":"Cannot read manifest files\\. Manifests may be written by a newer Iceberg version\\.","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-iceberg/src/main/java/com/facebook/presto/iceberg/SnapshotsTable.java","lineNumber":123,"sourceCode":"    private static List<Page> buildPages(ConnectorTableMetadata tableMetadata, ConnectorSession session, Table icebergTable)\n    {\n        PageListBuilder pagesBuilder = PageListBuilder.forTable(tableMetadata);\n        RuntimeStats runtimeStats = session.getRuntimeStats();\n        TableScan tableScan = buildTableScan(icebergTable, SNAPSHOTS, runtimeStats);\n        TimeZoneKey timeZoneKey = session.getTimeZoneKey();\n\n        Map<String, Integer> columnNameToPosition = columnNameToPositionInSchema(tableScan.schema());\n\n        try (CloseableIterable<FileScanTask> fileScanTasks = tableScan.planFiles()) {\n            fileScanTasks.forEach(fileScanTask -> addRows((DataTask) fileScanTask, pagesBuilder, timeZoneKey, columnNameToPosition));\n        }\n        catch (IOException e) {\n            throw new UncheckedIOException(e);\n        }\n        catch (RuntimeException e) {\n            // Catch Avro-specific exceptions that may occur during manifest deserialization\n            if (isAvroException(e)) {\n                throw new PrestoException(ICEBERG_INVALID_METADATA,\n                        \"Cannot read manifest files. Manifests may be written by a newer Iceberg version.\", e);\n            }\n            throw e;\n        }\n\n        return pagesBuilder.build();\n    }\n\n    private static boolean checkNonNull(Object object, PageListBuilder pagesBuilder)\n    {\n        if (object == null) {\n            pagesBuilder.appendNull();\n            return false;\n        }\n        return true;\n    }\n\n    private static void addRows(DataTask dataTask, PageListBuilder pagesBuilder, TimeZoneKey timeZoneKey, Map<String, Integer> columnNameToPositionInSchema)","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-iceberg/src/main/java/com/facebook/presto/iceberg/SnapshotsTable.java#L105-L141","documentation":"SnapshotsTable.buildPages reads Iceberg manifest files (Avro) to build the $manifests/$snapshots metadata table. If manifest deserialization throws an Avro-related RuntimeException, the connector wraps it in a PrestoException with ICEBERG_INVALID_METADATA, signaling the metadata was produced by an incompatible (likely newer) Iceberg writer.","triggerScenarios":"Querying a metadata table (e.g. \"table$manifests\" or \"$snapshots\") whose manifest list/manifest files were written by a newer Iceberg version whose Avro schema the bundled reader cannot deserialize.","commonSituations":"Cluster upgraded its Iceberg writing library (Spark/Iceberg runtime) but Presto's bundled Iceberg/Avro libraries are older; reading a table written by a newer Iceberg release; mixed-version environments.","solutions":["Upgrade Presto/Trino to a version bundling an Iceberg/Avro library compatible with the writer version that produced the manifests","Downgrade or re-pin the writing engine's Iceberg version to match what Presto can read","Rewrite the table metadata with the older writer (e.g. rewrite_manifests / rewrite_data_files) so manifests are re-encoded in a readable format","Inspect the wrapped Avro exception (the PrestoException's cause) to confirm which schema/field is incompatible"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Check the Iceberg writer version in table metadata before querying manifests metadata tables\n// e.g. compare format-version / writer-version against the connector's supported version","typeGuard":null,"tryCatchPattern":"try {\n    // query table$manifests / $snapshots\n} catch (PrestoException e) {\n    if (e.getErrorCode().getName().equals(\"ICEBERG_INVALID_METADATA\")) {\n        // manifests written by newer Iceberg; fall back or upgrade connector\n    } else { throw e; }\n}","preventionTips":["Keep Presto's bundled Iceberg/Avro libraries in sync with the cluster's writing engine version","Avoid mixed Iceberg writer/reader versions in the same environment","Test metadata-table queries after any Iceberg runtime upgrade","Pin the writer engine to a version known compatible with the deployed Presto"],"tags":["iceberg","avro","metadata","version-compatibility"],"backgroundTag":"avro-schema-incompatible","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"}