{"record":{"id":"246d313c2a27c75d","repo":"apache/iceberg","slug":"avro-does-not-support-aad-prefix","errorCode":null,"errorMessage":"Avro does not support AAD prefix","messagePattern":"Avro does not support AAD prefix","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/avro/AvroFormatModel.java","lineNumber":156,"sourceCode":"    public ModelWriteBuilder<D, S> metricsConfig(MetricsConfig metricsConfig) {\n      internal.metricsConfig(metricsConfig);\n      return this;\n    }\n\n    @Override\n    public ModelWriteBuilder<D, S> overwrite() {\n      internal.overwrite();\n      return this;\n    }\n\n    @Override\n    public ModelWriteBuilder<D, S> withFileEncryptionKey(ByteBuffer encryptionKey) {\n      throw new UnsupportedOperationException(\"Avro does not support file encryption keys\");\n    }\n\n    @Override\n    public ModelWriteBuilder<D, S> withAADPrefix(ByteBuffer aadPrefix) {\n      throw new UnsupportedOperationException(\"Avro does not support AAD prefix\");\n    }\n\n    @Override\n    public FileAppender<D> build() throws IOException {\n      switch (content) {\n        case DATA:\n          internal.createContextFunc(Avro.WriteBuilder.Context::dataContext);\n          internal.createWriterFunc(\n              avroSchema -> writerFunction.write(schema, avroSchema, engineSchema));\n          break;\n        case EQUALITY_DELETES:\n          internal.createContextFunc(Avro.WriteBuilder.Context::deleteContext);\n          internal.createWriterFunc(\n              avroSchema -> writerFunction.write(schema, avroSchema, engineSchema));\n          break;\n        case POSITION_DELETES:\n          Preconditions.checkState(\n              schema == null,","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/avro/AvroFormatModel.java#L138-L174","documentation":"The Avro format model's ModelWriteBuilder.withAADPrefix is unsupported: Avro files in Iceberg do not support additional authenticated data (AAD) prefixes used by Parquet modular encryption. Calling this builder method always throws UnsupportedOperationException.","triggerScenarios":"Calling withAADPrefix(bytes) on a write builder obtained from the Avro FormatModel, typically when encryption settings are applied uniformly regardless of the underlying file format.","commonSituations":"Shared write paths applying Parquet-style encryption parameters to all formats; table write properties enabling AAD prefixes while the writer is Avro; test harnesses exercising encryption flags across format models.","solutions":["Remove the withAADPrefix call when targeting Avro files","Switch the write path to Parquet if AAD-prefix encryption is required","Branch on file format before applying encryption-related builder options"],"exampleFix":"// before\nwriteBuilder(io, location)\n    .withAADPrefix(aadPrefix)\n    .build(); // avro: throws\n\n// after\nif (\"parquet\".equals(format)) {\n  writeBuilder(io, location).withAADPrefix(aadPrefix).build();\n} else {\n  writeBuilder(io, location).build();\n}","handlingStrategy":"validation","validationCode":"if (\"avro\".equals(format) && aadPrefix != null) { throw new IllegalArgumentException(\"AAD prefix requires Parquet\"); }","typeGuard":"boolean supportsAadPrefix(FormatModel m) { return !(m instanceof AvroFormatModel); }","tryCatchPattern":"try { builder.withAADPrefix(prefix); } catch (UnsupportedOperationException e) { /* strip encryption options for avro */ }","preventionTips":["Apply AAD-prefix options only on the Parquet write path","Split shared write config by format capability","Cover format-specific builder calls in tests"],"tags":["avro","encryption","aad-prefix","unsupported"],"backgroundTag":"operation-not-supported","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"}