Skip to content

Fixes #30586: return per-entity permissions inline on list endpoint (backport 2.0 #31024) - #36665

Merged
ShaileshParmar11 merged 2 commits into
2.0from
backport/2.0/pr-31024
Oct 30, 2026
Merged

ShaileshParmar11 merged 2 commits into
2.0from
backport/2.0/pr-31024

Conversation

@ShaileshParmar11

@ShaileshParmar11 ShaileshParmar11 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Backport of #31024 to 2.0: cherry-pick of a57a6994ef8 (git cherry-pick -x). Fixes #30586 on 2.0, and the production Sentry alert COLLATE-FRONTEND-2C ("Inefficient HTTP Requests" on /data-quality/test-cases: about 10 sequential permission GETs, one per test case, after the list search). Production runs 2.0.x, which does not have #31024; it first shipped in 2.1.0-rc1.

GET .../testCases/search/list?includePermissions=true returns each row's ResourcePermission in entityPermissions, keyed by id, through PagePermissionsResolver. The /data-quality/test-cases page and the table Quality tab ask for it and pass the map to DataQualityTab, so those pages no longer send one permission request per row. Without the flag, responses are unchanged.

Conflicts resolved:

  • DataQualityTab.tsx: same behaviour as main: row permissions come from the list response only, with no per-row fetch. As on main, TestSuiteDetailsPage does not request includePermissions, so its rows get no per-row permissions; that page is unchanged from main and is not part of this backport.
  • The React Query write of the inline permission (permissionQueryKeys) is dropped: 2.0 has no permissionQueryKeys, and its permission provider does not read from that cache. getDerivedPermissionFlags (not on 2.0) is not imported; 2.0's getPrioritizedEditPermission stays.
  • observability/DataQuality/TestCases/TestCases.tsx (the app-mode tab) does not exist on 2.0; its change is dropped.
  • DataQualityTab.test.tsx: same tests as main.
  • Backend (EntityResource, PagePermissionsResolver, ResultList, PermissionsResourceIT) applied without conflicts.

Type of change:

  • Bug fix

Tests:

Unit tests

  • yarn test src/components/Database/Profiler/DataQualityTab src/components/Database/Profiler/TableProfiler src/components/DataQuality/TestCases src/pages/TestSuiteDetailsPage, with the 2.0 dependencies: 21 of 22 suites passed (353 tests passed, 2 skipped). The one failing suite, ProfilerClassBase.test.ts, fails to start because the generated jsons/ingestionSchemas are missing in this checkout. This PR does not touch it.
  • Against the 2.0 DataQualityTab.tsx without this change, the 2 inline-permission tests fail (the tab always fetched per row).

Backend integration tests

  • mvn spotless:check -pl openmetadata-spec,openmetadata-service,openmetadata-integration-tests: passed.
  • mvn -DskipTests -DonlyBackend install -pl openmetadata-integration-tests -am on this branch: BUILD SUCCESS.
  • mvn test -pl openmetadata-integration-tests -Dtest=PermissionsResourceIT (testcontainers): 17 run, 0 failures, 0 errors, 4 skipped. The skipped tests are disabled on 2.0 already (user-factory and DataConsumer/DataSteward fixtures). The 3 tests this PR adds passed: testListEntitiesWithPermissions_adminGetsInlinePermissions, _nonAdminGetsReducedPermissions, _paginationRemainsIntact.
  • Other Java ITs not run.

Playwright (UI) tests

  • Not run on 2.0.

Manual testing performed

  • The CI checkstyle sequence (organize-imports, eslint --fix, prettier --write) on the changed UI files: 0 ESLint errors; Prettier reflowed one line in the test.
  • tsc --noEmit: no errors in the changed files. Its other errors are in existing files this PR does not touch (e.g. useTestCaseFilterOptions.tsx, TableProfilerUtils.test.ts).
  • Not checked in a running app on 2.0.

UI screen recording:

Not applicable: backport of a performance fix with no visual change.

Checklist:

  • I have read the CONTRIBUTING document.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • Decision check: no decision record needed.

🤖 Generated with Claude Code

…31024)

* Fixes #30586: return per-entity permissions inline on list endpoint

