Repository navigation
Fixes #38638: Gate memory edit and delete on the memory's own permission - #38676
Conversation
…s own permission Every user inherits OrganizationPolicy-Owner-Rule (All when isOwner()), which the server reports as conditional at resource level, so the Context Center hid Edit and Delete from a non-admin owner of a memory. The new useMemoryActionPermissions hook answers each memory from its own permission through useBulkEntityPermissions: a non-admin's owned memories are looked up by FQN, an admin keeps the resource-level answer with no lookup, and a loading or failed lookup offers no action. The owner-or-admin rule is kept. MemoriesView takes a getMemoryActions resolver instead of page-wide canEdit/canDelete flags, and the detail modal gets the open memory's own answer. Create stays resource level. Three ContextCenterPermission.spec.ts assertions that expected an owner without a role grant to have no Edit or Delete now expect them, per ADR:2026-10-09-data-consumers-create-context-memories.
❌ 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 |
Code Review ✅ Approved 🔴 High riskThe UI now gates memory edits and deletes on per-memory permissions, changing authorization decisions; an incorrect result could expose actions contrary to policy. Gates each memory's Edit and Delete in Context Center on that memory's own permission, so owners of a memory can act on it even when the resource-level VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
UI browser testsRan: all test files (no impact map from main yet) Result: ✅ 1079 passed · 154 skipped Changed code executed by these browser tests: 30 / 31 lines (97%)
Changed files no browser test loads
|
|
🤖 Backport to |
|
🤖 Backport to |
|
🤖 Backport to |
|
🤖 Backport to |
…ion (#38676) (#38771) Every user inherits OrganizationPolicy-Owner-Rule (All when isOwner()), which the server reports as conditional at resource level, so the Context Center hid Edit and Delete from a non-admin owner of a memory. The new useMemoryActionPermissions hook answers each memory from its own permission through useBulkEntityPermissions: a non-admin's owned memories are looked up by FQN, an admin keeps the resource-level answer with no lookup, and a loading or failed lookup offers no action. The owner-or-admin rule is kept. MemoriesView takes a getMemoryActions resolver instead of page-wide canEdit/canDelete flags, and the detail modal gets the open memory's own answer. Create stays resource level. Three ContextCenterPermission.spec.ts assertions that expected an owner without a role grant to have no Edit or Delete now expect them, per ADR:2026-10-09-data-consumers-create-context-memories. (cherry picked from commit 590ea15) Co-authored-by: deepinsight coder <32898216+Vamsi-klu@users.noreply.github.com>
…ermission (#38773) * Fixes #38638: Gate memory edit and delete on the memory's own permission (#38676) Every user inherits OrganizationPolicy-Owner-Rule (All when isOwner()), which the server reports as conditional at resource level, so the Context Center hid Edit and Delete from a non-admin owner of a memory. The new useMemoryActionPermissions hook answers each memory from its own permission through useBulkEntityPermissions: a non-admin's owned memories are looked up by FQN, an admin keeps the resource-level answer with no lookup, and a loading or failed lookup offers no action. The owner-or-admin rule is kept. MemoriesView takes a getMemoryActions resolver instead of page-wide canEdit/canDelete flags, and the detail modal gets the open memory's own answer. Create stays resource level. Three ContextCenterPermission.spec.ts assertions that expected an owner without a role grant to have no Edit or Delete now expect them, per ADR:2026-10-09-data-consumers-create-context-memories. (cherry picked from commit 590ea15) Backport notes for 2.0: useBulkEntityPermissions, PermissionDerivation and the Vitest browser-test harness are not on 2.0, so useMemoryActionPermissions queries per-memory permissions with useQueries directly, and the ContextCenterMemoriesPage browser/Jest tests and personas fixture are dropped. * Fix 2.0 backport: import createMemoryViaApi in spec, cache memory permission lookups The spec auto-merged but on 2.0 never imported createMemoryViaApi, so it failed to compile. Memory permission queries now use main's 5 minute staleTime instead of the 2.0 client default of 0. --------- Co-authored-by: deepinsight coder <32898216+Vamsi-klu@users.noreply.github.com>
Describe your changes:
Fixes #38638
In Context Center, a memory's owner could not edit or delete their own memory. The page gated each memory's Edit and Delete on the resource-level
contextMemorypermission. Every user inheritsOrganizationPolicy-Owner-Rule(AllwhenisOwner()), and the server reports a conditional rule asconditionalAllow/conditionalDenyat resource level, because there is no memory to evaluate the condition against. The UI translates resource-level conditionals strictly (permissionPolicy.ts), so Edit and Delete were hidden for every non-admin owner. Every default install is affected: it needs no custom policy, only a non-admin user who owns a memory.This PR gates each memory's Edit and Delete on that memory's own permission:
useMemoryActionPermissions(memories, resourcePermission)(src/hooks/discovery/context-center/), built onuseBulkEntityPermissions:GET /permissions/contextMemory/name/{fqn}only for the memories the user owns (one cached React Query per FQN, shared withuseEntityPermissions).main.EditAll.ContextCenterMemoriesPagepasses the resolver to the list, and the open memory's own answer to the detail/edit modal (canEdit,canDelete). Create stays on the resource level (canCreateviagetDerivedPermissionFlags, which also removes the rawpermissions.Create/permissions.Deletereads).src/test/browser/fixtures/personas.ts:servePersona'sentitycallback now receives the lookup ({ resource, id?, fqn? }), so a list page can answer each row against its own owners. The one existing caller (entityMatrix.ts) ignores the argument.Not changed:
CreateMemoryModal,ExtractedMemoriesCard,permissionPolicy.ts, locales, backend.MemoriesViewprops changed — Collate questionMemoriesViewPropslosescanEdit,canDelete,currentUserNameandisAdminUserand gainsgetMemoryActions?: (memory) => MemoryActionPermissions(default: no actions). In OSS the page is its only importer. Maintainers: please confirm that openmetadata-collate does not renderMemoriesViewdirectly. If it does, I will keep the old props as optional and deprecated for one release (REVIEW.md, "Collate builds against OpenMetadatamain").Issue discussion
Plan, including the three flipped assertions, posted on the issue before implementation: #38638 (comment). harshach assigned the issue in reply; there is no reply yet on the assertion flips themselves. @Rohit0301, as the author of #29287, please confirm the flips match the intent.
Type of change:
High-level design:
resourceLevelConditionalAllowto'attempt'would still denyconditionalDeny, changes every resource-level check in the app, and shows buttons the server then refuses.permissionPolicy.tsreserves the resource level for "places with no specific entity yet"; a memory row has one.PermissionsResourcehas only/{resource},/{resource}/{id},/{resource}/name/{name}), so this keeps the request count to the user's own memories on the page.DefaultAuthorizeranswersALLOWfor every admin operation at both levels, so a lookup per row (up to the page size) would add requests for the same answer.CreateMemoryModalfetch its own permission (changes a shared component's props and duplicates the page's fetch).permissionPolicy.tsand ADR:2026-10-09-data-consumers-create-context-memories.Tests:
Use cases covered
isOwner()sees Edit and the manage menu on their own row, edits the memory from its detail view (PATCH sent, dialog closes) and deletes it from the row (DELETE sent, row gone).conditionalDeny(a deny rule such as!isOwner() && !noOwner()).Unit tests
Jest,
yarn test src/hooks/discovery/context-center/useMemoryActionPermissions.test.tsx src/components/ContextCenter/MemoriesView src/pages/ContextCenterPage/ContextCenterMemoriesPage src/components/ContextCenter/CreateMemoryModal: 6 suites, 113 tests passed.useMemoryActionPermissions.test.tsx(7 tests; onlyrest/permissionAPIis mocked, real React Query and app store): owner allowed from the entity level while the resource level says no; only owned memories looked up; admin answered from the resource level with no call; a 403 leaves no actions; a late answer for memory A never reaches memory B; a soft-deleted memory allows Delete but not Edit; a memory listed twice is looked up once.MemoriesView.test.tsx: Edit/Delete render only on the rowsgetMemoryActionsallows (fails onmain), and none without a resolver.ContextCenterMemoriesPage.test.tsx: removed the two tests that asserted the resource-levelcanEditprop wiring that no longer exists; the hook is mocked (frontend-permissions rule).Browser test (Vitest browser mode, real app, MSW), new
ContextCenterMemoriesPage.browser.test.tsx: 7/7 pass.main/answer, dialog closes)?hardDelete=true, row removed)Every browser test that reaches
servePersona(82 files through the entity-matrix and custom-property contracts), becausepersonas.tschanged: not verified locally. In this worktree the entity-matrix tests cannot load their lazy route (Failed to fetch dynamically imported module: …/TableDetailsPageV1.tsx).EntityDataConsumer.Table.browser.test.tsxfails 12/12 the same way withorigin/main'spersonas.ts, so the cause is the local environment, not this change. The change itself is additive: the callback gets an argument, and the one existing caller (() => server.current()) ignores it;tscis clean for it. The impact-selected browser job on this PR runs them.Static checks
yarn tsc:playwright: clean.yarn tsc:check: 34 errors, all in two files this PR does not touch (src/utils/SSOUtils.test.ts,src/utils/ChartDetailsUtils.test.tsx); they are onorigin/mainas well. None in the changed files.yarn ui-checkstyle:changed <changed src files>(organize-imports, ESLint, Prettier, licence, i18n sync): no diff, 0 errors (the only warnings are the existingsetCurrentPageexhaustive-deps ones in the page).yarn lint:playwright: 0 errors. Pre-commit hooks passed.Backend integration tests
Playwright (UI) tests
playwright/e2e/Features/ContextCenterPermission.spec.ts,Memories Permissions:contextMemoryrules areCreate+ViewBasicunconditionally,ViewAll/EditAll/DeleteifisOwner(), andAlldenied if!isOwner() && !noOwner(). Asserts the resource level reportsEditAllas conditional, then in the UI: the row shows Edit, the detail view's Edit → Save returns PATCH 200 and an admin GET shows the new content, and the row's Delete returns 200, removes the row, and an admin GET returns 404. Fails onmain(no Edit on the row).OrganizationPolicy-Owner-Rule." The Playwright setup keeps that rule (ORGANIZATION_POLICY_RULESinplaywright/constant/permission.ts), and the backend already allows these operations; the tests pinned the UI bug, they are not loosened to make this PR pass:683b788f95, server bound to127.0.0.1, Playwrightsetupproject first for the CI policy baseline),PLAYWRIGHT_IS_OSS=true PW_PRESEEDED_STATE=true npx playwright test playwright/e2e/Features/ContextCenterPermission.spec.ts --project=chromium --workers=1 -g "Memories Permissions": 9 passed (the new test, the 3 flipped tests and the 5 unchanged ones).main.add-memory-btnassertions for the view-only and editAll users are green onmain. The Playwright setup replacesDataConsumerPolicywithDATA_CONSUMER_RULES, which has noCreateoncontextMemory, and removes the Organization's default roles. The last full nightly run with results (run 45313589314, 2026-11-24,3cdf00c82c) passed all 9Memories Permissionstests on the first attempt. (The 2026-11-25 nightly failed inplan-playwrightbefore any test ran.)make playwright_affected_run.make playwright_affectedselects 33 specs: this one, 11 impact-mapped Context Center specs, and canaries such asPages/Entity.spec.ts, the DomainIsolation suite andFlow/SearchRBAC.spec.ts; two of them (SystemCertificationTags,IntakeForm) also pull in the wholechromiumproject. That is too broad for this shared box; the merge queue runs the full suite.Manual testing performed
yarn build,mvn package -pl openmetadata-dist -am), started MySQL, Elasticsearch and the server in Docker, bound to127.0.0.1;/api/v1/system/versionreported revision683b788f95.ViewAll, and a memory owned by that user.UI screen recording:
Not applicable — a bug fix, not a feature. After screenshots from the local stack (classic mode renders light only; dark exists only in AI mode and was not captured): the owner's row with Edit and the manage menu, and the detail modal's footer with Delete and Edit. Before: on
mainthe same row shows only the copy-link button and the footer only Cancel (browser tests 1-2 fail on exactly these controls).After: the owner's row (copy link, Edit, manage menu)
After: the owner's detail modal (Delete and Edit in the footer, no read-only banner)
Checklist:
Fixes #38638: Gate memory edit and delete on the memory's own permissionFixes #38638above.REVIEW.md(thepr-checklistskill runs it) and fixed every 🔴 finding, or answered it on the line below.Fresh-context review against REVIEW.md (of the pre-amend
270cdc18b3; the final commit is683b788f95): no 🔴. Fixed: the failed-lookup browser test now waits for the 403 to land (networkIdle()) before its absence checks, so a loading state can't satisfy it (amended into this commit). Answered:isOwner()evaluation (resource level conditional, entity level allow, PATCH/DELETE 200) reaching the UI. A Java IT for that permission contract would be a good addition, but this PR has no backend change.setCustomRulePolicyleaves its policy, role and team behind: the same as every other user in this spec; the test deletes its user and memory in afinally.ExtractedMemoriesCard: pre-existing, listed under follow-ups.permissionPolicy.tsand ADR:2026-10-09-data-consumers-create-context-memories.Follow-ups (not in this PR)
isOwner()also matches the user's teams (SubjectContext). A member of an owning team still sees no Edit/Delete.ExtractedMemoriesCardopens the sameCreateMemoryModalbut gates Delete on owner-or-admin with no permission check and never passescanEdit(so no Edit there, even for an admin). It can reuseuseMemoryActionPermissions.EditAll/Delete, which re-encodes policy in the UI (REVIEW.md, "The UI consumes the API's semantics"). Dropping it is a product decision.🤖 Generated with Claude Code