Skip to content

fix: respect entity-level permissions for import/export in GlossaryHeader#27507

Open
himanshu748 wants to merge 2 commits intoopen-metadata:mainfrom
himanshu748:fix/import-export-permissions-conditions
Open

fix: respect entity-level permissions for import/export in GlossaryHeader#27507
himanshu748 wants to merge 2 commits intoopen-metadata:mainfrom
himanshu748:fix/import-export-permissions-conditions

Conversation

@himanshu748
Copy link
Copy Markdown

Summary

When a Data Producer role has conditions (e.g. isOwner(), hasDomain(), matchTeam()) on its EditAll permission, the import/export buttons in the Glossary header are incorrectly hidden.

Root Cause

importExportPermissions in GlossaryHeader.component.tsx only checks globalPermissions via checkPermission(), which evaluates static role-level operations without considering policy conditions. When conditions are added, these global checks return false.

Fix

Added a fallback to the entity-level permissions.EditAll (from useGenericContext), which evaluates policy conditions against the actual entity. This ensures import/export buttons are shown when the user satisfies the conditions on their role's policy.

Changes

  • GlossaryHeader.component.tsx: Added permissions.EditAll as an OR fallback in the importExportPermissions memo, and added permissions to the dependency array.
  • GlossaryHeader.test.tsx: Added test case verifying import/export buttons render when entity-level EditAll is true but global permissions lack All/EditAll.

Testing

  • Existing test (should not render import and export if no permission) still passes since DEFAULT_ENTITY_PERMISSION has EditAll: false.
  • New test validates the conditional permissions scenario described in the issue.

Fixes #27487

AI Disclosure

This contribution was developed with the assistance of Antigravity, an AI coding assistant by Google DeepMind.

…ader

When a Data Producer role has conditions (e.g. isOwner(), hasDomain(),
matchTeam()) on its EditAll permission, the global permissions check
returns false because conditions are not evaluated at the global level.

This fix adds a fallback to the entity-level permissions.EditAll, which
evaluates policy conditions against the specific entity. This ensures
import/export buttons are shown when the user satisfies the conditions.

Fixes open-metadata#27487
@himanshu748 himanshu748 requested a review from a team as a code owner April 18, 2026 07:36
Copilot AI review requested due to automatic review settings April 18, 2026 07:36
@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!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes Glossary header import/export visibility so users with conditional EditAll permissions (e.g., isOwner(), hasDomain(), matchTeam()) still see the actions when the condition evaluates true for the current entity.

Changes:

  • Update GlossaryHeader import/export permission logic to OR in entity-level permissions.EditAll.
  • Add a unit test covering the scenario where global permissions deny All/EditAll but entity-level EditAll is granted.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryHeader/GlossaryHeader.component.tsx Adds entity-level permissions.EditAll fallback for import/export visibility.
openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryHeader/GlossaryHeader.test.tsx Adds regression test for conditional-permission behavior.

Comment on lines +232 to +240
it('should render import and export when entity-level EditAll is true despite no global permission', async () => {
// Simulate a role with conditional EditAll (e.g. isOwner())
// Global permissions do not grant All/EditAll
mockGlossaryTermPermission.All = false;
mockGlossaryTermPermission.EditAll = false;
// Entity-level permissions evaluate conditions and grant EditAll
mockContext.permissions = { ...DEFAULT_ENTITY_PERMISSION, EditAll: true };
mockContext.type = EntityType.GLOSSARY;
render(
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

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

This new test mutates shared module-level mocks (mockGlossaryTermPermission and mockContext) without resetting them afterwards. Since other tests in this file also rely on the same shared objects (and don’t use a beforeEach reset), the suite becomes order-dependent and can be flaky when tests are re-ordered or run in isolation. Suggest resetting mockGlossaryTermPermission/mockContext to defaults in a beforeEach, or cloning fresh objects per test to avoid cross-test state leakage.

Copilot uses AI. Check for mistakes.
@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!

@gitar-bot
Copy link
Copy Markdown

gitar-bot bot commented Apr 18, 2026

Code Review ✅ Approved

GlossaryHeader import/export functionality now correctly respects entity-level permissions. No issues found.

Options

Display: compact → Showing less information.

Comment with these commands to change:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

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.

Permissions: Import/Export functionality is Disabled by Conditions

2 participants