Skip to content

[#13859] fix(authz): expose inaccessible object tag and policy associations - #13863

Merged
roryqi merged 4 commits into
apache:mainfrom
qqqttt123:fix/issue-13859
Oct 16, 2026
Merged

roryqi merged 4 commits into
apache:mainfrom
qqqttt123:fix/issue-13859

Conversation

@roryqi

@roryqi roryqi commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Add authorization-filtering indicators to metadata object tag and policy list responses:

  • hasInaccessibleTags
  • hasInaccessiblePolicies

The indicators are included in both name and detailed responses. Tag and policy associations are aggregated before authorization filtering so direct and inherited associations follow the same behavior.

Why are the changes needed?

When all associated tags or policies are inaccessible, the APIs currently return an empty list indistinguishable from an object with no associations.

The new fields indicate whether associations were omitted without exposing their names, count, details, or inheritance source.

Fix: #13859

Does this PR introduce any user-facing change?

Yes. The metadata object tag and policy list APIs add boolean fields indicating whether inaccessible associations were omitted.

How was this patch tested?

  • Common response DTO unit tests
  • Metadata object tag and policy REST tests
  • Tag and policy Docker authorization integration tests
  • ./gradlew :docs:build
  • Spotless checks

@mchades mchades left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed e396613. I did not find a concrete functional defect; the inline comments request regression coverage for the new visibility indicators. All 70 focused tests in TestResponses, TestMetadataObjectTagOperations, and TestMetadataObjectPolicyOperations passed locally. Docker authorization tests were not run locally.

throw new AssertionError(error);
});
Assertions.assertEquals(2, nameListResponse.getNames().length);
Assertions.assertTrue(nameListResponse.hasInaccessibleTags());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add an untagged object and an object whose only tag is inherited and inaccessible, asserting empty arrays with false versus true for both response modes. The current assertions only cover mixed visibility, so the empty-array distinction in #13859 remains untested.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in a4c8f52. Added real authorization coverage for both response modes using two distinct objects: an untagged catalog returns empty arrays with hasInaccessibleTags=false, while a table whose only effective tag is inherited and inaccessible returns empty arrays with hasInaccessibleTags=true. TagOperationsAuthorizationIT passes with Docker tests enabled.

MetadataObjectPolicyListResponse details =
(MetadataObjectPolicyListResponse) detailsResponse.getEntity();
Assertions.assertEquals(0, details.getPolicies().length);
Assertions.assertTrue(details.hasInaccessiblePolicies());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add an authorization integration test for this flag. Both the dispatcher and authorization filter are mocked here, and PolicyAuthorizationIT does not call the object policy-list endpoint. Verify all-hidden and mixed-visible tag-derived policies through real authorization, checking the flag and visible arrays in both response modes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in a4c8f52. Added PolicyAuthorizationIT coverage through the real tag-to-policy resolution and authorization path. It verifies all-hidden and mixed-visible results, including both arrays and hasInaccessiblePolicies, for names and details responses. Both PolicyAuthorizationIT and TagOperationsAuthorizationIT pass with Docker tests enabled.

@roryqi
roryqi requested a review from mchades October 15, 2026 08:00
mchades
mchades previously approved these changes Oct 15, 2026
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Code Coverage Report

Overall Project 71.86% +0.19% 🟢
Files changed 89.26% 🟢

Module Coverage
aliyun 19.74% 🔴
api 54.51% +0.13% 🟢
authorization-common 85.96% 🟢
authorization-ranger 14.44% 🔴
aws 53.54% 🟢
aws-bundle 0.0% 🔴
azure 32.1% 🔴
azure-bundle 0.0% 🔴
catalog-common 29.49% 🔴
catalog-fileset 82.37% 🟢
catalog-glue 73.24% 🟢
catalog-hive 83.63% 🟢
catalog-jdbc-common 57.98% 🟢
catalog-jdbc-doris 87.56% 🟢
catalog-jdbc-mysql 81.91% 🟢
catalog-jdbc-postgresql 84.02% 🟢
catalog-jdbc-starrocks 79.16% 🟢
catalog-kafka 75.21% 🟢
catalog-lakehouse-generic 84.58% 🟢
catalog-lakehouse-hudi 79.1% 🟢
catalog-lakehouse-iceberg 85.93% 🟢
catalog-lakehouse-paimon 84.36% 🟢
catalog-model 77.99% 🟢
cli 44.62% 🟢
client-java 79.44% +1.0% 🟢
client-java-runtime 0.0% 🔴
common 60.78% +0.27% 🟢
core 87.47% 🟢
filesystem-hadoop3 76.89% 🟢
flink 55.44% 🟢
flink-common 32.2% 🔴
flink-runtime 0.0% 🔴
gcp 32.2% 🔴
hadoop-auth 68.0% 🟢
hadoop-common 17.84% 🔴
hive-metastore-common 62.3% 🟢
hive-metastore3-libs 58.8% 🟢
iceberg-aliyun-bundle 0.0% 🔴
iceberg-common 66.53% 🟢
iceberg-rest-server 77.08% 🟢
idp-basic 86.77% 🟢
integration-test-common 0.0% 🔴
jobs 71.35% 🟢
k8s-job-executor 99.81% -0.19% 🟢
lance-common 39.9% 🔴
lance-rest-server 69.51% 🟢
lineage 59.39% 🟢
optimizer 84.27% 🟢
optimizer-api 46.58% 🟢
server 91.43% +0.07% 🟢
server-common 83.85% 🟢
spark 61.79% 🟢
tencent 81.78% 🟢
tms 80.0% 🟢
trino-connector 63.31% 🟢
Files
Module File Coverage
api Policy.java 100.0% 🟢
PolicyContents.java 72.97% 🟢
PolicyList.java 0.0% 🔴
SupportsPolicies.java 0.0% 🔴
SupportsTags.java 0.0% 🔴
TagList.java 0.0% 🔴
client-java BaseSchemaCatalog.java 100.0% 🟢
MetadataObjectPolicyOperations.java 100.0% 🟢
MetadataObjectTagOperations.java 100.0% 🟢
RelationalTable.java 95.37% 🟢
GenericSemanticModel.java 91.67% 🟢
GenericTopic.java 79.07% 🟢
GenericFileset.java 77.08% 🟢
GenericColumn.java 75.0% 🟢
GenericSchema.java 72.97% 🟢
GenericView.java 72.22% 🟢
GenericFunction.java 70.97% 🟢
GenericModel.java 45.0% 🔴
common NameListResponse.java 93.33% 🟢
TagListResponse.java 92.86% 🟢
MetadataObjectPolicyListResponse.java 88.89% 🟢
MetadataObjectTagListResponse.java 88.89% 🟢
PolicyNameListResponse.java 88.89% 🟢
TagNameListResponse.java 88.89% 🟢
PolicyListResponse.java 72.22% 🟢
k8s-job-executor K8sJobExecutorConfigs.java 100.0% 🟢
K8sJobResourceUtils.java 100.0% 🟢
SparkApplicationUtils.java 100.0% 🟢
SparkApplicationStatusUtils.java 99.44% 🟢
server MetadataObjectPolicyOperations.java 94.12% 🟢
MetadataObjectTagOperations.java 93.33% 🟢

@mchades mchades left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two additional gaps in client access and user documentation for the new association visibility indicators.

*
* @return true if at least one inaccessible tag was omitted, false otherwise
*/
public boolean hasInaccessibleTags() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The public Java SupportsTags/SupportsPolicies methods and Python tag methods still return only arrays/lists, so SDK callers still cannot distinguish no associations from all-inaccessible associations. The new tests read the DTOs through RESTClient directly. Please add backward-compatible public APIs exposing the visible items and the corresponding flag, with tests through those APIs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in fa15ab2. Added backward-compatible Java APIs returning TagList/PolicyList with the visible items and inaccessible-association indicator, while keeping the existing array-returning methods unchanged. Added the equivalent Python TagList APIs for tags. The authorization tests now exercise these public APIs instead of reading REST DTOs directly, and client unit tests cover the compatibility defaults and propagated flags.

Comment thread docs/open-api/tags.yaml
properties:
hasInaccessibleTags:
type: boolean
description: Whether one or more inaccessible tags were omitted from the response

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also update docs/manage-tags-in-gravitino.md and docs/manage-policies-in-gravitino.md. OpenAPI now describes the fields, but the user guides do not explain them. Document the four list/flag combinations, include an all-inaccessible response example, explain inherited associations, and show how users can read the indicators through the supported APIs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in fa15ab2. Updated both management guides to document the four visible-list/indicator combinations, all-inaccessible response examples, inherited association behavior before authorization filtering, and the supported Java and Python APIs. The documentation build passes.

roryqi added a commit that referenced this pull request Oct 15, 2026
…object tag and policy associations (#13863) (#13878)

### What changes were proposed in this pull request?

Backport #13863 to branch-1.3.

Add authorization-filtering indicators to metadata object tag and policy
list responses:

- `hasInaccessibleTags`
- `hasInaccessiblePolicies`

The indicators are included in both name and detailed responses. Direct
and inherited associations are aggregated before authorization
filtering.

### Why are the changes needed?

When all associated tags or policies are inaccessible, the APIs
currently return an empty list indistinguishable from an object with no
associations.

The new fields indicate whether associations were omitted without
exposing their names, count, details, or inheritance source.

Fix: #13859

### Does this PR introduce _any_ user-facing change?

Yes. Metadata object tag and policy list responses add boolean fields
indicating whether inaccessible associations were omitted.

### How was this patch tested?

- Common response DTO unit tests
- Metadata object tag and policy REST tests
- Metadata authorization helper tests
- Tag and policy Docker authorization integration tests
- `./gradlew :docs:build`
- Spotless checks

@mchades mchades left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed fa15ab2. The public SDK APIs and user guides address the previous SDK/docs comments. The 48 focused Java client tests, API Javadoc, formatting checks, and OpenAPI build pass locally. The Python tag suite has two reproducible fixture errors noted inline. Docker authorization tests were not run locally.

Comment on lines +611 to +615
with patch(
"gravitino.utils.http_client.HTTPClient.get",
return_value=mock_base.mock_http_response(response.to_json()),
):
tag_list = fileset.list_tags_with_visibility()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Supply an HTTP client to the visibility-test fixture

@mock_base.mock_data returns a GenericFileset constructed with rest_client=None. Consequently, this test and test_fileset_list_tags_info_with_visibility fail with AttributeError: 'NoneType' object has no attribute 'get' before reaching the patched HTTPClient.get. Both failures reproduce with python -m unittest tests.unittests.test_tag_api. Please provide an HTTP client in these fixtures so the tests exercise response parsing and flag propagation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 548bb95. The shared fileset fixture now constructs GenericFileset with a real HTTPClient, so both visibility tests reach the patched HTTPClient.get and exercise response parsing and flag propagation. Verified with python3 -m unittest tests.unittests.test_tag_api: all 30 tests pass.

@roryqi

roryqi commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

Hi @mchades, the latest review feedback has been addressed in 548bb95. The shared fileset fixture now uses a real HTTPClient, and python3 -m unittest tests.unittests.test_tag_api passes all 30 tests. Could you please take another look when you have time? Thanks!

roryqi added a commit that referenced this pull request Oct 16, 2026
…object tag and policy associations (#13889)

### What changes were proposed in this pull request?

Backport #13863 to branch-1.3.

- Add `hasInaccessibleTags` and `hasInaccessiblePolicies` to
metadata-object name and detail list responses.
- Add backward-compatible Java visibility APIs using `TagList` and
`PolicyList`, plus the equivalent Python tag APIs.
- Preserve branch-1.3's direct policy-association APIs while applying
authorization filtering consistently to direct and inherited
associations.
- Add SDK, authorization, response DTO, OpenAPI, and user-guide
coverage.

### Why are the changes needed?

When all associated tags or policies are inaccessible, an empty list is
indistinguishable from an object with no associations. The new
indicators report that associations were omitted without exposing their
names, counts, details, or inheritance sources.

Fix: #13859

### Does this PR introduce _any_ user-facing change?

Yes. Tag and policy list responses expose `hasInaccessibleTags` and
`hasInaccessiblePolicies`. Java and Python clients add
backward-compatible APIs that return visible items together with these
indicators.

### How was this patch tested?

- `./gradlew :api:build -x :api:test
:clients:client-java:compileTestJava`
- `./gradlew :clients:client-java:test --tests
org.apache.gravitino.client.TestSupportTags --tests
org.apache.gravitino.client.TestSupportPolicies`
- `python3 -m unittest tests.unittests.test_tag_api` (29 tests passed)
- `./gradlew :docs:build`
- Spotless checks
- Authorization Docker ITs were attempted, but both stopped during Hive
container initialization because the mapped ports timed out before test
execution.
@roryqi
roryqi merged commit 95ce9f5 into apache:main Oct 16, 2026
51 of 52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug report] Object tag and policy lists cannot distinguish absent from inaccessible associations

2 participants