Version
main branch
Describe what's wrong
MetadataAuthzHelper.preloadOwner is a best-effort cache warm-up - its catch (Exception e) logs and ignores any failure. But the entity-store lookup sits outside that try:
private static void preloadOwner(Entity.EntityType entityType, NameIdentifier[] nameIdentifiers) {
if (!GravitinoEnv.getInstance().cacheEnabled()) {
return;
}
EntityStore entityStore = GravitinoEnv.getInstance().entityStore(); // <-- outside the try
try {
entityStore.relationOperations().batchListEntitiesByRelation(...);
} catch (Exception e) {
LOG.warn("Ignore preloadOwner error:{}", e.getMessage(), e);
}
}
GravitinoEnv.entityStore() has Preconditions.checkArgument(initialized, "GravitinoEnv is not initialized."), so when the environment is not initialized that IllegalArgumentException escapes the warm-up, propagates out of MetadataAuthzHelper.filterByExpression, and fails the entire list request with HTTP 400 - even though nothing about the requested listing actually failed.
Error message and/or stacktrace
{"code":1001,"type":"IllegalArgumentException",
"message":"Failed to operate tag(s) operation [LIST] under object [object1.object2], reason [GravitinoEnv is not initialized.]"}
java.lang.IllegalArgumentException: GravitinoEnv is not initialized.
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:143)
at org.apache.gravitino.GravitinoEnv.entityStore(GravitinoEnv.java:261)
at org.apache.gravitino.server.authorization.MetadataAuthzHelper.preloadOwner(MetadataAuthzHelper.java:552)
at org.apache.gravitino.server.authorization.MetadataAuthzHelper.filterByExpression(MetadataAuthzHelper.java:364)
at org.apache.gravitino.server.web.rest.MetadataObjectTagOperations.lambda$listTagsForMetadataObject$9(MetadataObjectTagOperations.java:217)
How to reproduce
Version: main branch. Any list endpoint that routes through MetadataAuthzHelper.filterByExpression while GravitinoEnv is uninitialized returns 400. Observable on main with:
./gradlew :server:test -PskipITs --tests "org.apache.gravitino.server.web.rest.TestMetadataObjectTagOperations"
Three tests fail with 400 instead of 200: testListTagsForObject, testListTagsForObjectUnderHierarchicalSchema, testListTagsDeduplicatesDifferentAssignmentValues.
A booted server initializes GravitinoEnv, so production traffic does not hit this today - the defect is that a helper documented and coded as ignorable can still abort the request.
Additional context
Found while adding tag support for Semantic Models (#12615). The fix is to move the lookup inside the existing try.
Version
main branch
Describe what's wrong
MetadataAuthzHelper.preloadOwneris a best-effort cache warm-up - itscatch (Exception e)logs and ignores any failure. But the entity-store lookup sits outside thattry:GravitinoEnv.entityStore()hasPreconditions.checkArgument(initialized, "GravitinoEnv is not initialized."), so when the environment is not initialized thatIllegalArgumentExceptionescapes the warm-up, propagates out ofMetadataAuthzHelper.filterByExpression, and fails the entire list request with HTTP 400 - even though nothing about the requested listing actually failed.Error message and/or stacktrace
How to reproduce
Version: main branch. Any list endpoint that routes through
MetadataAuthzHelper.filterByExpressionwhileGravitinoEnvis uninitialized returns 400. Observable onmainwith:./gradlew :server:test -PskipITs --tests "org.apache.gravitino.server.web.rest.TestMetadataObjectTagOperations"Three tests fail with 400 instead of 200:
testListTagsForObject,testListTagsForObjectUnderHierarchicalSchema,testListTagsDeduplicatesDifferentAssignmentValues.A booted server initializes
GravitinoEnv, so production traffic does not hit this today - the defect is that a helper documented and coded as ignorable can still abort the request.Additional context
Found while adding tag support for Semantic Models (#12615). The fix is to move the lookup inside the existing
try.