{"record":{"id":"b81dcfbb61afd38f","repo":"apache/iceberg","slug":"unknown-field-ordinal-b81dcf","errorCode":null,"errorMessage":"Unknown field ordinal: ","messagePattern":"Unknown field ordinal: ","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/V2Metadata.java","lineNumber":145,"sourceCode":"          return wrapped.snapshotId();\n        case 7:\n          return wrapped.addedFilesCount();\n        case 8:\n          return wrapped.existingFilesCount();\n        case 9:\n          return wrapped.deletedFilesCount();\n        case 10:\n          return wrapped.addedRowsCount();\n        case 11:\n          return wrapped.existingRowsCount();\n        case 12:\n          return wrapped.deletedRowsCount();\n        case 13:\n          return wrapped.partitions();\n        case 14:\n          return wrapped.keyMetadata();\n        default:\n          throw new UnsupportedOperationException(\"Unknown field ordinal: \" + pos);\n      }\n    }\n\n    @Override\n    public String path() {\n      return wrapped.path();\n    }\n\n    @Override\n    public long length() {\n      return wrapped.length();\n    }\n\n    @Override\n    public int partitionSpecId() {\n      return wrapped.partitionSpecId();\n    }\n","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/V2Metadata.java#L127-L163","documentation":"V2Metadata.ManifestFileWrapper.get(pos) maps ordinals 0-14 to the V2 manifest-list schema (including partitions at 13 and key_metadata at 14). An out-of-range ordinal has no field and throws UnsupportedOperationException with the position, indicating the caller's struct shape does not match the V2 manifest schema.","triggerScenarios":"Calling get(pos) with pos < 0 or pos > 14 on a V2Metadata.ManifestFileWrapper, often from generic iteration code bounded by a V1 schema size or a wrong constant.","commonSituations":"Mixed-version code paths reading V1-sized structs against V2 wrappers; hardcoded indices that predate the partitions/key_metadata columns; reflection-based readers with stale schemas.","solutions":["Bound access by size() (14 for V2 manifest files) rather than hardcoded counts","Verify pos maps to a MANIFEST_LIST_SCHEMA column before calling get","Ensure V1 code paths use V1Metadata wrappers and V2 use V2Metadata wrappers"],"exampleFix":"// before\nObject v = wrapper.get(15);\n// after\nif (pos >= 0 && pos < wrapper.size()) { Object v = wrapper.get(pos); }","handlingStrategy":"validation","validationCode":"if (pos < 0 || pos >= MANIFEST_LIST_SCHEMA.columns().size()) { throw new IllegalArgumentException(\"ordinal out of range for V2 manifest list schema\"); }","typeGuard":"boolean validV2ManifestPos(int pos) { return pos >= 0 && pos < MANIFEST_LIST_SCHEMA.columns().size(); }","tryCatchPattern":"try { return wrapper.get(pos); } catch (UnsupportedOperationException e) { LOG.warn(\"bad ordinal {} for V2 manifest wrapper\", pos); return null; }","preventionTips":["Bound reads with size() (14 columns for V2 manifest files)","Update hardcoded indices when schema gains columns (partitions, key_metadata)","Pair V1 code with V1Metadata and V2 code with V2Metadata"],"tags":["java","schema","ordinal"],"backgroundTag":"index-out-of-range","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"}