roryqi commented on code in PR #14326:
URL: https://github.com/apache/gravitino/pull/14326#discussion_r4510950266


##########
core/src/main/java/org/apache/gravitino/policy/PolicyManager.java:
##########
@@ -73,6 +78,54 @@ public PolicyManager(IdGenerator idGenerator, EntityStore 
entityStore) {
     this.objectPolicyResolver = new ObjectPolicyResolver(entityStore);
   }
 
+  /**
+   * Applies a policy to an object through its hidden tag using the entity 
store.
+   *
+   * <p>The hidden tag is created with the policy. This method loads that tag 
and submits an
+   * idempotent object assignment. The relation operation validates the object 
endpoint and owns the
+   * transaction.
+   *
+   * <p>This internal method is not exposed through the policy dispatcher or 
client APIs.
+   *
+   * @param metalake The policy and object's metalake.
+   * @param policyName The policy name.
+   * @param object The metadata object to associate.
+   * @param auditInfo The audit information to preserve on newly created 
relations.
+   * @return The policy's hidden tag ID.
+   * @throws IOException If an entity or relation cannot be persisted.
+   * @throws NoSuchEntityException If the policy, hidden tag or target object 
does not exist.
+   * @throws IllegalArgumentException If the object type does not support tag 
assignments.
+   */
+  public long addPolicyToObject(
+      String metalake, String policyName, MetadataObject object, Audit 
auditInfo)
+      throws IOException {
+    Preconditions.checkNotNull(auditInfo, "Policy binding audit information is 
required");

Review Comment:
   Fixed in `e147f712c9`. Both `PolicyManager.addPolicyToObject` and 
`RelationUpdate.withAuditInfo` now use `checkArgument(auditInfo != null, ...)`. 
The null-audit binding test now expects `IllegalArgumentException`, and a 
relation-update test covers the same contract. Javadoc also records the 
exception type.



##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectTagOperations.java:
##########
@@ -192,6 +194,7 @@ public Response listTagsForMetadataObject(
             Tag[] nonInheritedTags = 
tagDispatcher.listTagsInfoForMetadataObject(metalake, object);

Review Comment:
   Fixed in `e147f712c9`. Both list endpoints now check tag path objects at the 
REST boundary before dispatch. The metadata-tag routes reuse the existing 
parsing helper for this check.
   
   The new parameterized HTTP tests model an existing unassigned hidden tag 
(whose dispatcher result would be empty) and a missing tag. Both requests must 
return 404 with `NoSuchMetadataObjectException`, for both `details=false` and 
`details=true`; the hidden-tag request must not reach the dispatcher. All 112 
focused core/REST tests and format checks passed.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to