Skip to content

[2.0] Align Context Center principal handling (#36663) - #36774

Merged
pmbrull merged 5 commits into
2.0from
backport/2.0/pr-36663
Nov 1, 2026
Merged

pmbrull merged 5 commits into
2.0from
backport/2.0/pr-36663

Conversation

@pmbrull

@pmbrull pmbrull commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Describe your changes

Backport of #36663 to 2.0 (source merge commit 9b32eb82ad95d45ac7e942f55eaf49833aac5324).

A user named like a shared team or domain must not gain that principal's access. Match memory shares by stored principal IDs using the existing search resolver, deny unresolved callers, and require a user-type owner reference when checking caller ownership.

Type of change

  • Bug fix

High-level design and backport compatibility

Keep the principal-ID and owner-reference fixes from the source PR while preserving the 2.0 visibility implementation and private helper scope.

  • 2.0 has no ContextFile sharing/visibility implementation, so the source PR's ContextFile changes are omitted.
  • Adapt the regression fixtures to the 2.0 memory schema and JWT helper; the newer Approved entity-status field is not introduced.
  • HTTP regression assertions cover the guarded GET-by-ID and GET-by-FQN routes. The later REST version/PATCH visibility guards and list-filter/paging behavior from main are not present on 2.0, so those assertions are not carried over. MCP get_entity and company_context positive/negative checks remain.
  • No schema, configuration, migration, or public API signature changes.

Tests

Use cases covered

  • Team/domain members can read explicitly shared memories through REST and MCP; namesakes who are not members are denied.
  • A user named like a team owner cannot read that team's private memory.
  • Unit coverage pins direct user shares, ID matching after renames, cross-type name collisions, missing IDs, unresolved callers, and the resulting Forbidden response.
  • On unmodified 2.0 production code, five adapted regression unit tests fail; with the fix, all 145 selected unit tests pass.

Unit tests and coverage

145 tests passed across 10 classes (129 service, 16 MCP), with zero failures, errors, or skips. The final production source is unchanged from that instrumented run.

ContextMemoryVisibility: 91.7% line coverage (66/72), measured with JaCoCo 0.8.13 on Java 21. The JaCoCo version override was local only; no POM changes.

Backend integration tests

Added McpContextMemoryPrincipalIdentityIT, adapted for 2.0. All three new regression cases passed.

Manual affected selection: ContextMemoryIT, McpContextMemoryVisibilityIT, McpContextMemoryPrincipalIdentityIT, AIContextRestIT, AIContextMcpIT, McpIntegrationIT, McpToolsValidationIT, McpUserContextIT, PersonaAIContextIT, McpServiceResourceIT. The 2.0 branch has no Java affected-test planner or impact map.

Local Java verification: FAILED

  • Final reviewed commit: 8956f3c8365c6f7fc09b51996e9d3d80be1d2948 (base origin/2.0).
  • Unit: 145 tests, 0 failures, 0 errors, 0 skipped.
  • Integration: 462 tests, 1 failure, 1 error, 50 skipped (MySQL + Elasticsearch, parallel lane).
  • Failure: McpServiceResourceIT#mcpServiceApiKey_encryptedAtRest_maskedForAdmin_readableForBot (encrypted-at-rest assertion).
  • Timeout: McpUserContextIT#ownedSummaryFindsOwnedTableViaNestedOwnersQuery.
  • Clean origin/2.0 baseline aa70b3d1a49b460bc0e0bbd0ec448b837b920ca2 reproduced both the same credential assertion and the same owned-summary timeout: 459 tests, 1 failure, 1 error, 50 skipped. The three additional cases in this backport all pass. The PR remains draft because the full selected run is red.
Clean 2.0 baseline comparison

A separate, unmodified worktree at aa70b3d1a49b460bc0e0bbd0ec448b837b920ca2 ran the same integration selection excluding McpContextMemoryPrincipalIdentityIT, which is introduced by this backport. git status --porcelain=v1 was empty before and after the run.

Run Tests Failures Errors Skipped
Backport 462 1 1 50
Clean 2.0 459 1 1 50

Both runs fail the same tests:

  • McpServiceResourceIT#mcpServiceApiKey_encryptedAtRest_maskedForAdmin_readableForBot: encrypted-at-rest assertion.
  • McpUserContextIT#ownedSummaryFindsOwnedTableViaNestedOwnersQuery: one-minute owned-table summary timeout.

Baseline command:

mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=parallel -Dit.test=ContextMemoryIT,McpContextMemoryVisibilityIT,AIContextRestIT,AIContextMcpIT,McpIntegrationIT,McpToolsValidationIT,McpUserContextIT,PersonaAIContextIT,McpServiceResourceIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
Commands and per-class JUnit results

Instrumented units and coverage:

mvn -B package -pl openmetadata-mcp -am -Dspring-boot.repackage.skip=true -Pstatic-code-analysis -Djacoco-plugin.version=0.8.13 -Dtest=ContextMemoryVisibilityTest,ContextMemorySearchVisibilityTest,SearchRequestBuilderMemoryVisibilityTest,ContextMemoryIndexTest,ContextMemoryRepositoryTest,ContextMemoryBodyTextContributorTest,AIContextBuilderTest,AIContextFinderAccessTest,AIContextFinderTest,CompanyContextToolTest -Dsurefire.failIfNoSpecifiedTests=false
mvn -B jacoco:report -pl openmetadata-service -Djacoco-plugin.version=0.8.13
Unit class Tests Failures Errors Skipped
org.openmetadata.service.aicontext.AIContextBuilderTest 46 0 0 0
org.openmetadata.service.aicontext.AIContextFinderAccessTest 2 0 0 0
org.openmetadata.service.aicontext.AIContextFinderTest 8 0 0 0
org.openmetadata.service.jdbi3.ContextMemoryRepositoryTest 13 0 0 0
org.openmetadata.service.resources.context.ContextMemoryVisibilityTest 23 0 0 0
org.openmetadata.service.search.SearchRequestBuilderMemoryVisibilityTest 5 0 0 0
org.openmetadata.service.search.indexes.ContextMemoryIndexTest 12 0 0 0
org.openmetadata.service.search.security.ContextMemorySearchVisibilityTest 14 0 0 0
org.openmetadata.service.search.vector.ContextMemoryBodyTextContributorTest 6 0 0 0
org.openmetadata.mcp.tools.CompanyContextToolTest 16 0 0 0

Integration command:

mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=parallel -Dit.test=ContextMemoryIT,McpContextMemoryVisibilityIT,McpContextMemoryPrincipalIdentityIT,AIContextRestIT,AIContextMcpIT,McpIntegrationIT,McpToolsValidationIT,McpUserContextIT,PersonaAIContextIT,McpServiceResourceIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false

The table groups raw JUnit XML testcase entries by their reported class, including inherited nested test classes. The XMLs contain five repeated class/method entries for inherited cases; aggregate counts above come from failsafe-summary.xml.

Integration class XML testcase entries Failures Errors Skipped
org.openmetadata.it.tests.BaseEntityIT$ListEntityHistoryByTimestampPaginationTest 10 0 0 8
org.openmetadata.it.tests.ContextMemoryIT 205 0 0 19
org.openmetadata.it.tests.McpServiceResourceIT 191 1 0 26
org.openmetadata.it.tests.mcp.AIContextMcpIT 6 0 0 0
org.openmetadata.it.tests.mcp.AIContextRestIT 6 0 0 0
org.openmetadata.it.tests.mcp.McpContextMemoryPrincipalIdentityIT 3 0 0 0
org.openmetadata.it.tests.mcp.McpContextMemoryVisibilityIT 4 0 0 0
org.openmetadata.it.tests.mcp.McpIntegrationIT 13 0 0 2
org.openmetadata.it.tests.mcp.McpToolsValidationIT 22 0 0 0
org.openmetadata.it.tests.mcp.McpUserContextIT 5 0 1 0
org.openmetadata.it.tests.mcp.PersonaAIContextIT 2 0 0 0

Ingestion integration tests

Not applicable — no Python or connector changes.

Playwright and UI recording

Not applicable — backend-only release backport; no UI changes.

Manual testing performed

No separate manual UI session. Real HTTP/MCP integration tests create team/domain principals, member and namesake users, and shared/private memories, then assert allowed reads and denied reads without disclosing the memory answer.

Other checks

spotless:apply, spotless:check, commit hooks, and git diff --check passed.

Self-review

A fresh reviewer checked final commit 8956f3c8365c6f7fc09b51996e9d3d80be1d2948 against the shared REVIEW.md bar: no Important findings remain. Target-branch test API, JWT, guarded-route, and list-pagination incompatibilities identified during review were resolved.

Checklist

  • Linked source PR Align Context Center principal handling #36663 and its merge commit; this is a release backport. Metadata waiver follows the source PR's existing skip-pr-checks label.
  • Read CONTRIBUTING and reviewed the final committed diff.
  • Added adapted unit and REST/MCP regression coverage; five unit regressions fail without the fix.
  • Measured changed-class coverage and checked Java formatting.
  • Evaluated schema, migration, UI, and decision-record requirements: no new requirements for this existing principal-identity contract.
  • Full selected integration run passes before marking ready.

Users, teams and domains have independent name namespaces. Match shared
principals by stored IDs and require user references for caller ownership.

Adapt the REST and MCP regression tests to the 2.0 memory APIs; file
sharing and approved-memory status are not available on this branch.

(cherry picked from commit 9b32eb8)
@pmbrull pmbrull added safe to test Add this label to run secure Github workflows on PRs skip-pr-checks Bypass PR metadata validation check labels Nov 1, 2026
@gitar-bot

gitar-bot Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved

🔴 High risk · Changing Context Memory sharing and ownership authorization to principal IDs could deny legitimate readers when identity resolution fails or IDs are missing.

Backports the principal-ID matching fix for memory shares so a user named like a team or domain no longer gains that principal's access, and requires a user-type owner reference for caller ownership checks. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

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

@pmbrull
pmbrull marked this pull request as ready for review November 1, 2026 07:25
@pmbrull
pmbrull requested a review from a team as a code owner November 1, 2026 07:25
@pmbrull
pmbrull requested review from yan-3005 and removed request for a team November 1, 2026 07:25
@sonarqubecloud

sonarqubecloud Bot commented Nov 1, 2026

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

Ingestion safe to test Add this label to run secure Github workflows on PRs skip-pr-checks Bypass PR metadata validation check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant