Skip to content

Fixes #32413: gate CustomPropertiesPanel on type resource permissions - #33280

Merged
Rohit0301 merged 13 commits into
mainfrom
custom-properties-panel-fix-plan
Sep 16, 2026
Merged

Rohit0301 merged 13 commits into
mainfrom
custom-properties-panel-fix-plan

Conversation

@Rohit0301

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #32413

The AI-mode Custom Properties panel (CustomPropertiesPanel) was gating all entity-type cards and the sidebar nav item on isAdminUser, ignoring the backend's policy-engine permission on the type resource. Non-admin users with a valid type-resource policy could call PUT /api/v1/metadata/types/{id} successfully via the API but saw an empty panel in the UI.

Additionally, CustomPropertiesDetailPage read permission[Operation.EditAll] directly (raw access, banned by openmetadata-permissions/no-raw-permission-access) and collapsed all three actions into one flag, mismatching the backend's per-operation authorization.

Changes (AI-mode panel only — legacy Settings route untouched):

  • CustomPropertiesLandingPage.tsx / CustomPropertiesPanel.tsx: Replace isAdminUser-based filter with userPermissions.hasViewPermissions(ResourceEntity.TYPE, permissions). Users with ViewAll or ViewBasic on type see all entity-type cards; others see nothing.
  • ProfilePage.tsx: Gate WORKSPACE_NAV_ITEMS (the "Custom Properties" sidebar entry) on the same permission, so users without type view access never see the nav item.
  • CustomPropertiesDetailPage.tsx: Replace raw permission[Operation.EditAll] with getDerivedPermissionFlags(permission) and split into three semantically correct flags — canCreate || canEditAll for Add, canEditAll for Edit, canDelete || canEditAll for Delete — matching what TypeResource evaluates on the backend.

Type of change:

  • Bug fix

High-level design:

The backend authorizes custom property management via MetadataOperation.CREATE on the type resource (TypeResource.addOrUpdateProperty). The type resource is entirely separate from data-entity resources (Table, Dashboard, etc.) — EditAll on Table does not grant any permission on type.

The fix has two layers:

  1. Visibility gate (ProfilePage + CustomPropertiesLandingPage + CustomPropertiesPanel): uses userPermissions.hasViewPermissions(ResourceEntity.TYPE, permissions) — the same utility already used for Services, Teams, and other settings categories — to control whether the nav item and entity cards render.
  2. Action gate (CustomPropertiesDetailPage): getEntityPermission(ResourceEntity.TYPE, entityType.id) already fetched the correctly-scoped OperationPermission; getDerivedPermissionFlags derives named flags from it without needing the resource type again. Three flags replace the single hasEditPermission boolean.

No legacy code (GlobalSettingsClassBase, SettingsRouter, CustomPropertiesPageV1) was changed.

Tests:

Use cases covered

  • Non-admin user with no type permissions → "Custom Properties" nav item absent from AI profile sidebar
  • Non-admin user with [Create, Delete, EditAll, ViewAll] on type → nav visible, all entity-type cards shown, Add + Edit + Delete buttons visible on Table detail page
  • Admin user → all existing CRUD flows unchanged (add String/Date/ERL, edit display name, delete via modal)
  • User with ViewAll only on type (read-only) → nav visible, landing shows cards, zero action buttons (documented in plan; manual-verified scenario)
  • User with EditAll on Table data resource but no type write permissions → no action buttons (data-resource grants do not bleed into type-resource checks)

Unit tests

  • Not added — permission derivation logic is covered by existing PermissionDerivation.test.ts; the UI wiring is exercised by the Playwright tests below.

Backend integration tests

  • Not applicable (no backend changes)

Ingestion integration tests

  • Not applicable (no ingestion changes)

Playwright (UI) tests

  • Added Playwright E2E tests
  • File: openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/AIMode/CustomPropertiesPanel.spec.ts
  • New describe blocks:
    • Custom Properties Panel — user without type permissions (dataConsumer storageState)
    • Custom Properties Panel — non-admin user with type permissions (creates policy/role/user via admin API in beforeAll, tears down in afterAll)

Manual testing performed

  1. Created a role with policy: Resources: type, Operations: [Create, Delete, EditAll, ViewAll], Effect: Allow
  2. Assigned role to a non-admin user; logged in as that user in AI mode
  3. Confirmed "Custom Properties" nav item appeared in the AI profile sidebar
  4. Opened landing page — all entity-type cards (Table, Dashboard, Pipeline, …) rendered
  5. Navigated to Table detail — Add, Edit, Delete buttons all visible; existing CRUD operations worked
  6. Logged in as a user with EditAll on Table + ViewAll on All (no type write) — nav visible, detail page accessible, zero action buttons confirmed
  7. Logged in as dataConsumer (no type permissions) — "Custom Properties" nav item absent

UI screen recording / screenshots:

TODO: attach screen recording — opening as draft until recording is added.

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 #32413 above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: Not applicable.
  • For UI changes: screen recording TODO (opening as draft).
  • I have added tests (Playwright) and listed them above.
  • I have added a test that covers the exact scenario we are fixing.

Replace isAdminUser gate with userPermissions.hasViewPermissions(ResourceEntity.TYPE)
in CustomPropertiesLandingPage, CustomPropertiesPanel, and ProfilePage so non-admin
users holding a type-resource policy can access the AI-mode Custom Properties panel.

Split the single raw EditAll read in CustomPropertiesDetailPage into three derived
flags (canCreate, canDelete, canEditAll) via getDerivedPermissionFlags, matching the
backend's per-operation authorization on TypeResource.

Add Playwright permission tests: dataConsumer (no type access) sees no nav item;
non-admin with full type access sees all entity cards and all action buttons.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@github-actions github-actions Bot added the UI UI specific issues label Sep 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@Rohit0301
Rohit0301 marked this pull request as ready for review September 14, 2026 11:58
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Playwright impact map auto-refreshed

This PR touched specs or UI source that changed the source→spec routing map. I regenerated .github/playwright/impact-map.generated.json and pushed the diff to this branch.

- source entries: 775 → 775
- 0 added, 0 removed, 5 changed spec-list

Entries whose spec list changed:
  openmetadata-ui/src/main/resources/ui/src/components/Settings/Users/CreateUser/CreateUser.component.tsx
  openmetadata-ui/src/main/resources/ui/src/pages/LoginPage/SignInPage.tsx
  openmetadata-ui/src/main/resources/ui/src/pages/ResetPassword/ResetPassword.component.tsx
  openmetadata-ui/src/main/resources/ui/src/pages/SignUp/BasicSignup.component.tsx
  openmetadata-ui/src/main/resources/ui/src/pages/TeamsPage/AddTeamForm.tsx

What is this file? It is the auto-generated half of Playwright's PR planner. It routes "if source X changes, run specs Y" by walking spec imports and cross-referencing getByTestId strings. Hand-authored routing in impact-map.json always wins on conflict.

What if I want to regenerate locally instead? Run this before pushing your next change to skip the bot commit:

python3 .github/scripts/generate_playwright_impact_map.py
git add .github/playwright/impact-map.generated.json
git commit --amend --no-edit  # or a separate commit

@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 1af911ee9d84ee2d73d252c685bed20076b610d6 in Playwright run 35006649519, attempt 1.

✅ 4510 passed · ❌ 0 failed · 🟡 3 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) 54m 25s

⏱️ Max setup 4m 18s · max shard execution 22m 26s · max shard-job elapsed before upload 25m 39s · reporting 18s

🌐 220.58 requests/attempt · 2.23 app boots/UI scenario · 35.30% common-shard skew

Optimization targets still in progress:

  • Common shard skew was 35.3% (convergence target: at most 15%).
  • Browser traffic was 220.58 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.23 per UI scenario (10704 boots / 4797 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard advanced-search-01 130 0 0 0 0 0
✅ Shard chromium-01 192 0 0 0 0 0
✅ Shard chromium-02 172 0 0 0 0 0
✅ Shard chromium-03 166 0 0 0 0 0
🟡 Shard chromium-04 190 0 1 0 0 0
🟡 Shard chromium-05 184 0 1 0 0 0
✅ Shard chromium-06 199 0 0 0 0 0
✅ Shard chromium-07 196 0 0 0 0 0
✅ Shard chromium-08 154 0 0 0 0 0
✅ Shard chromium-09 176 0 0 0 0 0
✅ Shard chromium-10 157 0 0 0 0 0
✅ Shard chromium-11 184 0 0 1 0 0
✅ Shard chromium-12 178 0 0 0 0 0
✅ Shard chromium-13 197 0 0 0 0 0
✅ Shard chromium-14 205 0 0 0 0 0
🟡 Shard chromium-15 196 0 1 0 0 0
✅ Shard chromium-16 180 0 0 0 0 0
✅ Shard chromium-17 182 0 0 0 0 0
✅ Shard chromium-18 171 0 0 0 0 0
✅ Shard chromium-19 146 0 0 0 0 0
✅ Shard chromium-20 172 0 0 0 0 0
✅ Shard chromium-21 176 0 0 0 0 0
✅ Shard chromium-22 179 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 80 0 0 0 0 0
✅ Shard import-export-02 70 0 0 0 0 0
✅ Shard ingestion-01 46 0 0 0 0 0
✅ Shard ingestion-02 48 0 0 0 0 0
✅ Shard reindex-01 28 0 0 0 0 0
✅ Shard search-01 12 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0
🟡 3 flaky test(s) (passed on retry)
  • Pages/EntityDataSteward.spec.ts › Glossary Term Add, Update and Remove (shard chromium-04, 1 retry)
  • Features/TagsSuggestion.spec.ts › should edit and accept suggested tags for a table column (shard chromium-05, 1 retry)
  • Pages/DataContractsSemanticRules.spec.ts › Validate Description Rule Is_Not_Set (shard chromium-15, 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

@Rohit0301 Rohit0301 added the safe to test Add this label to run secure Github workflows on PRs label Sep 14, 2026
@Rohit0301 Rohit0301 self-assigned this Sep 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Playwright impact map auto-refreshed

This PR touched specs or UI source that changed the source→spec routing map. I regenerated .github/playwright/impact-map.generated.json and pushed the diff to this branch.

- source entries: 775 → 775
- 0 added, 0 removed, 9 changed spec-list

Entries whose spec list changed:
  openmetadata-ui/src/main/resources/ui/playwright/support/access-control/PoliciesClass.ts
  openmetadata-ui/src/main/resources/ui/playwright/support/access-control/RolesClass.ts
  openmetadata-ui/src/main/resources/ui/playwright/support/user/UserClass.ts
  openmetadata-ui/src/main/resources/ui/playwright/utils/admin.ts
  openmetadata-ui/src/main/resources/ui/src/components/Settings/Users/CreateUser/CreateUser.component.tsx
  openmetadata-ui/src/main/resources/ui/src/pages/LoginPage/SignInPage.tsx
  openmetadata-ui/src/main/resources/ui/src/pages/ResetPassword/ResetPassword.component.tsx
  openmetadata-ui/src/main/resources/ui/src/pages/SignUp/BasicSignup.component.tsx
  openmetadata-ui/src/main/resources/ui/src/pages/TeamsPage/AddTeamForm.tsx

What is this file? It is the auto-generated half of Playwright's PR planner. It routes "if source X changes, run specs Y" by walking spec imports and cross-referencing getByTestId strings. Hand-authored routing in impact-map.json always wins on conflict.

What if I want to regenerate locally instead? Run this before pushing your next change to skip the bot commit:

python3 .github/scripts/generate_playwright_impact_map.py
git add .github/playwright/impact-map.generated.json
git commit --amend --no-edit  # or a separate commit

Rohit0301 and others added 4 commits September 15, 2026 18:53
…sion per-item

- Fix 6 failing CustomPropertiesLandingPage tests by adding ViewBasic to
  the permissions mock so hasViewPermissions returns true
- Filter items by isProtected in the component so unprotected items are
  explicitly excluded (mirrors getGlobalSettingMenuItem behaviour)
- Add isVisible guard to ProfileNavItem so each workspace nav item owns
  its own permission check instead of gating the entire WORKSPACE_NAV_ITEMS
  array on hasTypeViewPermission — future items (e.g. workflows) won't be
  incorrectly hidden by the TYPE resource permission

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Rohit0301 and others added 3 commits September 15, 2026 22:31
…ertiesLandingPage

All CUSTOM_PROPERTIES items in GlobalSettingsClassBase use isProtected: Boolean(isAdminUser),
and the component hard-codes isAdminUser=true, so the filter was always a no-op in production.
The real permission gate is hasTypeViewPermission. Remove the filter and delete tests that
exercised states (isProtected:false items) that production code could never reach.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@gitar-bot

gitar-bot Bot commented Sep 15, 2026

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

Fixes the Custom Properties panel to gate entity-type cards and sidebar navigation on type resource permissions rather than isAdminUser, allowing non-admin users with valid policies to access the feature. Action buttons now correctly match backend authorization: canCreate || canEditAll for Add, canEditAll for Edit, and canDelete || canEditAll for Delete. Resolved action-button gate misalignment, missing dependency in renderRow callback, stale comments contradicting test assertions, and removed the no-op isProtected filter. Playwright tests cover non-admin users with and without type permissions, plus read-only scenarios.

✅ 4 closed
✅ Edge Case: Action-button gates don't match the endpoints they trigger

📄 openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/panels/CustomPropertiesPanel/CustomPropertiesDetailPage.tsx:249-257 📄 openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/panels/CustomPropertiesPanel/CustomPropertiesDetailPage.tsx:267-268
The Add button is gated on canCreate || canEditAll, but the Add flow calls addPropertyToEntity → PUT /api/v1/metadata/types/{id}, which the backend authorizes strictly on MetadataOperation.CREATE (TypeResource.addOrUpdateProperty). Since EditAll does not imply Create in the policy engine, an EditAll-only user on type sees the Add button but gets a 403 on submit. Similarly, the Delete button is gated on canDelete || canEditAll, but delete is performed via updateType → PATCH /api/v1/metadata/types/{id} (removing the property from customProperties), which is authorized as an edit on the type entity — not the Delete operation (which deletes the whole type). A user holding only Delete on type (without edit rights) would see the button but the PATCH could 403. Consider aligning each gate with the operation its endpoint actually requires. The bundled E2E test grants all four operations at once, so it cannot catch these narrower mismatches.

✅ Bug: canDelete missing from renderRow useCallback deps

📄 openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/panels/CustomPropertiesPanel/CustomPropertiesDetailPage.tsx:239-253
This commit changes the delete-button gate from canEditAll to canDelete (lines 239, 250), but renderRow's useCallback dependency array (line 265) still only lists [canEditAll, onEditProperty, t] — canDelete is not included. permission starts as DEFAULT_ENTITY_PERMISSION (all false) and is populated asynchronously after getEntityPermission resolves. For a user granted Delete but not EditAll/Create, canEditAll never changes value across the async update, so the memoized renderRow is never recreated and captures the stale canDelete = false, hiding the Delete button despite valid permission. Add canDelete (and canCreate if used) to the dependency array.

✅ Quality: Stale comments contradict assertions in ViewAll-only test

📄 openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/AIMode/CustomPropertiesPanel.spec.ts:770-777
In the ViewAll-only describe block the comments were copied from the full-access test and now contradict the code: line 770 says "User has Create → Add button visible" immediately before expect(...).not.toBeVisible(), and line 773 says "Edit and Delete buttons visible" before asserting they are not visible. Update the comments to reflect that a ViewAll-only user has no action buttons, to avoid misleading future readers.

✅ Quality: isProtected filter is a no-op in production, only tests differ

📄 openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/panels/CustomPropertiesPanel/CustomPropertiesLandingPage.tsx:57-66
In CustomPropertiesLandingPage the menu is built with getGlobalSettingsMenuWithPermission(permissions, true), hard-coding isAdminUser to true. Every custom-property item is therefore assigned isProtected: Boolean(true) === true, so the new .filter((item) => item.isProtected) never removes anything at runtime — the real gate is hasTypeViewPermission. The unit tests exercise mockUnprotectedItem (isProtected:false) and an "empty placeholder when no protected items exist" case that production data can never produce, giving false confidence. This is fragile: if the hard-coded true is ever replaced with the user's actual admin flag, the filter would silently hide all cards from the exact non-admin users this PR is meant to serve. Consider dropping the redundant filter (relying on hasTypeViewPermission) or adding a code comment explaining the filter is defensive and only meaningful under differing menu data.

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

@github-actions

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 72%
72.85% (102462/140643) 57.58% (61982/107641) 58.83% (20352/34589)

@sonarqubecloud

Copy link
Copy Markdown

let viewAllRole: RolesClass;
let customPropertyName: string;

test.describe('Custom Properties Panel — user with ViewAll on All only', () => {

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.

What dose it mean?

}
});

test('Custom Properties nav item is not visible in sidebar', async ({

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.

What dose this mean? very generic statement

}
});

test('detail page does not show Add, Edit, or Delete buttons with ViewAll only', async ({

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.

detail page should not show Add, Edit, or Delete buttons with only ViewAll permission

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

safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom Properties settings are gated on isAdminUser in the UI while the backend authorizes them through policies on the type resource

3 participants