Skip to content

[2.0] Fixes #36463: restore context search on Elasticsearch - #37041

Merged
pmbrull merged 1 commit into
2.0from
backport/2.0/pr-36548
Nov 4, 2026
Merged

pmbrull merged 1 commit into
2.0from
backport/2.0/pr-36548

Conversation

@pmbrull

@pmbrull pmbrull commented Nov 4, 2026

Copy link
Copy Markdown
Member

Describe your changes:

Fixes #36463

Backport of #36548, cherry-picked from 961fb5f9200d4159c266303fccd9e6f86406097b.

On Elasticsearch, find_context returned no knowledge and company_context reported that semantic search was disabled because both read the OpenSearch-only singleton. Both now obtain VectorIndexService through SearchRepository.getVectorIndexService(). OpenSearch retains its existing implementation, and company-context searches still receive the caller's SubjectContext for memory visibility.

The only backport adaptation was resolving imports against the existing 2.0 finder and tests. The diff contains the same two production changes and their regression tests.

Type of change:

  • Bug fix

High-level design:

Not applicable — small backport that reuses the existing backend-neutral vector-service accessor. No schema, migration, API contract, or configuration changes.

Tests:

Use cases covered

  • The finder returns a knowledge hit through the repository's vector service when the OpenSearch singleton is null.
  • Company-context search uses the repository service, preserves pagination and caller identity, and handles a missing service.
  • Existing AI-context authorization and MCP memory visibility remain intact.

Unit tests

28 tests passed, zero failures or skips:

  • AIContextFinderTest: 9
  • AIContextFinderAccessTest: 2
  • CompanyContextToolTest: 17

Command:

mvn -B package jacoco:report -pl openmetadata-mcp -am -Pstatic-code-analysis \
  -Dspring-boot.repackage.skip=true \
  -Dtest=AIContextFinderTest,AIContextFinderAccessTest,CompanyContextToolTest \
  -Dsurefire.failIfNoSpecifiedTests=false -Dsonar.skip=true

JaCoCo covers both changed executable lines (2/2). Whole-class line coverage is 83.5% for AIContextFinder (111/133) and 88.8% for CompanyContextTool (103/116), below the 90% target; the uncovered lines belong to existing routing, lookup, and error paths outside this backport.

Backend integration tests

42 tests passed against MySQL and Elasticsearch, zero failures or skips:

  • AIContextKnowledgeAuthorizationIT: 1
  • AIContextRestIT: 6
  • AIContextMcpIT: 6
  • McpContextMemoryPrincipalIdentityIT: 3
  • McpContextMemoryVisibilityIT: 4
  • McpToolsValidationIT: 22

Command:

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

The 2.0 branch does not contain make java_affected or the Java impact map, so the relevant existing tests were selected and run directly. These are the backport's results; the original PR's results are not reused here.

Ingestion integration tests

Not applicable — no ingestion changes.

Playwright (UI) tests

Not applicable — no UI changes.

Manual testing performed

Compared the backport with the merged source patch and checked compatibility with 2.0's vector-service overloads and visibility filtering. No live embedding-provider test was repeated on 2.0; #36548 contains the original Elasticsearch before/after verification.

UI screen recording / screenshots:

Not applicable — backend-only fix.

Checklist:

  • Linked issue and merged source PR are identified above.
  • Regression tests are included and the target-branch validation is recorded above.
  • mvn -B -pl openmetadata-service,openmetadata-mcp spotless:apply passed.
  • No schema migration, UI recording, or ingestion validation is required for this change.
  • A fresh reviewer checked commit acb32478e6a7367e8e027c9592624eeb9d78435b against REVIEW.md, including the Elasticsearch implementation and caller visibility; no important findings.
  • No new decision record is needed: this backport reuses an existing accessor and contract.

Backport #36548 to 2.0.

(cherry picked from commit 961fb5f)
@pmbrull
pmbrull requested a review from a team as a code owner November 4, 2026 10:55
@pmbrull
pmbrull requested review from sonika-shah and removed request for a team November 4, 2026 10:55
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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 skip-pr-checks label.

@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Nov 4, 2026
@gitar-bot

gitar-bot Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved

🟡 Medium risk · Using the repository vector service for AI and company-context searches enables Elasticsearch results; service differences could surface incomplete or unintended context.

Backports the Elasticsearch context lookup fix so AIContextFinder and CompanyContextTool obtain VectorIndexService through SearchRepository.getVectorIndexService() instead of the OpenSearch-only singleton. 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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants