[Cherry-pick to branch-1.3] [MINOR] fix(auth): Handle missing parent catalog during metadata id resolution (#12214) - #12408
Open
github-actions[bot] wants to merge 1 commit into
Conversation
…esolution (#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: #12216 ### Does this PR introduce any user-facing change? No API or configuration changes. ### How was this patch tested? Ran: ```shell ./gradlew :server-common:test \ --tests org.apache.gravitino.server.authorization.TestMetadataIdConverter \ --tests org.apache.gravitino.server.authorization.jcasbin.TestJcasbinAuthorizationLookups \ -PskipITs -PskipDockerTests=false ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-pick Information:
branch-1.3