jarredhj0214 opened a new pull request, #12214:
URL: https://github.com/apache/gravitino/pull/12214

   ### What changes were proposed in this pull request?
   
   This PR updates `MetadataIdConverter` to gracefully handle missing parent 
metadata during metadata id resolution.
   
   When resolving metadata ids for objects such as filesets, schemas, tables, 
or topics, `MetadataIdConverter` normalizes the object identifier according to 
the parent catalog's case-sensitivity capability before looking up the entity 
id. If that parent catalog no longer exists, the target metadata cannot be 
resolved, so the converter now returns `Optional.empty()` instead of 
propagating `NotFoundException`.
   
   A unit test was added to cover the missing parent catalog case.
   
   ### Why are the changes needed?
   
   Revoking privileges from a role for a metadata object whose parent catalog 
no longer exists can fail during authorization expression evaluation with an 
internal error.
   
   For example, the failure can look like:
   
   ```text
   System internal error during authorization - Operation: 
revokePrivilegeFromRole
   Caused by: org.apache.gravitino.exceptions.NoSuchCatalogException:
   Catalog <metalake>.<catalog> does not exist
     at org.apache.gravitino.catalog.CatalogManager.loadCatalogInternal
     at org.apache.gravitino.catalog.CapabilityHelpers.getCapability
     at 
org.apache.gravitino.server.authorization.MetadataIdConverter.normalizeCaseSensitive
     at org.apache.gravitino.server.authorization.MetadataIdConverter.getID
     at 
org.apache.gravitino.server.authorization.jcasbin.JcasbinAuthorizationLookups.loadMetadataId
     
   This happens before the revoke operation reaches the business logic. During 
authorization, the requested metadata object is converted to an internal 
metadata id. For child metadata objects, this conversion first loads the parent 
catalog to apply the correct case-sensitivity normalization. If the parent 
catalog has already been dropped, that lookup throws NoSuchCatalogException, 
which currently bubbles up through the authorization expression evaluator as an 
internal error.
   Returning Optional.empty() is consistent with the existing contract of 
MetadataIdConverter#getID: if the metadata object cannot be resolved, the 
converter should return empty. A missing parent catalog means the requested 
child metadata object cannot exist or be resolved in Gravitino, so treating it 
as missing metadata is safer and more accurate than failing authorization 
evaluation with an internal exception.
   Fix: N/A
   Does this PR introduce any user-facing change?
   No API or configuration changes.
   How was this patch tested?
   Ran:
   ./gradlew :server-common:test \
     --tests org.apache.gravitino.server.authorization.TestMetadataIdConverter \
     --tests 
org.apache.gravitino.server.authorization.jcasbin.TestJcasbinAuthorizationLookups
 \
     -PskipITs -PskipDockerTests=false


-- 
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