You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "roryqi (via GitHub)" <gi...@apache.org> on 2026/08/06 06:34:21 UTC
[PR] [#12379] feat(core): Support assignment values in REST and Java client [gravitino]
roryqi opened a new pull request, #12384:
URL: https://github.com/apache/gravitino/pull/12384
### What changes were proposed in this pull request?
Add REST and Java client support for tag assignment values:
- Support creating tags with value constraints.
- Support associating and removing tag assignment values.
- Support retrieving assignment values from associated tags.
- Support listing associated metadata objects by assignment value.
- Use the v2 REST media type for valued tag association requests while retaining v1 behavior for legacy requests.
### Why are the changes needed?
The tag assignment value APIs added in the API and core layers need corresponding REST endpoints and Java client implementations.
Fix: #12379
### Does this PR introduce _any_ user-facing change?
Yes. Java client users can create tags with value constraints, associate values with tags, retrieve assigned values, and filter associated objects by value.
### How was this patch tested?
- Added REST unit tests for version handling, authorization, tag creation, association, removal, and value filtering.
- Added Java client unit tests for constraints, assignments, valued requests, and value filtering.
- Added and passed `TagIT.testAssignmentValues`.
- Passed the focused server and Java client regression tests.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12379] feat(core): Support assignment values in REST and Java client [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on PR #12384:
URL: https://github.com/apache/gravitino/pull/12384#issuecomment-5253405046
@mchades Could u help me review again?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12379] feat(core): Support assignment values in REST and Java client [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12384:
URL: https://github.com/apache/gravitino/pull/12384#discussion_r3726911301
##########
common/src/main/java/org/apache/gravitino/dto/requests/TagValuesAssociateRequest.java:
##########
@@ -82,32 +81,31 @@ public TagValue[] tagValuesToRemove() {
@Override
public void validate() throws IllegalArgumentException {
Preconditions.checkArgument(
- tagsToAdd != null || tagsToRemove != null,
- "tagsToAdd and tagsToRemove cannot both be null");
+ tagsToAdd != null && tagsToRemove != null,
+ "tagsToAdd and tagsToRemove must be arrays; use empty arrays when no tags are provided");
Review Comment:
Updated. The request now allows `tagsToAdd` / `tagsToRemove` to be null and normalizes null to an empty array internally. If both sides are null/empty after normalization, validation still rejects it as an empty association request.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12379] feat(core): Support assignment values in REST and Java client [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12384:
URL: https://github.com/apache/gravitino/pull/12384#discussion_r3758805609
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectTagOperations.java:
##########
@@ -270,26 +299,65 @@ public Response associateTagsForObject(
httpRequest,
() -> {
request.validate();
- MetadataObject object =
- MetadataObjects.parse(
- fullName, MetadataObject.Type.valueOf(type.toUpperCase(Locale.ROOT)));
+ MetadataObject object = parseMetadataObject(type, fullName);
String[] tagNames =
tagDispatcher.associateTagsForMetadataObject(
metalake, object, request.getTagsToAdd(), request.getTagsToRemove());
tagNames = tagNames == null ? new String[0] : tagNames;
- LOG.info(
- "Associated tags: {} for object type: {}, full name: {} under metalake: {}",
- Arrays.toString(tagNames),
- type,
- fullName,
- metalake);
+ logAssociatedTags(type, fullName, metalake, tagNames);
return Utils.ok(new NameListResponse(tagNames));
});
} catch (Exception e) {
return ExceptionHandlers.handleTagException(OperationType.ASSOCIATE, "", fullName, e);
}
}
+ private Response associateTagValuesForObjectInternal(
+ String metalake, String type, String fullName, TagValuesAssociateRequest request) {
+ LOG.info(
+ "Received associate tag values request for object type: {}, full name: {} under metalake: {}",
+ type,
+ fullName,
+ metalake);
+ try {
+ return Utils.doAs(
+ httpRequest,
+ () -> {
+ request.validate();
+ MetadataObject object = parseMetadataObject(type, fullName);
+ String[] tagNames =
+ tagDispatcher.associateTagValuesForMetadataObject(
Review Comment:
It's ok to keep consistent with v1 behaviour.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12379] feat(core): Support assignment values in REST and Java client [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12384:
URL: https://github.com/apache/gravitino/pull/12384#discussion_r3758826950
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectTagOperations.java:
##########
@@ -260,6 +257,35 @@ public Response associateTagsForObject(
@PathParam("fullName") @AuthorizationFullName String fullName,
@AuthorizationRequest(type = AuthorizationRequest.RequestType.ASSOCIATE_TAG)
TagsAssociateRequest request) {
+ return associateTagsForObjectInternal(metalake, type, fullName, request);
+ }
+
+ /**
+ * Associates tag values with a metadata object using the v2 request representation.
+ *
+ * @param metalake The metalake name.
+ * @param type The metadata object type.
+ * @param fullName The metadata object full name.
+ * @param request The tag values association request.
+ * @return The response containing associated tag names.
+ */
+ @POST
+ @Produces("application/vnd.gravitino.v2+json")
+ @Timed(name = "associate-object-tags." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "associate-object-tags", absolute = true)
+ @AuthorizationExpression(expression = CAN_ACCESS_METADATA_AND_TAG)
+ public Response associateTagValuesForObject(
+ @PathParam("metalake") @AuthorizationMetadata(type = Entity.EntityType.METALAKE)
+ String metalake,
+ @PathParam("type") @AuthorizationObjectType String type,
+ @PathParam("fullName") @AuthorizationFullName String fullName,
+ @AuthorizationRequest(type = AuthorizationRequest.RequestType.ASSOCIATE_TAG)
+ TagValuesAssociateRequest request) {
+ return associateTagsForObjectInternal(metalake, type, fullName, request);
Review Comment:
Thanks for the detailed callout. I agree stricter Accept negotiation and applying the negotiated media type to pre-resource JSON mapping would be more complete, but that changes the generic versioning/filter and global JSON exception mapper behavior beyond tag assignment values. I would prefer to keep this PR scoped to the tag values API surface and leave the broader negotiation/error-media behavior to a separate follow-up if we want to tighten it consistently across endpoints.
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectTagOperations.java:
##########
@@ -270,26 +299,65 @@ public Response associateTagsForObject(
httpRequest,
() -> {
request.validate();
- MetadataObject object =
- MetadataObjects.parse(
- fullName, MetadataObject.Type.valueOf(type.toUpperCase(Locale.ROOT)));
+ MetadataObject object = parseMetadataObject(type, fullName);
String[] tagNames =
tagDispatcher.associateTagsForMetadataObject(
metalake, object, request.getTagsToAdd(), request.getTagsToRemove());
tagNames = tagNames == null ? new String[0] : tagNames;
- LOG.info(
- "Associated tags: {} for object type: {}, full name: {} under metalake: {}",
- Arrays.toString(tagNames),
- type,
- fullName,
- metalake);
+ logAssociatedTags(type, fullName, metalake, tagNames);
return Utils.ok(new NameListResponse(tagNames));
});
} catch (Exception e) {
return ExceptionHandlers.handleTagException(OperationType.ASSOCIATE, "", fullName, e);
}
}
+ private Response associateTagValuesForObjectInternal(
+ String metalake, String type, String fullName, TagValuesAssociateRequest request) {
+ LOG.info(
+ "Received associate tag values request for object type: {}, full name: {} under metalake: {}",
+ type,
+ fullName,
+ metalake);
+ try {
+ return Utils.doAs(
+ httpRequest,
+ () -> {
+ request.validate();
+ MetadataObject object = parseMetadataObject(type, fullName);
+ String[] tagNames =
+ tagDispatcher.associateTagValuesForMetadataObject(
Review Comment:
Thanks. For this PR I would prefer to keep the association semantics aligned with the existing name-only API: missing tag names in batch add/remove are ignored to keep the operation idempotent. V2 extends the assignment representation with values, but I do not think we need to make missing pair names strict in this change. If we decide the V2 contract should be stricter here, I think it is better handled as a focused follow-up with the API contract and tests updated together.
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectTagOperations.java:
##########
@@ -270,26 +299,65 @@ public Response associateTagsForObject(
httpRequest,
() -> {
request.validate();
- MetadataObject object =
- MetadataObjects.parse(
- fullName, MetadataObject.Type.valueOf(type.toUpperCase(Locale.ROOT)));
+ MetadataObject object = parseMetadataObject(type, fullName);
String[] tagNames =
tagDispatcher.associateTagsForMetadataObject(
metalake, object, request.getTagsToAdd(), request.getTagsToRemove());
tagNames = tagNames == null ? new String[0] : tagNames;
- LOG.info(
- "Associated tags: {} for object type: {}, full name: {} under metalake: {}",
- Arrays.toString(tagNames),
- type,
- fullName,
- metalake);
+ logAssociatedTags(type, fullName, metalake, tagNames);
return Utils.ok(new NameListResponse(tagNames));
});
} catch (Exception e) {
return ExceptionHandlers.handleTagException(OperationType.ASSOCIATE, "", fullName, e);
}
}
+ private Response associateTagValuesForObjectInternal(
+ String metalake, String type, String fullName, TagValuesAssociateRequest request) {
+ LOG.info(
+ "Received associate tag values request for object type: {}, full name: {} under metalake: {}",
+ type,
+ fullName,
+ metalake);
+ try {
+ return Utils.doAs(
+ httpRequest,
+ () -> {
+ request.validate();
+ MetadataObject object = parseMetadataObject(type, fullName);
+ String[] tagNames =
+ tagDispatcher.associateTagValuesForMetadataObject(
+ metalake, object, request.tagValuesToAdd(), request.tagValuesToRemove());
Review Comment:
Good point that 409 can be argued for this state conflict. I am leaning to keep the current mapping in this PR because this path is still validation of an invalid assignment transition and is currently handled with the same 400 IllegalArgumentException flow as the other tag value constraint violations. I would rather avoid introducing a special conflict mapping for only this case unless we decide to revise the tag-assignment error contract more broadly.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12379] feat(core): Support assignment values in REST and Java client [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi merged PR #12384:
URL: https://github.com/apache/gravitino/pull/12384
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12379] feat(core): Support assignment values in REST and Java client [gravitino]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #12384:
URL: https://github.com/apache/gravitino/pull/12384#issuecomment-5239671769
<!-- coverage-report -->
### Code Coverage Report
|Overall Project|68.4% **`+0.4%`**|:green_circle:|
|:-|:-|:-:|
|Files changed|87.94%|:green_circle:|
<br>
|Module|Coverage||
|:-|:-|:-:|
|aliyun|1.72%|:red_circle:|
|api|49.37%|:green_circle:|
|authorization-common|85.96%|:green_circle:|
|aws|42.04%|:green_circle:|
|azure|2.47%|:red_circle:|
|catalog-common|9.92%|:red_circle:|
|catalog-fileset|79.74%|:green_circle:|
|catalog-glue|68.95%|:green_circle:|
|catalog-hive|79.4%|:green_circle:|
|catalog-jdbc-common|45.7%|:green_circle:|
|catalog-jdbc-doris|81.8%|:green_circle:|
|catalog-jdbc-mysql|79.33%|:green_circle:|
|catalog-jdbc-postgresql|83.39%|:green_circle:|
|catalog-jdbc-starrocks|79.16%|:green_circle:|
|catalog-kafka|77.01%|:green_circle:|
|catalog-lakehouse-generic|59.18%|:green_circle:|
|catalog-lakehouse-hudi|79.1%|:green_circle:|
|catalog-lakehouse-iceberg|85.86%|:green_circle:|
|catalog-lakehouse-paimon|84.23%|:green_circle:|
|catalog-model|77.72%|:green_circle:|
|cli|44.48%|:green_circle:|
|client-java|78.45% **`+4.25%`**|:green_circle:|
|common|52.54% **`+0.2%`**|:green_circle:|
|core|83.29% **`+0.02%`**|:green_circle:|
|filesystem-hadoop3|77.28%|:green_circle:|
|flink|0.0%|:red_circle:|
|flink-common|48.68%|:green_circle:|
|flink-runtime|0.0%|:red_circle:|
|gcp|14.12%|:red_circle:|
|hadoop-auth|68.0%|:green_circle:|
|hadoop-common|12.7%|:red_circle:|
|hive-metastore-common|53.4%|:green_circle:|
|iceberg-aliyun-bundle|0.0%|:red_circle:|
|iceberg-common|64.75%|:green_circle:|
|iceberg-rest-server|75.03%|:green_circle:|
|idp-basic|86.02%|:green_circle:|
|integration-test-common|0.0%|:red_circle:|
|jobs|62.92%|:green_circle:|
|lance-common|31.75%|:red_circle:|
|lance-rest-server|63.47%|:green_circle:|
|lineage|53.02%|:green_circle:|
|optimizer|83.24%|:green_circle:|
|optimizer-api|21.95%|:red_circle:|
|server|86.81% **`+0.75%`**|:green_circle:|
|server-common|76.45%|:green_circle:|
|spark|28.57%|:red_circle:|
|spark-common|45.89%|:green_circle:|
|tencent|69.84%|:green_circle:|
|trino-connector|40.29%|:green_circle:|
<details>
<summary>Files</summary>
|Module|File|Coverage||
|:-|:-|:-|:-:|
|client-java|[BaseSchemaCatalog.java](https://github.com/qqqttt123/gravitino/blob/aab7e2573eac7ac569a026065af09862ae5df28d/clients/client-java/src/main/java/org/apache/gravitino/client/BaseSchemaCatalog.java)|100.0%|:green_circle:|
||[MetadataObjectTagOperations.java](https://github.com/qqqttt123/gravitino/blob/aab7e2573eac7ac569a026065af09862ae5df28d/clients/client-java/src/main/java/org/apache/gravitino/client/MetadataObjectTagOperations.java)|100.0%|:green_circle:|
||[RelationalTable.java](https://github.com/qqqttt123/gravitino/blob/aab7e2573eac7ac569a026065af09862ae5df28d/clients/client-java/src/main/java/org/apache/gravitino/client/RelationalTable.java)|95.1%|:green_circle:|
||[GravitinoMetalake.java](https://github.com/qqqttt123/gravitino/blob/aab7e2573eac7ac569a026065af09862ae5df28d/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoMetalake.java)|92.37%|:green_circle:|
||[GenericFileset.java](https://github.com/qqqttt123/gravitino/blob/aab7e2573eac7ac569a026065af09862ae5df28d/clients/client-java/src/main/java/org/apache/gravitino/client/GenericFileset.java)|78.57%|:green_circle:|
||[GenericTag.java](https://github.com/qqqttt123/gravitino/blob/aab7e2573eac7ac569a026065af09862ae5df28d/clients/client-java/src/main/java/org/apache/gravitino/client/GenericTag.java)|78.05%|:green_circle:|
||[GenericTopic.java](https://github.com/qqqttt123/gravitino/blob/aab7e2573eac7ac569a026065af09862ae5df28d/clients/client-java/src/main/java/org/apache/gravitino/client/GenericTopic.java)|75.68%|:green_circle:|
||[GenericSchema.java](https://github.com/qqqttt123/gravitino/blob/aab7e2573eac7ac569a026065af09862ae5df28d/clients/client-java/src/main/java/org/apache/gravitino/client/GenericSchema.java)|75.0%|:green_circle:|
||[GenericColumn.java](https://github.com/qqqttt123/gravitino/blob/aab7e2573eac7ac569a026065af09862ae5df28d/clients/client-java/src/main/java/org/apache/gravitino/client/GenericColumn.java)|73.08%|:green_circle:|
||[GravitinoClient.java](https://github.com/qqqttt123/gravitino/blob/aab7e2573eac7ac569a026065af09862ae5df28d/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoClient.java)|71.95%|:green_circle:|
||[GenericFunction.java](https://github.com/qqqttt123/gravitino/blob/aab7e2573eac7ac569a026065af09862ae5df28d/clients/client-java/src/main/java/org/apache/gravitino/client/GenericFunction.java)|68.97%|:green_circle:|
||[GenericView.java](https://github.com/qqqttt123/gravitino/blob/aab7e2573eac7ac569a026065af09862ae5df28d/clients/client-java/src/main/java/org/apache/gravitino/client/GenericView.java)|66.67%|:green_circle:|
||[GenericModel.java](https://github.com/qqqttt123/gravitino/blob/aab7e2573eac7ac569a026065af09862ae5df28d/clients/client-java/src/main/java/org/apache/gravitino/client/GenericModel.java)|41.18%|:red_circle:|
|common|[TagValuesAssociateRequest.java](https://github.com/qqqttt123/gravitino/blob/aab7e2573eac7ac569a026065af09862ae5df28d/common/src/main/java/org/apache/gravitino/dto/requests/TagValuesAssociateRequest.java)|79.17%|:green_circle:|
|core|[TagManager.java](https://github.com/qqqttt123/gravitino/blob/aab7e2573eac7ac569a026065af09862ae5df28d/core/src/main/java/org/apache/gravitino/tag/TagManager.java)|85.96%|:green_circle:|
|server|[ApiVersion.java](https://github.com/qqqttt123/gravitino/blob/aab7e2573eac7ac569a026065af09862ae5df28d/server/src/main/java/org/apache/gravitino/server/web/ApiVersion.java)|100.0%|:green_circle:|
||[TagOperations.java](https://github.com/qqqttt123/gravitino/blob/aab7e2573eac7ac569a026065af09862ae5df28d/server/src/main/java/org/apache/gravitino/server/web/rest/TagOperations.java)|97.85%|:green_circle:|
||[VersioningFilter.java](https://github.com/qqqttt123/gravitino/blob/aab7e2573eac7ac569a026065af09862ae5df28d/server/src/main/java/org/apache/gravitino/server/web/VersioningFilter.java)|97.78%|:green_circle:|
||[AssociateTagAuthorizationExecutor.java](https://github.com/qqqttt123/gravitino/blob/aab7e2573eac7ac569a026065af09862ae5df28d/server/src/main/java/org/apache/gravitino/server/web/filter/authorization/AssociateTagAuthorizationExecutor.java)|91.43%|:green_circle:|
||[MetadataObjectTagOperations.java](https://github.com/qqqttt123/gravitino/blob/aab7e2573eac7ac569a026065af09862ae5df28d/server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectTagOperations.java)|89.47%|:green_circle:|
</details>
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12379] feat(core): Support assignment values in REST and Java client [gravitino]
Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #12384:
URL: https://github.com/apache/gravitino/pull/12384#discussion_r3758898030
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectTagOperations.java:
##########
@@ -260,6 +257,35 @@ public Response associateTagsForObject(
@PathParam("fullName") @AuthorizationFullName String fullName,
@AuthorizationRequest(type = AuthorizationRequest.RequestType.ASSOCIATE_TAG)
TagsAssociateRequest request) {
+ return associateTagsForObjectInternal(metalake, type, fullName, request);
+ }
+
+ /**
+ * Associates tag values with a metadata object using the v2 request representation.
+ *
+ * @param metalake The metalake name.
+ * @param type The metadata object type.
+ * @param fullName The metadata object full name.
+ * @param request The tag values association request.
+ * @return The response containing associated tag names.
+ */
+ @POST
+ @Produces("application/vnd.gravitino.v2+json")
+ @Timed(name = "associate-object-tags." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "associate-object-tags", absolute = true)
+ @AuthorizationExpression(expression = CAN_ACCESS_METADATA_AND_TAG)
+ public Response associateTagValuesForObject(
+ @PathParam("metalake") @AuthorizationMetadata(type = Entity.EntityType.METALAKE)
+ String metalake,
+ @PathParam("type") @AuthorizationObjectType String type,
+ @PathParam("fullName") @AuthorizationFullName String fullName,
+ @AuthorizationRequest(type = AuthorizationRequest.RequestType.ASSOCIATE_TAG)
+ TagValuesAssociateRequest request) {
+ return associateTagsForObjectInternal(metalake, type, fullName, request);
Review Comment:
Thanks — I agree the generic `Accept` parser can be handled separately. The malformed-body case is still a contract mismatch introduced on this endpoint, though: `tags.yaml` says the 400 response covers a malformed body and advertises `application/vnd.gravitino.v2+json`, while `JsonParseExceptionMapper` runs before `withMediaType` and returns `application/json`. Could we either make that pre-resource 400 use the V2 media type, or update the OpenAPI response to document the actual media type and remove malformed-body from this V2 promise? Then the broader negotiation behavior can remain a follow-up.
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectTagOperations.java:
##########
@@ -270,26 +299,65 @@ public Response associateTagsForObject(
httpRequest,
() -> {
request.validate();
- MetadataObject object =
- MetadataObjects.parse(
- fullName, MetadataObject.Type.valueOf(type.toUpperCase(Locale.ROOT)));
+ MetadataObject object = parseMetadataObject(type, fullName);
String[] tagNames =
tagDispatcher.associateTagsForMetadataObject(
metalake, object, request.getTagsToAdd(), request.getTagsToRemove());
tagNames = tagNames == null ? new String[0] : tagNames;
- LOG.info(
- "Associated tags: {} for object type: {}, full name: {} under metalake: {}",
- Arrays.toString(tagNames),
- type,
- fullName,
- metalake);
+ logAssociatedTags(type, fullName, metalake, tagNames);
return Utils.ok(new NameListResponse(tagNames));
});
} catch (Exception e) {
return ExceptionHandlers.handleTagException(OperationType.ASSOCIATE, "", fullName, e);
}
}
+ private Response associateTagValuesForObjectInternal(
+ String metalake, String type, String fullName, TagValuesAssociateRequest request) {
+ LOG.info(
+ "Received associate tag values request for object type: {}, full name: {} under metalake: {}",
+ type,
+ fullName,
+ metalake);
+ try {
+ return Utils.doAs(
+ httpRequest,
+ () -> {
+ request.validate();
+ MetadataObject object = parseMetadataObject(type, fullName);
+ String[] tagNames =
+ tagDispatcher.associateTagValuesForMetadataObject(
Review Comment:
Retaining V1 behavior for the V1 endpoint is compatible with V2 returning 404. The checked-in design already states that a tag referenced by either V2 array but not found returns `404 Not Found` (`design-docs/tag-assignment-values.md`, line 816), while the current `TagMetaService` path silently `continue`s and returns 200. This is therefore a runtime/contract mismatch, not an undecided stricter option. Please implement the documented 404 behavior, or, if the semantics are intentionally changing, update the design, OpenAPI, and tests in this PR; otherwise client typos appear to have succeeded.
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectTagOperations.java:
##########
@@ -270,26 +299,65 @@ public Response associateTagsForObject(
httpRequest,
() -> {
request.validate();
- MetadataObject object =
- MetadataObjects.parse(
- fullName, MetadataObject.Type.valueOf(type.toUpperCase(Locale.ROOT)));
+ MetadataObject object = parseMetadataObject(type, fullName);
String[] tagNames =
tagDispatcher.associateTagsForMetadataObject(
metalake, object, request.getTagsToAdd(), request.getTagsToRemove());
tagNames = tagNames == null ? new String[0] : tagNames;
- LOG.info(
- "Associated tags: {} for object type: {}, full name: {} under metalake: {}",
- Arrays.toString(tagNames),
- type,
- fullName,
- metalake);
+ logAssociatedTags(type, fullName, metalake, tagNames);
return Utils.ok(new NameListResponse(tagNames));
});
} catch (Exception e) {
return ExceptionHandlers.handleTagException(OperationType.ASSOCIATE, "", fullName, e);
}
}
+ private Response associateTagValuesForObjectInternal(
+ String metalake, String type, String fullName, TagValuesAssociateRequest request) {
+ LOG.info(
+ "Received associate tag values request for object type: {}, full name: {} under metalake: {}",
+ type,
+ fullName,
+ metalake);
+ try {
+ return Utils.doAs(
+ httpRequest,
+ () -> {
+ request.validate();
+ MetadataObject object = parseMetadataObject(type, fullName);
+ String[] tagNames =
+ tagDispatcher.associateTagValuesForMetadataObject(
+ metalake, object, request.tagValuesToAdd(), request.tagValuesToRemove());
Review Comment:
The checked-in contract already distinguishes request validation from this active-state conflict: malformed or invalid values return 400, while adding a valueless pair with remaining non-null assignments returns `409 Conflict` (`design-docs/tag-assignment-values.md`, lines 730–733 and 814). This request is pair-valid and fails only because of current assignment state; routing it through `IllegalArgumentException` collapses that documented distinction. Please return 409 and add a REST regression, or revise the design, OpenAPI, and tests in this PR if the product semantics are intentionally changing.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12379] feat(core): Support assignment values in REST and Java client [gravitino]
Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #12384:
URL: https://github.com/apache/gravitino/pull/12384#discussion_r3757764286
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectTagOperations.java:
##########
@@ -270,12 +296,24 @@ public Response associateTagsForObject(
httpRequest,
() -> {
request.validate();
+ TagValue[] tagsToAdd;
+ TagValue[] tagsToRemove;
+ if (request instanceof TagsAssociateRequest) {
+ TagsAssociateRequest tagsAssociateRequest = (TagsAssociateRequest) request;
+ tagsToAdd = toNoValue(tagsAssociateRequest.getTagsToAdd());
+ tagsToRemove = toNoValue(tagsAssociateRequest.getTagsToRemove());
+ } else {
+ TagValuesAssociateRequest tagValuesAssociateRequest =
+ (TagValuesAssociateRequest) request;
+ tagsToAdd = tagValuesAssociateRequest.tagValuesToAdd();
+ tagsToRemove = tagValuesAssociateRequest.tagValuesToRemove();
+ }
MetadataObject object =
MetadataObjects.parse(
fullName, MetadataObject.Type.valueOf(type.toUpperCase(Locale.ROOT)));
String[] tagNames =
- tagDispatcher.associateTagsForMetadataObject(
- metalake, object, request.getTagsToAdd(), request.getTagsToRemove());
+ tagDispatcher.associateTagValuesForMetadataObject(
Review Comment:
**[P1] V1 REST still bypasses the new `TAG_NAMES` path**
The core split is not reached from the V1 endpoint. `associateTagsForObjectInternal` converts a `TagsAssociateRequest` into `TagValue.noValue(...)` and then unconditionally invokes `associateTagValuesForMetadataObject`, so V1 REST and Java-client calls still select `TAG_VALUES`. As a result, repeating a V1 add is now an idempotent 200 instead of the legacy 409, and `tagsToRemove: ["domain"]` only attempts to delete `(domain, no-value)` rather than all active valued rows. This also contradicts the existing `TagIT` assertion that a repeated V1 add throws `TagAlreadyAssociatedException`. Please invoke the string overload for V1, reserve the valued overload for V2, and add a V2-valued-assignment to V1 name-removal regression.
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectTagOperations.java:
##########
@@ -260,6 +257,35 @@ public Response associateTagsForObject(
@PathParam("fullName") @AuthorizationFullName String fullName,
@AuthorizationRequest(type = AuthorizationRequest.RequestType.ASSOCIATE_TAG)
TagsAssociateRequest request) {
+ return associateTagsForObjectInternal(metalake, type, fullName, request);
+ }
+
+ /**
+ * Associates tag values with a metadata object using the v2 request representation.
+ *
+ * @param metalake The metalake name.
+ * @param type The metadata object type.
+ * @param fullName The metadata object full name.
+ * @param request The tag values association request.
+ * @return The response containing associated tag names.
+ */
+ @POST
+ @Produces("application/vnd.gravitino.v2+json")
+ @Timed(name = "associate-object-tags." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "associate-object-tags", absolute = true)
+ @AuthorizationExpression(expression = CAN_ACCESS_METADATA_AND_TAG)
+ public Response associateTagValuesForObject(
+ @PathParam("metalake") @AuthorizationMetadata(type = Entity.EntityType.METALAKE)
+ String metalake,
+ @PathParam("type") @AuthorizationObjectType String type,
+ @PathParam("fullName") @AuthorizationFullName String fullName,
+ @AuthorizationRequest(type = AuthorizationRequest.RequestType.ASSOCIATE_TAG)
+ TagValuesAssociateRequest request) {
+ return associateTagsForObjectInternal(metalake, type, fullName, request);
Review Comment:
**[P2] Preserve wildcard `Accept` semantics and V2 media on error paths**
The versioned `Content-Type` disambiguates the request body only when clients also send a versioned `Accept`. With `Content-Type: application/vnd.gravitino.v2+json` and an omitted `Accept` or `Accept: */*`, `VersioningFilter` sees no vendor token and replaces `Accept` with V1; no resource method then satisfies both V2 `@Consumes` and the injected V1 response type, so a wildcard request receives 406. The new success test covers only callers that explicitly send both V2 headers. In addition, validation, not-found, and conflict branches still return explicit `application/json` through `Utils` even for a V2-only `Accept`, while the OpenAPI operation documents only V1 error media types and no 400 response. Please let the vendor request type select V2 when `Accept` is missing or wildcard (or preserve wildcard negotiation), return and document the V2 error media type, and add coverage for both cases.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12379] feat(core): Support assignment values in REST and Java client [gravitino]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #12384:
URL: https://github.com/apache/gravitino/pull/12384#discussion_r3755503533
##########
server/src/main/java/org/apache/gravitino/server/web/rest/TagOperations.java:
##########
@@ -157,7 +157,11 @@ public Response createTag(
request.validate();
Tag tag =
tagDispatcher.createTag(
- metalake, request.getName(), request.getComment(), request.getProperties());
+ metalake,
+ request.getName(),
+ request.getComment(),
+ request.getProperties(),
+ request.valueConstraint());
Review Comment:
Document the new tag constraint fields in the OpenAPI contract. `docs/open-api/tags.yaml:354-379` still omits constraint/assignment fields from `Tag`, and `docs/open-api/tags.yaml:405-423` omits `allowedValues` from `TagCreateRequest`, so generated clients cannot discover or model this user-facing capability.
##########
server/src/main/java/org/apache/gravitino/server/web/rest/TagOperations.java:
##########
@@ -268,14 +272,20 @@ public Response deleteTag(
public Response listMetadataObjectsForTag(
@PathParam("metalake") @AuthorizationMetadata(type = Entity.EntityType.METALAKE)
String metalake,
- @PathParam("tag") @AuthorizationMetadata(type = Entity.EntityType.TAG) String tagName) {
- LOG.info("Received list objects for tag: {} under metalake: {}", tagName, metalake);
+ @PathParam("tag") @AuthorizationMetadata(type = Entity.EntityType.TAG) String tagName,
+ @QueryParam("value") String value) {
Review Comment:
Validate a non-null `value` before forwarding it. The Java API rejects blank values and values over 256 characters, but this REST endpoint accepts them; in particular, `?value=` queries the storage sentinel used for no-value assignments, so raw REST callers can observe behavior that the public `objects(String)` API explicitly disallows. Apply the same nonblank/length rules here so invalid filters return 400.
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectTagOperations.java:
##########
@@ -260,6 +257,35 @@ public Response associateTagsForObject(
@PathParam("fullName") @AuthorizationFullName String fullName,
@AuthorizationRequest(type = AuthorizationRequest.RequestType.ASSOCIATE_TAG)
TagsAssociateRequest request) {
+ return associateTagsForObjectInternal(metalake, type, fullName, request);
+ }
+
+ /**
+ * Associates tag values with a metadata object using the v2 request representation.
+ *
+ * @param metalake The metalake name.
+ * @param type The metadata object type.
+ * @param fullName The metadata object full name.
+ * @param request The tag values association request.
+ * @return The response containing associated tag names.
+ */
+ @POST
+ @Produces("application/vnd.gravitino.v2+json")
+ @Timed(name = "associate-object-tags." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "associate-object-tags", absolute = true)
+ @AuthorizationExpression(expression = CAN_ACCESS_METADATA_AND_TAG)
+ public Response associateTagValuesForObject(
+ @PathParam("metalake") @AuthorizationMetadata(type = Entity.EntityType.METALAKE)
+ String metalake,
+ @PathParam("type") @AuthorizationObjectType String type,
+ @PathParam("fullName") @AuthorizationFullName String fullName,
+ @AuthorizationRequest(type = AuthorizationRequest.RequestType.ASSOCIATE_TAG)
+ TagValuesAssociateRequest request) {
+ return associateTagsForObjectInternal(metalake, type, fullName, request);
Review Comment:
Add this V2 representation to the OpenAPI contract. The association operation at `docs/open-api/tags.yaml:221-244` currently exposes only the V1 string-array request and V1 response media type, leaving the new valued request shape and `application/vnd.gravitino.v2+json` response undiscoverable.
##########
server/src/main/java/org/apache/gravitino/server/web/rest/TagOperations.java:
##########
@@ -268,14 +272,20 @@ public Response deleteTag(
public Response listMetadataObjectsForTag(
@PathParam("metalake") @AuthorizationMetadata(type = Entity.EntityType.METALAKE)
String metalake,
- @PathParam("tag") @AuthorizationMetadata(type = Entity.EntityType.TAG) String tagName) {
- LOG.info("Received list objects for tag: {} under metalake: {}", tagName, metalake);
+ @PathParam("tag") @AuthorizationMetadata(type = Entity.EntityType.TAG) String tagName,
+ @QueryParam("value") String value) {
+ LOG.info(
+ "Received list objects for tag: {} and value: {} under metalake: {}",
+ tagName,
+ value,
+ metalake);
try {
return Utils.doAs(
httpRequest,
() -> {
- MetadataObject[] objects = tagDispatcher.listMetadataObjectsForTag(metalake, tagName);
+ MetadataObject[] objects =
+ tagDispatcher.listMetadataObjectsForTag(metalake, tagName, value);
Review Comment:
Document the new `value` query parameter. `docs/open-api/tags.yaml:307-338` still describes this operation without any parameters beyond metalake and tag, so REST consumers and generated clients cannot use the new filtering feature from the published contract.
##########
server/src/test/java/org/apache/gravitino/server/web/filter/authorization/TestAssociateTagAuthorizationExecutor.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * 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.gravitino.server.web.filter.authorization;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyMap;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import org.apache.gravitino.Entity;
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.authorization.AuthorizationRequestContext;
+import org.apache.gravitino.dto.requests.TagValuesAssociateRequest;
+import org.apache.gravitino.dto.requests.TagsAssociateRequest;
+import org.apache.gravitino.server.authorization.annotations.AuthorizationRequest;
+import org.apache.gravitino.server.authorization.expression.AuthorizationExpressionEvaluator;
+import org.apache.gravitino.tag.TagValue;
+import org.junit.jupiter.api.Test;
+
+public class TestAssociateTagAuthorizationExecutor {
+
+ @Test
+ public void testAuthorizesV1TagNames() throws Exception {
+ TagsAssociateRequest request =
+ new TagsAssociateRequest(new String[] {"pii", "data_domain"}, null);
+ assertAuthorizesAllTags("associateV1", TagsAssociateRequest.class, request);
+ }
+
+ @Test
+ public void testAuthorizesV2TagValues() throws Exception {
+ TagValuesAssociateRequest request =
+ new TagValuesAssociateRequest(
+ new TagValue[] {TagValue.noValue("pii"), TagValue.of("data_domain", "finance")}, null);
+ assertAuthorizesAllTags("associateV2", TagValuesAssociateRequest.class, request);
Review Comment:
This V2 authorization test puts both tags in `tagsToAdd` and leaves `tagsToRemove` null, so it would still pass if removal tags were never authorized. Exercise one addition and one removal to cover both security-sensitive branches.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12379] feat(core): Support assignment values in REST and Java client [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12384:
URL: https://github.com/apache/gravitino/pull/12384#discussion_r3757299920
##########
common/src/main/java/org/apache/gravitino/dto/requests/TagValuesAssociateRequest.java:
##########
@@ -82,32 +85,28 @@ public TagValue[] tagValuesToRemove() {
@Override
public void validate() throws IllegalArgumentException {
Preconditions.checkArgument(
- tagsToAdd != null || tagsToRemove != null,
- "tagsToAdd and tagsToRemove cannot both be null");
+ tagsToAdd.length > 0 || tagsToRemove.length > 0,
+ "tagsToAdd and tagsToRemove cannot both be empty");
validateTagValues(tagsToAdd, "tagsToAdd");
Review Comment:
Fixed in e5aaed4e5. `TagValuesAssociateRequest.validate()` now rejects exact `(name, value)` overlap across add/remove arrays, with DTO-level regression coverage for valued and valueless pairs. Different values for the same tag remain valid.
##########
server/src/main/java/org/apache/gravitino/server/web/filter/authorization/AssociateTagAuthorizationExecutor.java:
##########
@@ -63,37 +66,51 @@ public boolean execute(AuthorizationRequestContext context) throws Exception {
context.setOriginalAuthorizationExpression(expression);
Entity.EntityType targetType =
Entity.EntityType.TAG; // Tags are the only supported batch target here
+
Preconditions.checkArgument(
- request instanceof TagsAssociateRequest,
+ request instanceof TagsAssociateRequest || request instanceof TagValuesAssociateRequest,
"Only tag can use AssociateTagAuthorizationExecutor, please contact the administrator.");
- TagsAssociateRequest tagsAssociateRequest = (TagsAssociateRequest) request;
- tagsAssociateRequest.validate();
+
+ TagValue[] tagsToAdd;
+ TagValue[] tagsToRemove;
+ if (request instanceof TagsAssociateRequest) {
+ TagsAssociateRequest tagsAssociateRequest = (TagsAssociateRequest) request;
+ tagsAssociateRequest.validate();
+ tagsToAdd = toNoValue(tagsAssociateRequest.getTagsToAdd());
+ tagsToRemove = toNoValue(tagsAssociateRequest.getTagsToRemove());
+ } else {
+ TagValuesAssociateRequest tagValuesAssociateRequest = (TagValuesAssociateRequest) request;
+ tagValuesAssociateRequest.validate();
Review Comment:
Fixed in e5aaed4e5. The authorization executor now extracts tag names without performing full request validation, leaving invalid V2 body validation to the resource layer. Added executor coverage and an interception/resource regression that returns 400 instead of authorization 500.
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectTagOperations.java:
##########
@@ -260,6 +257,35 @@ public Response associateTagsForObject(
@PathParam("fullName") @AuthorizationFullName String fullName,
@AuthorizationRequest(type = AuthorizationRequest.RequestType.ASSOCIATE_TAG)
TagsAssociateRequest request) {
+ return associateTagsForObjectInternal(metalake, type, fullName, request);
+ }
+
+ /**
+ * Associates tag values with a metadata object using the v2 request representation.
+ *
+ * @param metalake The metalake name.
+ * @param type The metadata object type.
+ * @param fullName The metadata object full name.
+ * @param request The tag values association request.
+ * @return The response containing associated tag names.
+ */
+ @POST
+ @Produces("application/vnd.gravitino.v2+json")
+ @Timed(name = "associate-object-tags." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "associate-object-tags", absolute = true)
+ @AuthorizationExpression(expression = CAN_ACCESS_METADATA_AND_TAG)
+ public Response associateTagValuesForObject(
+ @PathParam("metalake") @AuthorizationMetadata(type = Entity.EntityType.METALAKE)
+ String metalake,
+ @PathParam("type") @AuthorizationObjectType String type,
+ @PathParam("fullName") @AuthorizationFullName String fullName,
+ @AuthorizationRequest(type = AuthorizationRequest.RequestType.ASSOCIATE_TAG)
+ TagValuesAssociateRequest request) {
+ return associateTagsForObjectInternal(metalake, type, fullName, request);
Review Comment:
Fixed in e5aaed4e5. V2 association now consumes `application/vnd.gravitino.v2+json`, the Java client sends that content type plus Accept, OpenAPI documents V1 and V2 under separate request media types, and V2 success responses are returned with the negotiated V2 vendor media type. Added REST/client tests for the media-type behavior.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12379] feat(core): Support assignment values in REST and Java client [gravitino]
Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #12384:
URL: https://github.com/apache/gravitino/pull/12384#discussion_r3756961137
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectTagOperations.java:
##########
@@ -270,12 +296,24 @@ public Response associateTagsForObject(
httpRequest,
() -> {
request.validate();
+ TagValue[] tagsToAdd;
+ TagValue[] tagsToRemove;
+ if (request instanceof TagsAssociateRequest) {
+ TagsAssociateRequest tagsAssociateRequest = (TagsAssociateRequest) request;
+ tagsToAdd = toNoValue(tagsAssociateRequest.getTagsToAdd());
+ tagsToRemove = toNoValue(tagsAssociateRequest.getTagsToRemove());
+ } else {
+ TagValuesAssociateRequest tagValuesAssociateRequest =
+ (TagValuesAssociateRequest) request;
+ tagsToAdd = tagValuesAssociateRequest.tagValuesToAdd();
+ tagsToRemove = tagValuesAssociateRequest.tagValuesToRemove();
+ }
MetadataObject object =
MetadataObjects.parse(
fullName, MetadataObject.Type.valueOf(type.toUpperCase(Locale.ROOT)));
String[] tagNames =
- tagDispatcher.associateTagsForMetadataObject(
- metalake, object, request.getTagsToAdd(), request.getTagsToRemove());
+ tagDispatcher.associateTagValuesForMetadataObject(
Review Comment:
**[P1] Preserve pair-specific removal for V2 valueless entries**
`TagValuesAssociateRequest` maps an omitted or null value to `TagValue.noValue`, but `TagMetaService.associateTagValuesWithMetadataObject` treats any valueless removal as a wildcard and puts the tag ID in `tagIdsToRemove`, which deletes every row for this tag and object. If `domain=finance` and `domain=risk` are active, V2 `tagsToRemove: [{"name": "domain"}]` therefore silently removes both instead of only the `(domain, null)` pair, which may not exist. The V2 design defines removal as pair-specific and a missing pair as an idempotent no-op. Please keep the V1 name-only remove-all path separate from V2 pair removal and add this regression case.
##########
common/src/main/java/org/apache/gravitino/dto/requests/TagValuesAssociateRequest.java:
##########
@@ -82,32 +85,28 @@ public TagValue[] tagValuesToRemove() {
@Override
public void validate() throws IllegalArgumentException {
Preconditions.checkArgument(
- tagsToAdd != null || tagsToRemove != null,
- "tagsToAdd and tagsToRemove cannot both be null");
+ tagsToAdd.length > 0 || tagsToRemove.length > 0,
+ "tagsToAdd and tagsToRemove cannot both be empty");
validateTagValues(tagsToAdd, "tagsToAdd");
Review Comment:
**[P2] Reject an exact pair present in both arrays**
This validates each array independently but never checks their intersection. `TagManager` later removes common pairs from both sets, so adding and removing the same `(name, value)` in one request returns 200 as a no-op. The documented V2 contract requires this conflict to return 400. Please validate the cross-array intersection here and add a request-level regression test.
##########
clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/TagIT.java:
##########
@@ -298,6 +301,42 @@ public void testCreateGetAndListTag() {
Assertions.assertEquals(tag2, tag3);
}
+ @Test
+ public void testAssignmentValues() {
+ String tagName = GravitinoITUtils.genRandomName("tag_it_assignment_value");
+ TagValueConstraint constraint = TagValueConstraint.ofAllowedValues("finance", "risk");
+ Tag tag = metalake.createTag(tagName, "comment", Collections.emptyMap(), constraint);
+ Assertions.assertEquals(constraint, tag.valueConstraint());
+
+ TagValue[] values =
+ new TagValue[] {TagValue.of(tagName, "finance"), TagValue.of(tagName, "risk")};
+ Assertions.assertArrayEquals(
+ new String[] {tagName}, table.supportsTags().associateTags(values, null));
Review Comment:
**[P2] Keep all-valueless V2 additions idempotent**
A V2 request containing only `TagValue.noValue(...)` reaches `RelationUpdate.hasRelationValues() == false`, so `RelationalEntityStore` routes it through the legacy `associateTagsWithMetadataObject` path, which enables duplicate failure. Repeating the request then returns 409, while the same valueless pair becomes idempotent if its batch happens to contain any unrelated valued pair. V2 behavior should not depend on other batch elements. Please select the V1 versus V2 semantics explicitly and extend this test with a repeated all-valueless request.
##########
server/src/main/java/org/apache/gravitino/server/web/filter/authorization/AssociateTagAuthorizationExecutor.java:
##########
@@ -63,37 +66,51 @@ public boolean execute(AuthorizationRequestContext context) throws Exception {
context.setOriginalAuthorizationExpression(expression);
Entity.EntityType targetType =
Entity.EntityType.TAG; // Tags are the only supported batch target here
+
Preconditions.checkArgument(
- request instanceof TagsAssociateRequest,
+ request instanceof TagsAssociateRequest || request instanceof TagValuesAssociateRequest,
"Only tag can use AssociateTagAuthorizationExecutor, please contact the administrator.");
- TagsAssociateRequest tagsAssociateRequest = (TagsAssociateRequest) request;
- tagsAssociateRequest.validate();
+
+ TagValue[] tagsToAdd;
+ TagValue[] tagsToRemove;
+ if (request instanceof TagsAssociateRequest) {
+ TagsAssociateRequest tagsAssociateRequest = (TagsAssociateRequest) request;
+ tagsAssociateRequest.validate();
+ tagsToAdd = toNoValue(tagsAssociateRequest.getTagsToAdd());
+ tagsToRemove = toNoValue(tagsAssociateRequest.getTagsToRemove());
+ } else {
+ TagValuesAssociateRequest tagValuesAssociateRequest = (TagValuesAssociateRequest) request;
+ tagValuesAssociateRequest.validate();
Review Comment:
**[P2] Preserve 400 responses for invalid V2 bodies when authorization is enabled**
A deserialized but invalid V2 body, such as both arrays empty or a blank or overlong value, throws here before the resource method runs. `GravitinoInterceptionService` catches that exception and converts it to `Utils.internalError`, so the request returns 500 instead of the REST layer 400. Please avoid full request validation in the authorizer or map validation failures to Bad Request, and add an authorization-enabled endpoint test.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12379] feat(core): Support assignment values in REST and Java client [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12384:
URL: https://github.com/apache/gravitino/pull/12384#discussion_r3757298822
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectTagOperations.java:
##########
@@ -270,12 +296,24 @@ public Response associateTagsForObject(
httpRequest,
() -> {
request.validate();
+ TagValue[] tagsToAdd;
+ TagValue[] tagsToRemove;
+ if (request instanceof TagsAssociateRequest) {
+ TagsAssociateRequest tagsAssociateRequest = (TagsAssociateRequest) request;
+ tagsToAdd = toNoValue(tagsAssociateRequest.getTagsToAdd());
+ tagsToRemove = toNoValue(tagsAssociateRequest.getTagsToRemove());
+ } else {
+ TagValuesAssociateRequest tagValuesAssociateRequest =
+ (TagValuesAssociateRequest) request;
+ tagsToAdd = tagValuesAssociateRequest.tagValuesToAdd();
+ tagsToRemove = tagValuesAssociateRequest.tagValuesToRemove();
+ }
MetadataObject object =
MetadataObjects.parse(
fullName, MetadataObject.Type.valueOf(type.toUpperCase(Locale.ROOT)));
String[] tagNames =
- tagDispatcher.associateTagsForMetadataObject(
- metalake, object, request.getTagsToAdd(), request.getTagsToRemove());
+ tagDispatcher.associateTagValuesForMetadataObject(
Review Comment:
Fixed in e5aaed4e5. V1 name-only removal and V2 pair-specific removal are now separated; V2 valueless removal only removes the `(tag, null)` pair and is a no-op when that pair is absent. Added a regression in `TestTagManager` for valued assignments surviving `TagValue.noValue(tag)` removal.
##########
clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/TagIT.java:
##########
@@ -298,6 +301,42 @@ public void testCreateGetAndListTag() {
Assertions.assertEquals(tag2, tag3);
}
+ @Test
+ public void testAssignmentValues() {
+ String tagName = GravitinoITUtils.genRandomName("tag_it_assignment_value");
+ TagValueConstraint constraint = TagValueConstraint.ofAllowedValues("finance", "risk");
+ Tag tag = metalake.createTag(tagName, "comment", Collections.emptyMap(), constraint);
+ Assertions.assertEquals(constraint, tag.valueConstraint());
+
+ TagValue[] values =
+ new TagValue[] {TagValue.of(tagName, "finance"), TagValue.of(tagName, "risk")};
+ Assertions.assertArrayEquals(
+ new String[] {tagName}, table.supportsTags().associateTags(values, null));
Review Comment:
Fixed in e5aaed4e5. `RelationUpdate` now carries an explicit value-aware flag, so V2 all-valueless requests still route through the idempotent value-aware path while legacy V1 keeps duplicate-failing semantics. Added repeated no-value coverage in both `TestTagManager` and `TagIT`.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12379] feat(core): Support assignment values in REST and Java client [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12384:
URL: https://github.com/apache/gravitino/pull/12384#discussion_r3755670867
##########
server/src/test/java/org/apache/gravitino/server/web/filter/authorization/TestAssociateTagAuthorizationExecutor.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * 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.gravitino.server.web.filter.authorization;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyMap;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import org.apache.gravitino.Entity;
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.authorization.AuthorizationRequestContext;
+import org.apache.gravitino.dto.requests.TagValuesAssociateRequest;
+import org.apache.gravitino.dto.requests.TagsAssociateRequest;
+import org.apache.gravitino.server.authorization.annotations.AuthorizationRequest;
+import org.apache.gravitino.server.authorization.expression.AuthorizationExpressionEvaluator;
+import org.apache.gravitino.tag.TagValue;
+import org.junit.jupiter.api.Test;
+
+public class TestAssociateTagAuthorizationExecutor {
+
+ @Test
+ public void testAuthorizesV1TagNames() throws Exception {
+ TagsAssociateRequest request =
+ new TagsAssociateRequest(new String[] {"pii", "data_domain"}, null);
+ assertAuthorizesAllTags("associateV1", TagsAssociateRequest.class, request);
+ }
+
+ @Test
+ public void testAuthorizesV2TagValues() throws Exception {
+ TagValuesAssociateRequest request =
+ new TagValuesAssociateRequest(
+ new TagValue[] {TagValue.noValue("pii"), TagValue.of("data_domain", "finance")}, null);
+ assertAuthorizesAllTags("associateV2", TagValuesAssociateRequest.class, request);
Review Comment:
Fixed in 694053b1c. The V1 and V2 authorization tests now exercise one tag in tagsToAdd and one tag in tagsToRemove, so the test fails if the removal branch is not authorized.
##########
server/src/main/java/org/apache/gravitino/server/web/rest/TagOperations.java:
##########
@@ -268,14 +272,20 @@ public Response deleteTag(
public Response listMetadataObjectsForTag(
@PathParam("metalake") @AuthorizationMetadata(type = Entity.EntityType.METALAKE)
String metalake,
- @PathParam("tag") @AuthorizationMetadata(type = Entity.EntityType.TAG) String tagName) {
- LOG.info("Received list objects for tag: {} under metalake: {}", tagName, metalake);
+ @PathParam("tag") @AuthorizationMetadata(type = Entity.EntityType.TAG) String tagName,
+ @QueryParam("value") String value) {
Review Comment:
Fixed in 694053b1c. The REST endpoint now validates a non-null value filter as nonblank and <= 256 characters before forwarding it, and TestTagOperations covers a valid value, value=, and an over-length value returning 400.
##########
server/src/main/java/org/apache/gravitino/server/web/rest/TagOperations.java:
##########
@@ -157,7 +157,11 @@ public Response createTag(
request.validate();
Tag tag =
tagDispatcher.createTag(
- metalake, request.getName(), request.getComment(), request.getProperties());
+ metalake,
+ request.getName(),
+ request.getComment(),
+ request.getProperties(),
+ request.valueConstraint());
Review Comment:
Fixed in 694053b1c. The OpenAPI Tag schema now documents allowedValues and assignmentValues, and TagCreateRequest documents allowedValues.
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectTagOperations.java:
##########
@@ -260,6 +257,35 @@ public Response associateTagsForObject(
@PathParam("fullName") @AuthorizationFullName String fullName,
@AuthorizationRequest(type = AuthorizationRequest.RequestType.ASSOCIATE_TAG)
TagsAssociateRequest request) {
+ return associateTagsForObjectInternal(metalake, type, fullName, request);
+ }
+
+ /**
+ * Associates tag values with a metadata object using the v2 request representation.
+ *
+ * @param metalake The metalake name.
+ * @param type The metadata object type.
+ * @param fullName The metadata object full name.
+ * @param request The tag values association request.
+ * @return The response containing associated tag names.
+ */
+ @POST
+ @Produces("application/vnd.gravitino.v2+json")
+ @Timed(name = "associate-object-tags." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "associate-object-tags", absolute = true)
+ @AuthorizationExpression(expression = CAN_ACCESS_METADATA_AND_TAG)
+ public Response associateTagValuesForObject(
+ @PathParam("metalake") @AuthorizationMetadata(type = Entity.EntityType.METALAKE)
+ String metalake,
+ @PathParam("type") @AuthorizationObjectType String type,
+ @PathParam("fullName") @AuthorizationFullName String fullName,
+ @AuthorizationRequest(type = AuthorizationRequest.RequestType.ASSOCIATE_TAG)
+ TagValuesAssociateRequest request) {
+ return associateTagsForObjectInternal(metalake, type, fullName, request);
Review Comment:
Fixed in 694053b1c. The associateTags OpenAPI operation now documents both V1 TagsAssociateRequest and V2 TagValuesAssociateRequest shapes and includes the application/vnd.gravitino.v2+json 200 response media type.
##########
server/src/main/java/org/apache/gravitino/server/web/rest/TagOperations.java:
##########
@@ -268,14 +272,20 @@ public Response deleteTag(
public Response listMetadataObjectsForTag(
@PathParam("metalake") @AuthorizationMetadata(type = Entity.EntityType.METALAKE)
String metalake,
- @PathParam("tag") @AuthorizationMetadata(type = Entity.EntityType.TAG) String tagName) {
- LOG.info("Received list objects for tag: {} under metalake: {}", tagName, metalake);
+ @PathParam("tag") @AuthorizationMetadata(type = Entity.EntityType.TAG) String tagName,
+ @QueryParam("value") String value) {
+ LOG.info(
+ "Received list objects for tag: {} and value: {} under metalake: {}",
+ tagName,
+ value,
+ metalake);
try {
return Utils.doAs(
httpRequest,
() -> {
- MetadataObject[] objects = tagDispatcher.listMetadataObjectsForTag(metalake, tagName);
+ MetadataObject[] objects =
+ tagDispatcher.listMetadataObjectsForTag(metalake, tagName, value);
Review Comment:
Fixed in 694053b1c. The listTagObjects OpenAPI operation now documents the value query parameter with the 256-character limit.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12379] feat(core): Support assignment values in REST and Java client [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12384:
URL: https://github.com/apache/gravitino/pull/12384#discussion_r3726846586
##########
common/src/main/java/org/apache/gravitino/dto/requests/TagValuesAssociateRequest.java:
##########
@@ -82,32 +81,31 @@ public TagValue[] tagValuesToRemove() {
@Override
public void validate() throws IllegalArgumentException {
Preconditions.checkArgument(
- tagsToAdd != null || tagsToRemove != null,
- "tagsToAdd and tagsToRemove cannot both be null");
+ tagsToAdd != null && tagsToRemove != null,
+ "tagsToAdd and tagsToRemove must be arrays; use empty arrays when no tags are provided");
Review Comment:
You only removes the tag values. The tagsToAdd should be an empty array.
You only adds the tag values. The TagsToRemove should be an empty array.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12379] feat(core): Support assignment values in REST and Java client [gravitino]
Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #12384:
URL: https://github.com/apache/gravitino/pull/12384#discussion_r3756962317
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectTagOperations.java:
##########
@@ -260,6 +257,35 @@ public Response associateTagsForObject(
@PathParam("fullName") @AuthorizationFullName String fullName,
@AuthorizationRequest(type = AuthorizationRequest.RequestType.ASSOCIATE_TAG)
TagsAssociateRequest request) {
+ return associateTagsForObjectInternal(metalake, type, fullName, request);
+ }
+
+ /**
+ * Associates tag values with a metadata object using the v2 request representation.
+ *
+ * @param metalake The metalake name.
+ * @param type The metadata object type.
+ * @param fullName The metadata object full name.
+ * @param request The tag values association request.
+ * @return The response containing associated tag names.
+ */
+ @POST
+ @Produces("application/vnd.gravitino.v2+json")
+ @Timed(name = "associate-object-tags." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "associate-object-tags", absolute = true)
+ @AuthorizationExpression(expression = CAN_ACCESS_METADATA_AND_TAG)
+ public Response associateTagValuesForObject(
+ @PathParam("metalake") @AuthorizationMetadata(type = Entity.EntityType.METALAKE)
+ String metalake,
+ @PathParam("type") @AuthorizationObjectType String type,
+ @PathParam("fullName") @AuthorizationFullName String fullName,
+ @AuthorizationRequest(type = AuthorizationRequest.RequestType.ASSOCIATE_TAG)
+ TagValuesAssociateRequest request) {
+ return associateTagsForObjectInternal(metalake, type, fullName, request);
Review Comment:
**[P2] The updated spec still leaves V2 negotiation ambiguous**
Both request shapes are now under the same `application/json` `oneOf`, but runtime selects `TagsAssociateRequest` versus `TagValuesAssociateRequest` using the request `Accept` header, and `VersioningFilter` defaults a missing or non-versioned `Accept` to V1. A client can therefore send the documented valued body and receive 400 unless it separately knows to set `Accept: application/vnd.gravitino.v2+json`. The success response has the inverse mismatch: the V2 method calls `Utils.ok`, which forces `Content-Type: application/json` although this operation advertises the V2 vendor media type. Please bind request-version selection explicitly, for example with a versioned request media type, and return the negotiated response media type.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12379] feat(core): Support assignment values in REST and Java client [gravitino]
Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #12384:
URL: https://github.com/apache/gravitino/pull/12384#discussion_r3758506579
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectTagOperations.java:
##########
@@ -260,6 +257,35 @@ public Response associateTagsForObject(
@PathParam("fullName") @AuthorizationFullName String fullName,
@AuthorizationRequest(type = AuthorizationRequest.RequestType.ASSOCIATE_TAG)
TagsAssociateRequest request) {
+ return associateTagsForObjectInternal(metalake, type, fullName, request);
+ }
+
+ /**
+ * Associates tag values with a metadata object using the v2 request representation.
+ *
+ * @param metalake The metalake name.
+ * @param type The metadata object type.
+ * @param fullName The metadata object full name.
+ * @param request The tag values association request.
+ * @return The response containing associated tag names.
+ */
+ @POST
+ @Produces("application/vnd.gravitino.v2+json")
+ @Timed(name = "associate-object-tags." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "associate-object-tags", absolute = true)
+ @AuthorizationExpression(expression = CAN_ACCESS_METADATA_AND_TAG)
+ public Response associateTagValuesForObject(
+ @PathParam("metalake") @AuthorizationMetadata(type = Entity.EntityType.METALAKE)
+ String metalake,
+ @PathParam("type") @AuthorizationObjectType String type,
+ @PathParam("fullName") @AuthorizationFullName String fullName,
+ @AuthorizationRequest(type = AuthorizationRequest.RequestType.ASSOCIATE_TAG)
+ TagValuesAssociateRequest request) {
+ return associateTagsForObjectInternal(metalake, type, fullName, request);
Review Comment:
**[P2] Keep explicit `Accept` preferences and pre-resource V2 errors intact**
The new fallback still treats every `Accept` value without a Gravitino vendor token as if it were absent or wildcard. For example, with `Content-Type: application/vnd.gravitino.v2+json` and explicit `Accept: application/json`, `VersioningFilter` replaces the client preference with V2 and returns a representation the client did not accept instead of allowing normal 406 negotiation. The parser also still stops at the first vendor token and ignores quality/fallback ranges (for example, `v3;q=0, v2`). In addition, `withMediaType` only covers exceptions raised after the resource is invoked: malformed JSON is handled earlier by the JSON exception mappers, which still use `Utils.illegalArguments` and return `application/json`, although the updated OpenAPI 400 response promises the V2 media type for malformed requests. Please parse the actual Accept ranges and apply the negotiated media type in a response/exception layer that also covers deserialization failures; add explicit non-wildcard
Accept and malformed-JSON regressions.
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectTagOperations.java:
##########
@@ -270,26 +299,65 @@ public Response associateTagsForObject(
httpRequest,
() -> {
request.validate();
- MetadataObject object =
- MetadataObjects.parse(
- fullName, MetadataObject.Type.valueOf(type.toUpperCase(Locale.ROOT)));
+ MetadataObject object = parseMetadataObject(type, fullName);
String[] tagNames =
tagDispatcher.associateTagsForMetadataObject(
metalake, object, request.getTagsToAdd(), request.getTagsToRemove());
tagNames = tagNames == null ? new String[0] : tagNames;
- LOG.info(
- "Associated tags: {} for object type: {}, full name: {} under metalake: {}",
- Arrays.toString(tagNames),
- type,
- fullName,
- metalake);
+ logAssociatedTags(type, fullName, metalake, tagNames);
return Utils.ok(new NameListResponse(tagNames));
});
} catch (Exception e) {
return ExceptionHandlers.handleTagException(OperationType.ASSOCIATE, "", fullName, e);
}
}
+ private Response associateTagValuesForObjectInternal(
+ String metalake, String type, String fullName, TagValuesAssociateRequest request) {
+ LOG.info(
+ "Received associate tag values request for object type: {}, full name: {} under metalake: {}",
+ type,
+ fullName,
+ metalake);
+ try {
+ return Utils.doAs(
+ httpRequest,
+ () -> {
+ request.validate();
+ MetadataObject object = parseMetadataObject(type, fullName);
+ String[] tagNames =
+ tagDispatcher.associateTagValuesForMetadataObject(
Review Comment:
**[P2] Return 404 when a V2 pair references a missing tag**
This V2 path still inherits the legacy name-only “ignore missing tags” behavior. `TagMetaService` resolves only existing tag definitions and simply `continue`s when the requested name is absent, so `tagsToAdd: [{"name":"typo","value":"finance"}]` (and the corresponding removal) returns 200 with no change. The tag-assignment-values contract requires a missing tag referenced by either V2 array to return 404; silently succeeding makes client typos look applied. Please validate all V2 pair names before updating while preserving the V1 ignore-missing behavior, and add an endpoint regression.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12379] feat(core): Support assignment values in REST and Java client [gravitino]
Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #12384:
URL: https://github.com/apache/gravitino/pull/12384#discussion_r3758508689
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectTagOperations.java:
##########
@@ -270,26 +299,65 @@ public Response associateTagsForObject(
httpRequest,
() -> {
request.validate();
- MetadataObject object =
- MetadataObjects.parse(
- fullName, MetadataObject.Type.valueOf(type.toUpperCase(Locale.ROOT)));
+ MetadataObject object = parseMetadataObject(type, fullName);
String[] tagNames =
tagDispatcher.associateTagsForMetadataObject(
metalake, object, request.getTagsToAdd(), request.getTagsToRemove());
tagNames = tagNames == null ? new String[0] : tagNames;
- LOG.info(
- "Associated tags: {} for object type: {}, full name: {} under metalake: {}",
- Arrays.toString(tagNames),
- type,
- fullName,
- metalake);
+ logAssociatedTags(type, fullName, metalake, tagNames);
return Utils.ok(new NameListResponse(tagNames));
});
} catch (Exception e) {
return ExceptionHandlers.handleTagException(OperationType.ASSOCIATE, "", fullName, e);
}
}
+ private Response associateTagValuesForObjectInternal(
+ String metalake, String type, String fullName, TagValuesAssociateRequest request) {
+ LOG.info(
+ "Received associate tag values request for object type: {}, full name: {} under metalake: {}",
+ type,
+ fullName,
+ metalake);
+ try {
+ return Utils.doAs(
+ httpRequest,
+ () -> {
+ request.validate();
+ MetadataObject object = parseMetadataObject(type, fullName);
+ String[] tagNames =
+ tagDispatcher.associateTagValuesForMetadataObject(
+ metalake, object, request.tagValuesToAdd(), request.tagValuesToRemove());
Review Comment:
**[P2] Map the valueless/valued state conflict to 409**
When this V2 request adds a valueless pair while non-null values for the same tag remain active, `TagMetaService` fails `Preconditions.checkArgument(activeValues.isEmpty())`. That becomes `IllegalArgumentException`, and `TagExceptionHandler` returns 400. This is a valid pair-shaped request that conflicts with current assignment state; the checked-in contract explicitly requires 409 for this case. Please raise or map a conflict exception and add a REST regression that starts with a valued assignment and then attempts a valueless add without removing the values.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12379] feat(core): Support assignment values in REST and Java client [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12384:
URL: https://github.com/apache/gravitino/pull/12384#discussion_r3758016645
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectTagOperations.java:
##########
@@ -270,12 +296,24 @@ public Response associateTagsForObject(
httpRequest,
() -> {
request.validate();
+ TagValue[] tagsToAdd;
+ TagValue[] tagsToRemove;
+ if (request instanceof TagsAssociateRequest) {
+ TagsAssociateRequest tagsAssociateRequest = (TagsAssociateRequest) request;
+ tagsToAdd = toNoValue(tagsAssociateRequest.getTagsToAdd());
+ tagsToRemove = toNoValue(tagsAssociateRequest.getTagsToRemove());
+ } else {
+ TagValuesAssociateRequest tagValuesAssociateRequest =
+ (TagValuesAssociateRequest) request;
+ tagsToAdd = tagValuesAssociateRequest.tagValuesToAdd();
+ tagsToRemove = tagValuesAssociateRequest.tagValuesToRemove();
+ }
MetadataObject object =
MetadataObjects.parse(
fullName, MetadataObject.Type.valueOf(type.toUpperCase(Locale.ROOT)));
String[] tagNames =
- tagDispatcher.associateTagsForMetadataObject(
- metalake, object, request.getTagsToAdd(), request.getTagsToRemove());
+ tagDispatcher.associateTagValuesForMetadataObject(
Review Comment:
Fixed in f613cb307. V1 REST now calls the tag-name overload `associateTagsForMetadataObject`, while V2 stays on `associateTagValuesForMetadataObject`. Added a core regression covering V2 valued assignment followed by V1 name removal, and updated the REST test to verify the V1 string overload path.
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectTagOperations.java:
##########
@@ -260,6 +257,35 @@ public Response associateTagsForObject(
@PathParam("fullName") @AuthorizationFullName String fullName,
@AuthorizationRequest(type = AuthorizationRequest.RequestType.ASSOCIATE_TAG)
TagsAssociateRequest request) {
+ return associateTagsForObjectInternal(metalake, type, fullName, request);
+ }
+
+ /**
+ * Associates tag values with a metadata object using the v2 request representation.
+ *
+ * @param metalake The metalake name.
+ * @param type The metadata object type.
+ * @param fullName The metadata object full name.
+ * @param request The tag values association request.
+ * @return The response containing associated tag names.
+ */
+ @POST
+ @Produces("application/vnd.gravitino.v2+json")
+ @Timed(name = "associate-object-tags." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "associate-object-tags", absolute = true)
+ @AuthorizationExpression(expression = CAN_ACCESS_METADATA_AND_TAG)
+ public Response associateTagValuesForObject(
+ @PathParam("metalake") @AuthorizationMetadata(type = Entity.EntityType.METALAKE)
+ String metalake,
+ @PathParam("type") @AuthorizationObjectType String type,
+ @PathParam("fullName") @AuthorizationFullName String fullName,
+ @AuthorizationRequest(type = AuthorizationRequest.RequestType.ASSOCIATE_TAG)
+ TagValuesAssociateRequest request) {
+ return associateTagsForObjectInternal(metalake, type, fullName, request);
Review Comment:
Fixed in f613cb307. `VersioningFilter` now derives the response version from versioned `Content-Type` when `Accept` is missing or wildcard, V2 association errors are returned with the V2 vendor media type, OpenAPI documents V2 error media for the association operation, and tests cover both Content-Type negotiation cases plus V2 error media.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12379] feat(core): Support assignment values in REST and Java client [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12384:
URL: https://github.com/apache/gravitino/pull/12384#discussion_r3758759520
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectTagOperations.java:
##########
@@ -260,6 +257,35 @@ public Response associateTagsForObject(
@PathParam("fullName") @AuthorizationFullName String fullName,
@AuthorizationRequest(type = AuthorizationRequest.RequestType.ASSOCIATE_TAG)
TagsAssociateRequest request) {
+ return associateTagsForObjectInternal(metalake, type, fullName, request);
+ }
+
+ /**
+ * Associates tag values with a metadata object using the v2 request representation.
+ *
+ * @param metalake The metalake name.
+ * @param type The metadata object type.
+ * @param fullName The metadata object full name.
+ * @param request The tag values association request.
+ * @return The response containing associated tag names.
+ */
+ @POST
+ @Produces("application/vnd.gravitino.v2+json")
+ @Timed(name = "associate-object-tags." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "associate-object-tags", absolute = true)
+ @AuthorizationExpression(expression = CAN_ACCESS_METADATA_AND_TAG)
+ public Response associateTagValuesForObject(
+ @PathParam("metalake") @AuthorizationMetadata(type = Entity.EntityType.METALAKE)
+ String metalake,
+ @PathParam("type") @AuthorizationObjectType String type,
+ @PathParam("fullName") @AuthorizationFullName String fullName,
+ @AuthorizationRequest(type = AuthorizationRequest.RequestType.ASSOCIATE_TAG)
+ TagValuesAssociateRequest request) {
+ return associateTagsForObjectInternal(metalake, type, fullName, request);
Review Comment:
We don't consider this case now.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12379] feat(core): Support assignment values in REST and Java client [gravitino]
Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #12384:
URL: https://github.com/apache/gravitino/pull/12384#discussion_r3726594629
##########
common/src/main/java/org/apache/gravitino/dto/requests/TagValuesAssociateRequest.java:
##########
@@ -82,32 +81,31 @@ public TagValue[] tagValuesToRemove() {
@Override
public void validate() throws IllegalArgumentException {
Preconditions.checkArgument(
- tagsToAdd != null || tagsToRemove != null,
- "tagsToAdd and tagsToRemove cannot both be null");
+ tagsToAdd != null && tagsToRemove != null,
+ "tagsToAdd and tagsToRemove must be arrays; use empty arrays when no tags are provided");
Review Comment:
what's the case for "no tags are provided"?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org