Opt-in ?includePermissions=true on the generic list endpoint attaches each
listed entity's ResourcePermission to ResultList.entityPermissions (keyed by
id, NON_NULL so existing responses are unchanged), computed via the existing
single-entity authorizer path and hooked into all shared list paths including
the search-backed one. The UI reads these from the list response instead of
firing one permission call per row (the data-quality N+1), falling back to the
old per-row fetch when the map is absent.

* docs: design for permission-aware entity pagination (#30586, 2.1)

Captures Harsha's revised direction: filter inaccessible rows in the DB/search
query (before count/cursor) via one shared SpEL->predicate compiler rendered to
both portable SQL EXISTS and the existing OMQueryBuilder, with includePermissions
demoted to an optional sidecar. Grounded in RBACConditionEvaluator, the
entity_relationship/tag_usage schema, and the EntityDAO list/count splice points.
Lists the staging, parity-test plan, and open questions for review before the
security-critical compiler is built.

* Fixes #30586: filter unauthorized rows from permission-aware listing

includePermissions=true now also hides entities the caller may not view, so a
list no longer returns assets the user has no access to.

Pagination is preserved: cursors are (name, id) positions in the table's own
ordering, so dropping rows only shortens a page rather than invalidating the
cursor. listAfterAuthorized/listBeforeAuthorized therefore refill a page by
continuing the scan from the last row consumed, bounded by
MAX_AUTHORIZATION_FILL_BATCHES so a user who may view little cannot scan the
whole table for one page. Each entity's policy is evaluated once and reused by
both the filter and the sidecar.

paging.total stays the unfiltered count (an upper bound) until the DB-side
predicate lands; see docs/plans/permission-aware-pagination.md.

* Address review: sidecar-only permissions, batched authorization load

Drop the in-process row filtering added for includePermissions=true. It had
no consumer -- both UI callers reach listInternalFromSearch, which only
attached the sidecar -- while making a display flag decide which rows a list
returns, on every EntityResource at once. Removing it also removes a refill
loop that dropped the continuation cursor once MAX_AUTHORIZATION_FILL_BATCHES
was exhausted, a paging.total that counted rows the caller could not see, a
view check that diverged from DefaultAuthorizer.authorize on the isReviewer
bypass, an unbounded per-request permission memo, and ~90 lines duplicating
listAfter/listBefore.

includePermissions=true is now purely additive: same rows, same total, plus
an entityPermissions map.

Move the sidecar out of the JAX-RS base into PagePermissionsResolver, which
batch-loads the page once with ResourceContext.authorizationFields and one
BulkFieldHydrator for tags, as LineagePermissionFilter and bulkCreateOrUpdate
already do, instead of re-fetching every row by id. Decision entities are
loaded separately from the response rows so hydrating owners and domains
cannot leak them into the JSON.

UI: fall back per row when the map omits a test case, treat an empty map as
"no answer" rather than "no permissions", re-arm the loading gate so a page
change cannot paint stale permissions, and publish inline permissions under
the shared React Query key so drawers and useEntityPermissions stop
re-fetching them.

Drop the design doc from this PR, and ignore .run/.

* Derive row permissions from the list response only

Addresses two open review threads on the data-quality tab.

Per @chirag-madlani, drop the per-row permission fetch entirely: the list
response is now the only source of row permissions, so neither the whole-page
fallback nor the per-row fallback for map misses remains.

That also closes the P1 race Greptile flagged on the same code. The derivation
is synchronous again, so there is no in-flight request for a superseded page to
resolve late and overwrite the current page's permissions or clear its loading
state. PagePermissionsResolver emits an entry for every row it returns, so a
miss can only mean a row with no id.

Both call sites -- QualityTab and the standalone data-quality page -- already
pass the map. Test props now carry the same grants the removed fetch returned,
and the suite asserts the permission endpoint is never called for any shape of
response: absent, empty, or partial.

* fix(ui): pass entityPermissions to the app-mode data-quality test-case tab

Row permissions now come from the list response only, so a DataQualityTab that
is not given entityPermissions resolves every row to DEFAULT_ENTITY_PERMISSION
and silently loses its edit/delete/status actions. The app-mode observability
test-case tab renders that tab but never passed the map, unlike QualityTab and
the standalone data-quality page.

Reported by the Gitar review on #31024.

---------

Backport to 2.0: DataQualityTab keeps the per-row permission fetch as a
fallback when the caller passes no entityPermissions map. On 2.0,
TestSuiteDetailsPage renders the tab without one, so dropping the fetch
would leave its rows with no edit or delete actions. The React Query
permission cache write is dropped (2.0 has no permissionQueryKeys), and
the app-mode observability TestCases.tsx does not exist on 2.0.

(cherry picked from commit a57a699)
@ShaileshParmar11 ShaileshParmar11 added UI UI specific issues safe to test Add this label to run secure Github workflows on PRs labels Oct 30, 2026
@ShaileshParmar11
ShaileshParmar11 requested review from a team as code owners October 30, 2026 09:15
@ShaileshParmar11
ShaileshParmar11 requested review from anuj-kumary and pmbrull and removed request for a team October 30, 2026 09:15
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

…backport

The test suite table has no row edit or incident-status actions, so it
needs no row permissions. Match main: row permissions come from the list
response only, and the suite page no longer sends one permission request
per row.
Comment on lines +420 to +434
/**
* Row permissions come from the list response only. `PagePermissionsResolver`
* emits an entry for every row it returns, so a miss here means the row
* carries no id and genuinely has no permissions.
*/
const applyInlinePermissions = () => {
const data = testCases.map((testCase) => {
const inline = testCase.id ? entityPermissions?.[testCase.id] : undefined;

return {
...(inline
? getOperationPermissions(inline)
: DEFAULT_ENTITY_PERMISSION),
fullyQualifiedName: testCase.fullyQualifiedName,
};

@gitar-bot gitar-bot Bot Oct 30, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Bug: Test suite page loses per-row Edit/Restore/incident-status permissions

This commit removes the per-row permission fetch. Any row with no entityPermissions entry now gets DEFAULT_ENTITY_PERMISSION, which is all false. TestSuiteDetailsPage (TestSuiteDetailsPage.component.tsx:175-197) passes neither entityPermissions nor isEditAllowed, and its useTestSuiteDetailsPage query does not request includePermissions. The PR says that table has no row edit or incident-status actions, but that is wrong. renderRow always renders renderIncidentCell and renderActionsCell (DataQualityTab.tsx:770-787).

On the test suite page this means:

  • testCaseEditPermission is undefined || EditAll(false), so Edit is disabled.
  • Restore of soft-deleted cases is disabled.
  • Incident status cannot be changed, because hasEditPermission is false.

A user who holds test-case EditAll/EditStatus but not suite-level EditTests used to get these actions from the per-row fetch. On the 2.0 baseline they were fetched for every row, so this is a regression. Fix it by having the test-suite test-case query send includePermissions: true and passing entityPermissions through to DataQualityTab, as TableProfilerProvider and useTestCaseList already do. The other option is to keep the per-row fallback when entityPermissions is undefined.

Request inline permissions on the test suite page and pass them through (alongside adding includePermissions: true to testCaseQueryParams in useTestSuiteDetailsPage):

<DataQualityTab
  afterDeleteAction={fetchTestCases}
  breadcrumbData={incidentUrlState}
  entityPermissions={testCaseEntityPermissions}
  fetchTestCases={handleSortTestCase}
  ...
/>

Was this helpful? React with 👍 / 👎

@gitar-bot

gitar-bot Bot commented Oct 30, 2026

Copy link
Copy Markdown
Code Review ⚠️ Changes requested 0 closed / 1 findings

🟡 Medium risk · Adding opt-in per-row permission resolution to list responses could expose incorrect action grants if entity-context hydration miscomputes policies.

Backports the inline per-entity permissions on the test case list endpoint to stop the N+1 permission GETs on the data quality pages. Changes are requested: the test suite details page no longer fetches per-row permissions and no longer passes entityPermissions or includePermissions, so Edit, Restore, and incident-status actions in DataQualityTab are disabled for users who previously had them. Fix by requesting includePermissions: true for the test suite query and passing the permission map through, or by keeping the per-row fallback when entityPermissions is undefined.

⚠️ Bug: Test suite page loses per-row Edit/Restore/incident-status permissions

📄 openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/DataQualityTab/DataQualityTab.tsx:420-434 📄 openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/DataQualityTab/DataQualityTab.test.tsx:507-521

This commit removes the per-row permission fetch. Any row with no entityPermissions entry now gets DEFAULT_ENTITY_PERMISSION, which is all false. TestSuiteDetailsPage (TestSuiteDetailsPage.component.tsx:175-197) passes neither entityPermissions nor isEditAllowed, and its useTestSuiteDetailsPage query does not request includePermissions. The PR says that table has no row edit or incident-status actions, but that is wrong. renderRow always renders renderIncidentCell and renderActionsCell (DataQualityTab.tsx:770-787).

On the test suite page this means:

  • testCaseEditPermission is undefined || EditAll(false), so Edit is disabled.
  • Restore of soft-deleted cases is disabled.
  • Incident status cannot be changed, because hasEditPermission is false.

A user who holds test-case EditAll/EditStatus but not suite-level EditTests used to get these actions from the per-row fetch. On the 2.0 baseline they were fetched for every row, so this is a regression. Fix it by having the test-suite test-case query send includePermissions: true and passing entityPermissions through to DataQualityTab, as TableProfilerProvider and useTestCaseList already do. The other option is to keep the per-row fallback when entityPermissions is undefined.

Request inline permissions on the test suite page and pass them through (alongside adding includePermissions: true to testCaseQueryParams in useTestSuiteDetailsPage)
<DataQualityTab
  afterDeleteAction={fetchTestCases}
  breadcrumbData={incidentUrlState}
  entityPermissions={testCaseEntityPermissions}
  fetchTestCases={handleSortTestCase}
  ...
/>
🤖 Prompt for agents
Code Review: Backports the inline per-entity permissions on the test case list endpoint to stop the N+1 permission GETs on the data quality pages. Changes are requested: the test suite details page no longer fetches per-row permissions and no longer passes `entityPermissions` or `includePermissions`, so Edit, Restore, and incident-status actions in `DataQualityTab` are disabled for users who previously had them. Fix by requesting `includePermissions: true` for the test suite query and passing the permission map through, or by keeping the per-row fallback when `entityPermissions` is undefined.

1. ⚠️ Bug: Test suite page loses per-row Edit/Restore/incident-status permissions
   Files: openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/DataQualityTab/DataQualityTab.tsx:420-434, openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/DataQualityTab/DataQualityTab.test.tsx:507-521

   This commit removes the per-row permission fetch. Any row with no `entityPermissions` entry now gets `DEFAULT_ENTITY_PERMISSION`, which is all false. `TestSuiteDetailsPage` (TestSuiteDetailsPage.component.tsx:175-197) passes neither `entityPermissions` nor `isEditAllowed`, and its `useTestSuiteDetailsPage` query does not request `includePermissions`. The PR says that table has no row edit or incident-status actions, but that is wrong. `renderRow` always renders `renderIncidentCell` and `renderActionsCell` (DataQualityTab.tsx:770-787).
   
   On the test suite page this means:
   - `testCaseEditPermission` is `undefined || EditAll(false)`, so Edit is disabled.
   - Restore of soft-deleted cases is disabled.
   - Incident status cannot be changed, because `hasEditPermission` is false.
   
   A user who holds test-case EditAll/EditStatus but not suite-level EditTests used to get these actions from the per-row fetch. On the 2.0 baseline they were fetched for every row, so this is a regression. Fix it by having the test-suite test-case query send `includePermissions: true` and passing `entityPermissions` through to `DataQualityTab`, as `TableProfilerProvider` and `useTestCaseList` already do. The other option is to keep the per-row fallback when `entityPermissions` is `undefined`.

   Fix (Request inline permissions on the test suite page and pass them through (alongside adding includePermissions: true to testCaseQueryParams in useTestSuiteDetailsPage)):
   <DataQualityTab
     afterDeleteAction={fetchTestCases}
     breadcrumbData={incidentUrlState}
     entityPermissions={testCaseEntityPermissions}
     fetchTestCases={handleSortTestCase}
     ...
   />

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@github-actions

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 68%
68.52% (83333/121612) 53.49% (51762/96753) 54.18% (15374/28371)

@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

@ShaileshParmar11 ShaileshParmar11 added the skip-pr-checks Bypass PR metadata validation check label Oct 30, 2026
@ShaileshParmar11
ShaileshParmar11 merged commit 59d371e into 2.0 Oct 30, 2026
123 of 131 checks passed
@ShaileshParmar11
ShaileshParmar11 deleted the backport/2.0/pr-31024 branch October 30, 2026 10:47

This branch had an error being deployed

1 failed deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs skip-pr-checks Bypass PR metadata validation check UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants