mchades commented on code in PR #14669:
URL: https://github.com/apache/gravitino/pull/14669#discussion_r4491765766
##########
server-common/src/main/java/org/apache/gravitino/server/authorization/expression/AuthorizationExpressionEvaluator.java:
##########
@@ -183,8 +185,15 @@ private boolean evaluate(
metadataNames.forEach(
(type, entityNameIdent) -> {
if (isMetadataType(type)) {
- MetadataObject metadataObject =
- NameIdentifierUtil.toMetadataObject(entityNameIdent, type);
+ MetadataObject metadataObject;
+ try {
+ metadataObject =
NameIdentifierUtil.toMetadataObject(entityNameIdent, type);
+ } catch (IllegalNameIdentifierException e) {
+ throw e;
+ } catch (IllegalArgumentException e) {
+ // Only metadata-name parsing failures are client errors, not
authorizer failures.
+ throw new IllegalMetadataObjectException(e, "%s",
e.getMessage());
Review Comment:
The 400 fix is scoped to the Gravitino REST failure in #14668. Lance/Iceberg
authorization already wraps these parsing failures in RuntimeException before
response mapping, so this PR does not introduce their 500 behavior.
MetadataAuthzHelper has different paths: per-object failures are filtered out,
while parent-scope failures propagate. I'd keep cross-protocol mapping
separate, with endpoint-specific reproduction and tests.
##########
server/src/main/java/org/apache/gravitino/server/web/rest/ExceptionHandlers.java:
##########
@@ -1048,7 +1049,11 @@ public Response handle(OperationType op, String
semanticModel, String schema, Ex
String errorMsg = getSemanticModelErrorMsg(formatted, op.name(), schema,
getErrorMsg(e));
LOG.warn(errorMsg, e);
- if (e instanceof IllegalArgumentException) {
+ if (e instanceof IllegalMetadataObjectException) {
+ // Preserve the existing response type for source-name validation
failures.
Review Comment:
Other paths can observe the subtype; we're accepting that refinement for
2.0. It still extends IllegalArgumentException, so the existing argument-error
handling and codes apply. Semantic Model is also new in 2.0: removed its
compatibility-only special case and updated the regression expectation in
f345fe8c68.
##########
server-common/src/main/java/org/apache/gravitino/server/authorization/expression/AuthorizationExpressionEvaluator.java:
##########
@@ -183,8 +185,15 @@ private boolean evaluate(
metadataNames.forEach(
(type, entityNameIdent) -> {
if (isMetadataType(type)) {
- MetadataObject metadataObject =
- NameIdentifierUtil.toMetadataObject(entityNameIdent, type);
+ MetadataObject metadataObject;
+ try {
+ metadataObject =
NameIdentifierUtil.toMetadataObject(entityNameIdent, type);
+ } catch (IllegalNameIdentifierException e) {
+ throw e;
+ } catch (IllegalArgumentException e) {
Review Comment:
The method itself also throws IllegalArgumentException for null inputs or
unsupported types. Here, isMetadataType filters unsupported entity types before
conversion; all 16 admitted types have matching conversion branches. Authorizer
construction and OGNL execution remain outside this catch. This relies on
callers supplying non-null identifiers; I found no current request path
violating that contract.
--
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]