Skip to content

Core: TableMetadata.Builder allows adding encryption keys to v1/v2 tables #18632

Open

Description

@kevinjqliu

Apache Iceberg version

main (development)

Query engine

Other

Please describe the bug 🐞

encryption-keys is v3-only, but TableMetadata.Builder.addEncryptionKey doesn't check the format version. REST servers built on CatalogHandlers accept add-encryption-key from any client and write it into v1/v2 metadata.

Proposed fix

Reject in TableMetadata.Builder.addEncryptionKey below v3. This covers Java clients and REST servers, since both go through the builder. removeEncryptionKey and parsing should stay lenient so existing tables can be cleaned up.

Repro (REST fixture)
docker run -d --rm -p 8181:8181 apache/iceberg-rest-fixture
H='Content-Type: application/json'; U=localhost:8181/v1
curl -s -XPOST $U/namespaces -H "$H" -d '{"namespace":["ns"]}'
curl -s -XPOST $U/namespaces/ns/tables -H "$H" -d '{"name":"t","schema":{"type":"struct","fields":[{"id":1,"name":"id","type":"long","required":false}]},"properties":{"format-version":"2"}}'
curl -s -XPOST $U/namespaces/ns/tables/t -H "$H" -d '{"requirements":[],"updates":[{"action":"add-encryption-key","encryption-key":{"key-id":"kek","encrypted-key-metadata":"a2V5"}}]}'
# 200, "format-version": 2 with "encryption-keys"
Existing version checks in TableMetadata.Builder
More context

Java's own writers don't check the version either (manifest list encryption), they rely on encryption.key-id being rejected on v1/v2 at create (#14668).

Other implementations:

Related:

Willingness to contribute

  • I can contribute a fix for this bug independently
  • I would be willing to contribute a fix for this bug with guidance from the Iceberg community
  • I cannot contribute a fix for this bug at this time

Activity

  1. xanderbailey commented on Oct 24, 2026

    @xanderbailey

    To me your analysis for this seems correct, I think we should be more strict about this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions