Skip to content

[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
branch-1.3from
cherry-pick-a98f0182-to-branch-1.3
Open

[Cherry-pick to branch-1.3] [MINOR] fix(auth): Handle missing parent catalog during metadata id resolution (#12214)#12408
github-actions[bot] wants to merge 1 commit into
branch-1.3from
cherry-pick-a98f0182-to-branch-1.3

Conversation

@github-actions

Copy link
Copy Markdown

Cherry-pick Information:

  • Original commit: a98f018
  • Target branch: branch-1.3
  • Status: ✅ Clean cherry-pick (no conflicts)

…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
```
@github-actions github-actions Bot added the cherry-pick Automatically opened cherry-pick PR label Aug 10, 2026
@github-actions
github-actions Bot requested a review from jerryshao August 10, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick Automatically opened cherry-pick PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant