apache/iceberg · error · UnsupportedOperationException
${this.getClass().getName()} doesn't implement copyWithLengt
Error message
${this.getClass().getName()} doesn't implement copyWithLength What it means
NativeEncryptionKeyMetadata.copyWithLength is a default method that throws UnsupportedOperationException. It must be overridden to return a copy of the key metadata carrying the given encrypted file length; the default signals the implementation does not support length tracking.
Source
Thrown at core/src/main/java/org/apache/iceberg/encryption/NativeEncryptionKeyMetadata.java:44
ByteBuffer encryptionKey();
/** Additional authentication data as a {@link ByteBuffer} */
ByteBuffer aadPrefix();
/** Encrypted file length */
default Long fileLength() {
throw new UnsupportedOperationException(
this.getClass().getName() + " doesn't implement fileLength");
}
/**
* Copy this key metadata and set the file length.
*
* @param length length of the encrypted file in bytes
* @return a copy of this key metadata (key and AAD) with the file length
*/
default NativeEncryptionKeyMetadata copyWithLength(long length) {
throw new UnsupportedOperationException(
this.getClass().getName() + " doesn't implement copyWithLength");
}
}
View on GitHub (pinned to 86d9c8fc54)
Solutions
- Override copyWithLength(long) in your implementation to return a copy with the length set
- Use a key metadata implementation that supports length copying
- Update the library providing the key metadata class to a version that implements it
Example fix
// before
class MyKeyMetadata implements NativeEncryptionKeyMetadata { /* no copyWithLength */ }
// after
class MyKeyMetadata implements NativeEncryptionKeyMetadata {
@Override public NativeEncryptionKeyMetadata copyWithLength(long length) {
return new MyKeyMetadata(kekId(), keyId(), aadPrefix(), length);
}
} Defensive patterns
Strategy: try-catch
Validate before calling
try { km.copyWithLength(0L); return true; } catch (UnsupportedOperationException e) { return false; } Try / catch
try { withLength = km.copyWithLength(length); }
catch (UnsupportedOperationException e) { withLength = null; /* impl lacks length support */ } Prevention
- Override copyWithLength in every NativeEncryptionKeyMetadata implementation
- Keep custom key metadata classes in sync with interface additions
- Add integration tests that call copyWithLength during file writing
When it happens
Trigger: Calling copyWithLength(length) on a NativeEncryptionKeyMetadata implementation that did not override it, typically when a writer needs to attach the final encrypted file size to key metadata.
Common situations: Custom or older native encryption key metadata implementations predating copyWithLength; third-party integration code that never implemented the length-copy contract.
Related errors
- ${this.getClass().getName()} doesn't implement fileLength
- Key generation is not supported in this KmsClient
- Key generation is not supported in this KmsClient
- %s doesn't implement copyWithStats
- %s doesn't implement validateFilesExist
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/aa2e3bef72173a6e.
Report an issue: GitHub.