apache/iceberg · error · UnsupportedOperationException
${this.getClass().getName()} doesn't implement fileLength
Error message
${this.getClass().getName()} doesn't implement fileLength What it means
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.
Source
Thrown at core/src/main/java/org/apache/iceberg/encryption/NativeEncryptionKeyMetadata.java:33
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.iceberg.encryption;
import java.nio.ByteBuffer;
/** {@link EncryptionKeyMetadata} for use with format-native encryption. */
public interface NativeEncryptionKeyMetadata extends EncryptionKeyMetadata {
/** Encryption key as a {@link ByteBuffer} */
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 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
Example fix
// before
class MyKeyMetadata implements NativeEncryptionKeyMetadata { /* no fileLength */ }
// after
class MyKeyMetadata implements NativeEncryptionKeyMetadata {
@Override public Long fileLength() { return encryptedLength; }
} Defensive patterns
Strategy: try-catch
Validate before calling
try { km.fileLength(); return true; } catch (UnsupportedOperationException e) { return false; } Type guard
boolean hasFileLength(NativeEncryptionKeyMetadata km) {
try { return km.fileLength() != null; } catch (UnsupportedOperationException e) { return false; }
} Try / catch
try { length = km.fileLength(); }
catch (UnsupportedOperationException e) { length = null; /* length unavailable */ } Prevention
- 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
When it happens
Trigger: Calling fileLength() on a NativeEncryptionKeyMetadata implementation that did not override the method — typically custom key metadata classes written before the method was added.
Common situations: 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.
Related errors
- ${this.getClass().getName()} doesn't implement copyWithLengt
- 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/b2627eb985002d9e.
Report an issue: GitHub.