Skip to content

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

Merged
mohityadav766 merged 8 commits into
mainfrom
fix-issue-30586
Sep 22, 2026
Merged

mohityadav766 merged 8 commits into
mainfrom
fix-issue-30586

Conversation

@mohityadav766

@mohityadav766 mohityadav766 commented Aug 5, 2026 •

Copy link
Copy Markdown
Member

Describe your changes:

Fixes #30586

I added an opt-in ?includePermissions=true query param to the generic entity list/pagination endpoint so it returns each listed entity's permissions inline (ResultList.entityPermissions, keyed by id), instead of the UI firing one /permissions/{resource}/... call per listed row (the data-quality Sentry N+1). Per the design discussion this is deliberately not a separate bulk permission endpoint — the pagination API itself returns the permission set. The field is @JsonInclude(NON_NULL) and only computed when requested, so every existing list response is unchanged.

Type of change:

  • Improvement

High-level design:

  • EntityResource.addPermissions() reads includePermissions from UriInfo (no per-resource method-signature churn) and, when set, computes each entity's ResourcePermission via the existing single-entity authorizer.getPermission(...) path — identical results to /permissions/{resource}/{id}. Hooked into all shared list paths: listInternal (both overloads), searchInternal, and listInternalFromSearch (the search-backed path the test-case data-quality list uses).
  • ResultList<T> gains an optional Map<entityId, ResourcePermission> entityPermissions (hand-written spec class, NON_NULL) — no schema regen, no impact on other endpoints.
  • UI: getListTestCaseBySearch sends the flag; TableProfilerProvider (the /table/*/profiler/data-quality Sentry path) and useTestCaseList (standalone DQ page) thread entityPermissions into the shared DataQualityTab, which derives row permissions from the map. When the map is absent it falls back to the old per-row fetch, so unmigrated callers keep working.
  • Rejected alternative: the bulk /api/v1/entity/permissions?Fqn=... endpoint from the ticket — having the list endpoint return permissions is a smaller surface and removes the client round-trips entirely.

Tests:

Use cases covered

  • Admin lists tables with ?includePermissions=true → each row carries inline permissions (EDIT_ALL allowed); default listing omits the field.
  • Non-admin lists an admin-owned table → inline permissions present but reduced (no EDIT_ALL / DELETE).
  • Data-quality tab renders row actions from the list response with zero per-row permission calls; falls back to per-row fetch when permissions aren't inlined.

Unit tests

  • UI Jest — DataQualityTab.test.tsx: consumes inline map (asserts 0 getEntityPermissionByFqn calls) + fallback path still fires them. Full affected suite: 177 tests pass.

Backend integration tests

  • PermissionsResourceIT — testListEntitiesWithPermissions_adminGetsInlinePermissions, testListEntitiesWithPermissions_nonAdminGetsReducedPermissions (green against testcontainers: 2/2).

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • No new Playwright test — the change is network behavior (fewer calls), not new UI; covered by the Jest tests above.

Manual testing performed

Automated verification: backend IT (2/2 testcontainers), UI tsc clean, 177 Jest tests, prettier / organize-imports / spotless.

UI screen recording / screenshots:

No visual change — the same row actions render; the change only removes N per-row permission API calls (now sourced from the list response). No recording.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: N/A — no JSON Schema changed (ResultList is a hand-written spec class).
  • For UI changes: I attached a screen recording and/or screenshots above. (No visual change — see above.)
  • I have added tests (unit / integration as applicable) and listed them above.
  • I have added tests around the new logic.
  • For connector/ingestion changes: N/A.

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with no outstanding correctness, security, or repository-rule findings.

Findings

  1. P1 Security Committed credentials expose secrets ▶
  2. P2 Run configuration is nonportable ▶
  3. P2 Permission memo is unbounded ▶
Summary

This PR adds an opt-in permission sidecar to entity list responses and updates data-quality views to consume those permissions without issuing one request per row.

  • Adds entityPermissions, keyed by entity ID, to ResultList.
  • Resolves permissions for each returned page through the existing authorization path.
  • Requests and propagates inline permissions through the table-profiler and standalone data-quality flows.
  • Seeds the shared permission-query cache from inline results.
  • Adds backend pagination and authorization coverage plus UI coverage for eliminating per-row permission calls.
Diagram
sequenceDiagram
  participant UI as Data-quality UI
  participant List as Entity list endpoint
  participant Resolver as PagePermissionsResolver
  participant Auth as Authorizer
  UI->>List: "GET list?includePermissions=true"
  List->>Resolver: Resolve permissions for returned rows
  Resolver->>Auth: Evaluate each row for current user
  Auth-->>Resolver: ResourcePermission values
  Resolver-->>List: Map keyed by entity ID
  List-->>UI: data + paging + entityPermissions
  UI->>UI: Derive row actions and seed permission cache
Loading

Reviews (7) · Last reviewed commit: "fix(ui): pass entityPermissions to the a..."

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.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings August 5, 2026 11:37
@mohityadav766
mohityadav766 requested review from a team as code owners August 5, 2026 11:37
@github-actions

github-actions Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

@github-actions github-actions Bot added backend safe to test Add this label to run secure Github workflows on PRs labels Aug 5, 2026

Copilot AI 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.

Pull request overview

This PR adds an opt-in includePermissions=true query parameter to list/pagination APIs so responses can include per-entity ResourcePermission data inline (keyed by entity id). This reduces UI N+1 permission lookups by allowing list views (notably Data Quality test case lists) to render row-level actions without issuing one permission request per row.

Changes:

  • Backend: Extend ResultList<T> with optional entityPermissions and populate it from shared list paths in EntityResource when includePermissions=true.
  • UI: Thread entityPermissions through Data Quality list flows and update DataQualityTab to consume inline permissions, falling back to per-row fetch when absent.
  • Tests: Add/adjust backend IT coverage for inline permissions and UI Jest coverage for inline vs fallback behavior.

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated no comments.

Show a summary per file
File Description
openmetadata-ui/src/main/resources/ui/src/rest/testAPI.ts Adds includePermissions to test-case list params so callers can request inline permissions.
openmetadata-ui/src/main/resources/ui/src/interface/types.d.ts Extends PagingResponse to optionally include entityPermissions keyed by entity id.
openmetadata-ui/src/main/resources/ui/src/components/DataQuality/TestCases/useTestCaseListPage.tsx Exposes entityPermissions from the list hook to the page.
openmetadata-ui/src/main/resources/ui/src/components/DataQuality/TestCases/useTestCaseList.ts Requests includePermissions=true, stores returned permissions map, and returns it to consumers.
openmetadata-ui/src/main/resources/ui/src/components/DataQuality/TestCases/TestCases.component.tsx Passes inline entityPermissions down to the shared DataQualityTab.
openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/TableProfiler/TableProfilerProvider.tsx Requests inline permissions for test-case listings and stores them in provider state.
openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/TableProfiler/TableProfilerProvider.test.tsx Updates expectations to include includePermissions: true in list calls.
openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/TableProfiler/TableProfiler.interface.ts Adds optional allTestCasesPermissions to the provider context.
openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/TableProfiler/QualityTab/QualityTab.component.tsx Passes inline permissions map to DataQualityTab.
openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/ProfilerDashboard/profilerDashboard.interface.ts Adds optional entityPermissions prop to DataQualityTabProps.
openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/DataQualityTab/DataQualityTab.tsx Uses inline permissions (via PermissionsUtils) when provided; otherwise falls back to per-row fetch.
openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/DataQualityTab/DataQualityTab.test.tsx Adds tests asserting zero per-row permission calls when inline permissions are provided, and fallback behavior otherwise.
openmetadata-spec/src/main/java/org/openmetadata/schema/utils/ResultList.java Adds optional entityPermissions to list responses (already class-level NON_NULL JSON include).
openmetadata-service/src/main/java/org/openmetadata/service/resources/EntityResource.java Implements includePermissions behavior across shared list paths.
openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/PermissionsResourceIT.java Adds integration tests validating inline permissions for admin vs non-admin and default omission.

@github-actions

github-actions Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ UI Checkstyle passed — lint findings in changed files

🔍 ESLint findings in this PR's files — 0 error(s), 30 warning(s)

Errors block the build. Warnings do not yet — they are rules whose backlog is still
being worked down, listed so this PR does not add to it. See docs/ui-code-quality-gate.md.

0 error(s), 30 warning(s) across 9 changed file(s).

Count Rule
13 react-hooks/exhaustive-deps
10 openmetadata-imports/no-lower-layer-page-imports
4 openmetadata-imports/no-circular-imports
2 no-restricted-imports
1 openmetadata-imports/no-rest-ui-imports
All findings
Location Rule Message
🟡 src/components/DataQuality/TestCases/TestCases.component.tsx:27:1 openmetadata-imports/no-lower-layer-page-imports Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here.
🟡 src/components/DataQuality/TestCases/TestCases.component.tsx:28:1 openmetadata-imports/no-lower-layer-page-imports Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here.
🟡 src/components/DataQuality/TestCases/TestCases.component.tsx:40:1 openmetadata-imports/no-circular-imports This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency.
🟡 src/components/DataQuality/TestCases/useTestCaseList.ts:34:1 openmetadata-imports/no-lower-layer-page-imports Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here.
🟡 src/components/DataQuality/TestCases/useTestCaseList.ts:40:10 no-restricted-imports 'getPrioritizedViewPermission' import from '../../../utils/PermissionsUtils' is restricted from being used by a pattern. getPrioritizedEditPermission/getPriorit
🟡 src/components/DataQuality/TestCases/useTestCaseList.ts:238:6 react-hooks/exhaustive-deps React Hook useEffect has a missing dependency: 'getTestCases'. Either include it or remove the dependency array.
🟡 src/components/DataQuality/TestCases/useTestCaseListPage.tsx:20:1 openmetadata-imports/no-circular-imports This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency.
🟡 src/components/DataQuality/TestCases/useTestCaseListPage.tsx:20:1 openmetadata-imports/no-lower-layer-page-imports Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here.
🟡 src/components/DataQuality/TestCases/useTestCaseListPage.tsx:21:1 openmetadata-imports/no-lower-layer-page-imports Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here.
🟡 src/components/DataQuality/TestCases/useTestCaseListPage.tsx:22:1 openmetadata-imports/no-lower-layer-page-imports Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here.
🟡 src/components/Database/Profiler/DataQualityTab/DataQualityTab.tsx:49:1 openmetadata-imports/no-lower-layer-page-imports Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here.
🟡 src/components/Database/Profiler/DataQualityTab/DataQualityTab.tsx:499:6 react-hooks/exhaustive-deps React Hook useEffect has missing dependencies: 'applyInlinePermissions' and 'collectInlineIncidentStatuses'. Either include them or remove the dependency array.
🟡 src/components/Database/Profiler/ProfilerDashboard/profilerDashboard.interface.ts:24:1 openmetadata-imports/no-circular-imports This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency.
🟡 src/components/Database/Profiler/TableProfiler/QualityTab/QualityTab.component.tsx:48:3 no-restricted-imports 'getPrioritizedEditPermission' import from '../../../../../utils/PermissionsUtils' is restricted from being used by a pattern. getPrioritizedEditPermission/getP
🟡 src/components/Database/Profiler/TableProfiler/QualityTab/QualityTab.component.tsx:100:6 react-hooks/exhaustive-deps React Hook useMemo has an unnecessary dependency: 'getPrioritizedEditPermission'. Either exclude it or remove the dependency array. Outer scope values like 'get
🟡 src/components/Database/Profiler/TableProfiler/QualityTab/QualityTab.component.tsx:179:6 react-hooks/exhaustive-deps React Hook useMemo has a missing dependency: 't'. Either include it or remove the dependency array.
🟡 src/components/Database/Profiler/TableProfiler/QualityTab/QualityTab.component.tsx:199:6 react-hooks/exhaustive-deps React Hook useEffect has a missing dependency: 'fetchIngestionPipelineCount'. Either include it or remove the dependency array.
🟡 src/components/Database/Profiler/TableProfiler/QualityTab/QualityTab.component.tsx:201:9 react-hooks/exhaustive-deps The 'handleTestCasePageChange' function makes the dependencies of useMemo Hook (at line 351) change on every render. Move it inside the useMemo callback. Altern
🟡 src/components/Database/Profiler/TableProfiler/QualityTab/QualityTab.component.tsx:328:5 react-hooks/exhaustive-deps React Hook useMemo has missing dependencies: 'paging.total' and 't'. Either include them or remove the dependency array.
🟡 src/components/Database/Profiler/TableProfiler/TableProfilerProvider.tsx:204:6 react-hooks/exhaustive-deps React Hook useMemo has a missing dependency: 'getProfileSampleValue'. Either include it or remove the dependency array.
🟡 src/components/Database/Profiler/TableProfiler/TableProfilerProvider.tsx:229:5 react-hooks/exhaustive-deps React Hook useCallback has an unnecessary dependency: 'allTestCases'. Either exclude it or remove the dependency array.
🟡 src/components/Database/Profiler/TableProfiler/TableProfilerProvider.tsx:334:6 react-hooks/exhaustive-deps React Hook useEffect has missing dependencies: 'fetchLatestProfilerData', 'isTableDeleted', and 'tableProfiler'. Either include them or remove the dependency ar
🟡 src/components/Database/Profiler/TableProfiler/TableProfilerProvider.tsx:346:6 react-hooks/exhaustive-deps React Hook useEffect has a missing dependency: 'fetchAllTests'. Either include it or remove the dependency array.
🟡 src/components/Database/Profiler/TableProfiler/TableProfilerProvider.tsx:372:6 react-hooks/exhaustive-deps React Hook useEffect has a missing dependency: 'fetchTestCaseSummary'. Either include it or remove the dependency array.
🟡 src/components/Database/Profiler/TableProfiler/TableProfilerProvider.tsx:396:6 react-hooks/exhaustive-deps React Hook useMemo has a missing dependency: 'fetchAllTests'. Either include it or remove the dependency array.
🟡 src/components/observability/DataQuality/TestCases/TestCases.tsx:18:1 openmetadata-imports/no-lower-layer-page-imports Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here.
🟡 src/components/observability/DataQuality/TestCases/TestCases.tsx:19:1 openmetadata-imports/no-lower-layer-page-imports Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here.
🟡 src/rest/testAPI.ts:47:1 openmetadata-imports/no-circular-imports This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency.
🟡 src/rest/testAPI.ts:47:1 openmetadata-imports/no-lower-layer-page-imports Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here.
🟡 src/rest/testAPI.ts:47:1 openmetadata-imports/no-rest-ui-imports REST clients must not import UI or state-layer modules. Move shared request/response types to the interface layer.

Fix locally (fast - only checks files changed in this branch):

make ui-checkstyle-changed

@github-actions

github-actions Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 72%
72.39% (103351/142754) 57.51% (62957/109459) 58.54% (20598/35182)

if (entityPermissions) {
applyInlinePermissions();
} else {
fetchTestCasePermissions();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We can eliminate fetch cll as we don't want that now

@github-actions

github-actions Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit e37b3fe3fbe2c7b6672e7ed5569c16e33b6ce429 in Playwright run 35693018475, attempt 1.

✅ 4506 passed · ❌ 0 failed · 🟡 6 flaky · ⏭️ 1 skipped · 🧰 0 lifecycle flaky

Performance

Blocking targets: ✅ met · Optimization targets: 🟡 in progress

Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting.

🕒 Full workflow signal wall (to summary) 56m 24s

⏱️ Max setup 7m 11s · max shard execution 21m 49s · max shard-job elapsed before upload 28m 58s · reporting 21s

🌐 224.63 requests/attempt · 2.23 app boots/UI scenario · 25.52% common-shard skew

Optimization targets still in progress:

  • Common shard skew was 25.52% (convergence target: at most 15%).
  • Browser traffic was 224.63 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.23 per UI scenario (10725 boots / 4805 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
🟡 Shard advanced-search-01 129 0 1 0 0 0
🟡 Shard chromium-01 133 0 1 0 0 0
✅ Shard chromium-02 141 0 0 0 0 0
✅ Shard chromium-03 162 0 0 0 0 0
✅ Shard chromium-04 151 0 0 0 0 0
✅ Shard chromium-05 169 0 0 0 0 0
✅ Shard chromium-06 164 0 0 0 0 0
✅ Shard chromium-07 180 0 0 0 0 0
✅ Shard chromium-08 191 0 0 0 0 0
✅ Shard chromium-09 180 0 0 0 0 0
✅ Shard chromium-10 181 0 0 0 0 0
✅ Shard chromium-11 203 0 0 0 0 0
✅ Shard chromium-12 163 0 0 0 0 0
✅ Shard chromium-13 149 0 0 0 0 0
✅ Shard chromium-14 218 0 0 0 0 0
✅ Shard chromium-15 180 0 0 0 0 0
✅ Shard chromium-16 180 0 0 1 0 0
🟡 Shard chromium-17 187 0 1 0 0 0
✅ Shard chromium-18 163 0 0 0 0 0
🟡 Shard chromium-19 149 0 1 0 0 0
✅ Shard chromium-20 166 0 0 0 0 0
✅ Shard chromium-21 166 0 0 0 0 0
🟡 Shard chromium-22 184 0 1 0 0 0
✅ Shard chromium-23 173 0 0 0 0 0
✅ Shard data-asset-rules-01 65 0 0 0 0 0
✅ Shard domain-isolation-01 16 0 0 0 0 0
✅ Shard global-state-01 34 0 0 0 0 0
✅ Shard import-export-01 67 0 0 0 0 0
✅ Shard import-export-02 83 0 0 0 0 0
✅ Shard ingestion-01 50 0 0 0 0 0
🟡 Shard ingestion-02 48 0 1 0 0 0
✅ Shard reindex-01 40 0 0 0 0 0
✅ Shard search-01 12 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0
🟡 6 flaky test(s) (passed on retry)
  • Features/AdvancedSearch.spec.ts › Verify Rule functionality for field Tier with OR operator (shard advanced-search-01, 1 retry)
  • Features/AIMode/CustomPropertiesPanel.spec.ts › deletes a custom property via the confirmation modal (shard chromium-01, 1 retry)
  • Pages/LoginConfiguration.spec.ts › update login configuration should work (shard chromium-17, 1 retry)
  • Pages/DataContracts.spec.ts › Create Data Contract and validate for SearchIndex (shard chromium-19, 1 retry)
  • Pages/ExplorePageRightPanel_KnowledgeCenter.spec.ts › Should remove user owner for knowledgeCenter (shard chromium-22, 1 retry)
  • Features/IncidentManager.spec.ts › Complete Incident lifecycle with table owner (shard ingestion-02, 1 retry)

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

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.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings August 5, 2026 16:13
private final class ListPermissionEvaluator {
private final SecurityContext securityContext;
private final String user;
private final Map<String, ResourcePermission> evaluated = new LinkedHashMap<>();

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 Permission memo is unbounded

This LinkedHashMap is used as a permission memo but has no explicit entry limit. That violates the repository directive that every cache must have an explicit size cap. This requirement must be satisfied before merging by using a fixed maximum or an approved bounded cache implementation.

Context Used: CLAUDE.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

mohityadav766 and others added 2 commits September 21, 2026 22:28
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/.
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.
…e 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.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@gitar-bot

gitar-bot Bot commented Sep 22, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 4 closed / 4 findings

🔴 High risk · Generic list endpoints now expose per-entity authorization permissions to clients

Adds opt-in ?includePermissions=true query parameter to entity list endpoints, returning each entity's permissions inline in the response instead of requiring one API call per row. Backend integration tests confirm admin and non-admin permission resolution; UI data-quality views now consume the inlined permissions map with fallback to per-row fetches for unmigrated callers. No open issues.

✅ 4 closed
✅ Performance: includePermissions triggers per-entity get-by-id (backend N+1)

📄 openmetadata-service/src/main/java/org/openmetadata/service/resources/EntityResource.java:201-215
computeEntityPermissions() loops over each listed entity and calls authorizer.getPermission() with new ResourceContext<>(entityType, id, null). For non-admin users this resolves the entity via entityRepository.get(...) per row (owners/tags/domains needed for conditional rules), so a list of N rows incurs N extra get-by-id lookups even though the entities were already loaded by the list/search query. This moves the UI's N+1 onto the backend rather than eliminating it, and can be costly for larger page sizes. Consider reusing the already-loaded list entities via ResourceContext(resource, entity, repository) once their permission-relevant fields (owners/tags/domains) are guaranteed loaded, or fetching those fields in a single batched query.

✅ Edge Case: Inline path silently yields no-permission rows for map misses

📄 openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/DataQualityTab/DataQualityTab.tsx:410-424 📄 openmetadata-service/src/main/java/org/openmetadata/service/resources/EntityResource.java:201-212
applyInlinePermissions() falls back to DEFAULT_ENTITY_PERMISSION (all false) for any testCase whose id is absent from entityPermissions (e.g. backend skips entities with null id in computeEntityPermissions). Because the fallback to the per-row fetch only occurs when the whole entityPermissions object is undefined, a present-but-partial map will render those rows with all actions disabled rather than fetching real permissions. Low likelihood since listed entities normally have ids, but worth guarding if a row can be missing from the map.

✅ Bug: Bounded refill drops reachable authorized rows from paging

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java:2540-2542 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java:2559-2573 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java:2735-2749
In collectAuthorizedAfter the scan stops after MAX_AUTHORIZATION_FILL_BATCHES (10) batches of limit+1 rows. When a caller's viewable rows are sparse but spread beyond that window (e.g. one authorized row, then many hidden rows, then more authorized rows further down), the loop exits with authorized.size() <= limitParam even though the table is not exhausted (jsons.size() == wanted on every batch). Back in listAfterAuthorized, the entities.size() > limitParam guard is then false, so afterCursor stays null — the client reads that as end-of-pagination and the still-authorized rows past the scan window become unreachable. collectAuthorizedBefore/listBeforeAuthorized have the same shape. The pagination IT only exercises an admin who can view every row, so this path is untested. This is a silent visibility loss, distinct from the acknowledged paging.total upper-bound gap noted in the design doc.

✅ Bug: App-mode DQ test cases lose all row permissions

📄 openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/DataQualityTab/DataQualityTab.tsx:477-491
This commit removes the per-row permission fallback (fetchTestCasePermissions/fetchPermissionByFqn) from DataQualityTab; applyInlinePermissions now assigns DEFAULT_ENTITY_PERMISSION (all-false) to any row whose id is missing from the entityPermissions prop. The app-mode observability page observability/DataQuality/TestCases/TestCases.tsx renders the modified Profiler DataQualityTab but does NOT pass entityPermissions (it destructures many fields from useTestCaseListPage() but omits it), unlike the classic DataQuality/TestCases/TestCases.component.tsx which passes entityPermissions={entityPermissions}. As a result every row on this page now resolves to no permissions, so edit/delete/status-update row actions silently disappear where they previously worked via the fetch fallback. Thread entityPermissions from the hook into the component.

Review coverage

📋 Rules No rules evaluated

🧪 Functional validation Not enabled · Set up

🤖 Auto-approval Not enabled · Set up

Options

Display: compact → Counting what did not apply, without listing it.

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

@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

This branch was previously deployed

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

Labels

backend safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BE - Need bulk api for permission fetch

4 participants