Repository navigation
Fixes #30586: return per-entity permissions inline on list endpoint (backport 2.0 #31024) - #36665
Conversation
…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)
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
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 |
…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.
| /** | ||
| * 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, | ||
| }; |
There was a problem hiding this comment.
⚠️ 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:
testCaseEditPermissionisundefined || EditAll(false), so Edit is disabled.- Restore of soft-deleted cases is disabled.
- Incident status cannot be changed, because
hasEditPermissionis 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 👍 / 👎
Code Review
|
| Compact |
|
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source
|
|



Describe your changes:
Backport of #31024 to
2.0: cherry-pick ofa57a6994ef8(git cherry-pick -x). Fixes #30586 on2.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 runs2.0.x, which does not have #31024; it first shipped in2.1.0-rc1.GET .../testCases/search/list?includePermissions=truereturns each row'sResourcePermissioninentityPermissions, keyed by id, throughPagePermissionsResolver. The/data-quality/test-casespage and the table Quality tab ask for it and pass the map toDataQualityTab, so those pages no longer send one permission request per row. Without the flag, responses are unchanged.Conflicts resolved:
DataQualityTab.tsx: same behaviour asmain: row permissions come from the list response only, with no per-row fetch. As onmain,TestSuiteDetailsPagedoes not requestincludePermissions, so its rows get no per-row permissions; that page is unchanged frommainand is not part of this backport.permissionQueryKeys) is dropped:2.0has nopermissionQueryKeys, and its permission provider does not read from that cache.getDerivedPermissionFlags(not on2.0) is not imported;2.0'sgetPrioritizedEditPermissionstays.observability/DataQuality/TestCases/TestCases.tsx(the app-mode tab) does not exist on2.0; its change is dropped.DataQualityTab.test.tsx: same tests asmain.EntityResource,PagePermissionsResolver,ResultList,PermissionsResourceIT) applied without conflicts.Type of change:
Tests:
Unit tests
yarn test src/components/Database/Profiler/DataQualityTab src/components/Database/Profiler/TableProfiler src/components/DataQuality/TestCases src/pages/TestSuiteDetailsPage, with the2.0dependencies: 21 of 22 suites passed (353 tests passed, 2 skipped). The one failing suite,ProfilerClassBase.test.ts, fails to start because the generatedjsons/ingestionSchemasare missing in this checkout. This PR does not touch it.2.0DataQualityTab.tsxwithout 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 -amon 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 on2.0already (user-factory and DataConsumer/DataSteward fixtures). The 3 tests this PR adds passed:testListEntitiesWithPermissions_adminGetsInlinePermissions,_nonAdminGetsReducedPermissions,_paginationRemainsIntact.Playwright (UI) tests
2.0.Manual testing performed
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).2.0.UI screen recording:
Not applicable: backport of a performance fix with no visual change.
Checklist:
🤖 Generated with Claude Code