You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@polaris.apache.org by "adutra (via GitHub)" <gi...@apache.org> on 2026/09/03 19:34:14 UTC
Re: [PR] [1/2] Enforce immutable Iceberg encryption key IDs [polaris]
adutra commented on code in PR #5185:
URL: https://github.com/apache/polaris/pull/5185#discussion_r3927985919
##########
runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/TableMetadataTransitionValidator.java:
##########
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.polaris.service.catalog.iceberg;
+
+import java.util.Map;
+import java.util.Objects;
+import org.apache.iceberg.TableMetadata;
+import org.apache.iceberg.TableProperties;
+import org.apache.iceberg.encryption.EncryptionUtil;
+import org.apache.iceberg.exceptions.ValidationException;
+
+final class TableMetadataTransitionValidator {
+ static final String KEY_ID_PINNED_PROPERTY = "polaris.encryption.key-id-pinned";
+ static final String KEY_ID_PROPERTY = "polaris.encryption.key-id";
+
+ private TableMetadataTransitionValidator() {}
+
+ static void validate(Map<String, String> trustedProperties, TableMetadata candidate) {
+ if (!trustedProperties.containsKey(KEY_ID_PINNED_PROPERTY)) {
+ // Legacy tables remain outside the invariant until an explicit trusted attestation
+ // mechanism enrolls them. Ordinary legacy operations must not establish trust from
+ // metadata that may have been read from unprotected storage.
+ return;
+ }
+ if (!keyIdMatches(trustedProperties, candidate)) {
+ throw new ValidationException(
+ "Cannot add, change, or remove encryption key ID after table creation");
+ }
+ }
+
+ /**
+ * Verifies metadata loaded from storage against the trusted catalog pin before it is used.
+ *
+ * <p>Legacy entities without a pin remain outside the invariant. For pinned entities, a missing
+ * key ID is a value in its own right and must continue to be missing.
+ */
+ static void validateLoaded(
Review Comment:
The two methods are very similar and differ only by the error message. Shouldn't we instead introduce a single method that returns a boolean, and let callers deal with the error message?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org