{"record":{"id":"b2627eb985002d9e","repo":"apache/iceberg","slug":"this-getclass-getname-doesn-t-implement-fil","errorCode":null,"errorMessage":"${this.getClass().getName()} doesn't implement fileLength","messagePattern":"(.+?) doesn't implement fileLength","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/encryption/NativeEncryptionKeyMetadata.java","lineNumber":33,"sourceCode":" * KIND, either express or implied.  See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\npackage org.apache.iceberg.encryption;\n\nimport java.nio.ByteBuffer;\n\n/** {@link EncryptionKeyMetadata} for use with format-native encryption. */\npublic interface NativeEncryptionKeyMetadata extends EncryptionKeyMetadata {\n  /** Encryption key as a {@link ByteBuffer} */\n  ByteBuffer encryptionKey();\n\n  /** Additional authentication data as a {@link ByteBuffer} */\n  ByteBuffer aadPrefix();\n\n  /** Encrypted file length */\n  default Long fileLength() {\n    throw new UnsupportedOperationException(\n        this.getClass().getName() + \" doesn't implement fileLength\");\n  }\n\n  /**\n   * Copy this key metadata and set the file length.\n   *\n   * @param length length of the encrypted file in bytes\n   * @return a copy of this key metadata (key and AAD) with the file length\n   */\n  default NativeEncryptionKeyMetadata copyWithLength(long length) {\n    throw new UnsupportedOperationException(\n        this.getClass().getName() + \" doesn't implement copyWithLength\");\n  }\n}\n","sourceCodeStart":15,"sourceCodeEnd":48,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/encryption/NativeEncryptionKeyMetadata.java#L15-L48","documentation":"NativeEncryptionKeyMetadata.fileLength is a default method that throws UnsupportedOperationException. Implementations must override it to report the encrypted file length; the default exists so the interface can evolve without breaking existing implementations.","triggerScenarios":"Calling fileLength() on a NativeEncryptionKeyMetadata implementation that did not override the method — typically custom key metadata classes written before the method was added.","commonSituations":"Custom native encryption integrations (e.g. Parquet native encryption) with key metadata classes lacking the newer fileLength override; reading file lengths from third-party key metadata implementations.","solutions":["Override fileLength() in your NativeEncryptionKeyMetadata implementation to return the encrypted file length","Use copyWithLength on implementations that support it to obtain metadata carrying the length","Upgrade or patch the third-party key metadata implementation to one that implements fileLength"],"exampleFix":"// before\nclass MyKeyMetadata implements NativeEncryptionKeyMetadata { /* no fileLength */ }\n// after\nclass MyKeyMetadata implements NativeEncryptionKeyMetadata {\n  @Override public Long fileLength() { return encryptedLength; }\n}","handlingStrategy":"try-catch","validationCode":"try { km.fileLength(); return true; } catch (UnsupportedOperationException e) { return false; }","typeGuard":"boolean hasFileLength(NativeEncryptionKeyMetadata km) {\n  try { return km.fileLength() != null; } catch (UnsupportedOperationException e) { return false; }\n}","tryCatchPattern":"try { length = km.fileLength(); }\ncatch (UnsupportedOperationException e) { length = null; /* length unavailable */ }","preventionTips":["Override fileLength() in all custom NativeEncryptionKeyMetadata implementations","Test native encryption integrations against the current Iceberg interface","Prefer implementations from the Iceberg codebase over hand-rolled ones"],"tags":["encryption","unsupported-operation","native-encryption"],"backgroundTag":"method-not-implemented","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"}