Skip to content

Fixes #30573: search index=mlModelService no longer returns mlModel assets - #30574

Merged
aniketkatkar97 merged 2 commits into
mainfrom
fix/mlmodelservice-search-alias-leak
Jul 28, 2026
Merged

Fixes #30573: search index=mlModelService no longer returns mlModel assets#30574
aniketkatkar97 merged 2 commits into
mainfrom
fix/mlmodelservice-search-alias-leak

Conversation

@aniketkatkar97

@aniketkatkar97 aniketkatkar97 commented Jul 28, 2026

Copy link
Copy Markdown
Member

Describe your changes:

Fixes #30573

GET /v1/search/query?index=mlModelService was returning both mlModel service entities and mlModel asset entities; it should return only services (as dashboardService, databaseService, etc. correctly do).

Root cause: the search resolver SearchRepository.resolveSingleAliasToken maps the index token to a concrete *_search_index only via a by-key lookup in entityIndexMap. The mlModel service's map key is mlmodelService (equal to Entity.MLMODEL_SERVICE), but its alias — the value clients/UI send — is mlModelService (capital M). The casing mismatch makes the by-key lookup miss, so the token falls through to native ES/OpenSearch alias expansion. That alias is attached to mlmodel_search_index too (the asset lists mlModelService as a parentAlias), so assets leak in. Every other *Service has key == alias, so its lookup hits and resolves to the single concrete service index.

Fix: resolve a token by an entity's own alias (not just its map key). A new aliasIndexMap (built in loadIndexMappings(), only for aliases that are not already keys, so by-key resolution always wins) is consulted on a key miss before falling through to ES. index=mlModelService now resolves to mlmodel_service_search_index only; compound aliases (all, dataAsset, service) still pass through for native expansion; index=mlmodel still returns assets. No schema, UI, or entity-type change.

Type of change:

  • Bug fix

High-level design:

N/A — small change (3 files, resolver + tests).

Tests:

Use cases covered

  • GET /v1/search/query?index=mlModelService returns only mlModel services, never mlModel assets.
  • GET /v1/search/query?index=mlmodel still returns mlModel assets.

Unit tests

  • Added SearchRepositoryBehaviorTest#getIndexOrAliasNameResolvesEntityAliasWhenKeyCasingDiffers (fails before the fix, passes after). Added a key≠alias mapping to the suite and updated the search-entities key-set assertion. Full suite: 124/124 pass.
  • Files: openmetadata-service/src/test/java/org/openmetadata/service/search/SearchRepositoryBehaviorTest.java

Backend integration tests

  • Added MlModelServiceSearchAliasIT — creates an mlModel service + asset, waits for indexing, asserts index=mlModelService does not return the asset (and index=mlmodel does).
  • Files: openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/MlModelServiceSearchAliasIT.java

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

Ran the new IT against a full containerized stack (MySQL + Elasticsearch). Server access logs confirmed: q=<asset>&index=mlModelService did not return the asset, q=<asset>&index=mlmodel did, and q=<service>&index=mlModelService returned the service. mvn spotless:check clean.

UI screen recording / screenshots:

Not applicable.

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 #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed. (No schema changes.)
  • For UI changes: I attached a screen recording and/or screenshots above. (No UI changes.)
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • I have added a test that covers the exact scenario we are fixing.

Greptile Summary

Updates search alias resolution to map entity aliases with key-casing differences to their concrete index.

  • Adds alias-based fallback resolution while preserving key precedence and native compound-alias expansion.
  • Adds unit coverage for the mlModelService casing mismatch.
  • Adds an integration regression test verifying service searches exclude ML model assets.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java Adds a construction-time alias lookup map and consults it after canonical entity-key lookup misses.
openmetadata-service/src/test/java/org/openmetadata/service/search/SearchRepositoryBehaviorTest.java Adds unit coverage proving the mixed-case ML model service alias resolves to its concrete service index.
openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/MlModelServiceSearchAliasIT.java Adds end-to-end coverage confirming service alias searches exclude ML model assets while asset-index searches remain functional.

Reviews (2): Last reviewed commit: "test(search): make MlModelServiceSearchA..." | Re-trigger Greptile

…ssets

index=mlModelService returned mlModel assets because the entityIndexMap key
(mlmodelService) differs in casing from the alias clients send (mlModelService),
so the resolver's by-key lookup missed and the token fell through to ES alias
expansion across mlmodel_search_index. Resolve a token by an entity's own alias
(not just its key) so it collapses to the single concrete service index.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@aniketkatkar97
aniketkatkar97 requested a review from a team as a code owner July 28, 2026 10:37
Copilot AI review requested due to automatic review settings July 28, 2026 10:37

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

The IT flaked on the postgres-opensearch CI lane: the service await timed out
because free-text queries on the long underscore-laden entity name matched
unreliably in the mlmodel_service index analyzer. Query by id (a keyword field)
instead, which behaves identically on Elasticsearch and OpenSearch, and raise
the indexing-convergence timeout to 120s for the heavily parallel IT lane.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 28, 2026 12:30

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit ced529030dc59c42d07b8a9051d113415fbc292a in Playwright run 30359220935, attempt 1.

✅ 1013 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 5 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) 53m 7s

⏱️ Max setup 2m 58s · max shard execution 16m 45s · max shard-job elapsed before upload 19m 38s · reporting 5s

🌐 189.21 requests/attempt · 2.22 app boots/UI scenario · 15.82% common-shard skew

Optimization targets still in progress:

  • Common shard skew was 15.82% (convergence target: at most 15%).
  • Application boot ratio was 2.22 per UI scenario (2287 boots / 1029 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 145 0 0 3 0 0
✅ Shard chromium-02 141 0 0 0 0 0
✅ Shard chromium-03 143 0 0 0 0 0
✅ Shard chromium-04 133 0 0 0 0 0
✅ Shard chromium-05 142 0 0 0 0 0
✅ Shard chromium-06 143 0 0 0 0 0
✅ Shard data-asset-rules-01 61 0 0 0 0 0
✅ Shard domain-isolation-01 14 0 0 0 0 0
✅ Shard global-state-01 23 0 0 0 0 0
✅ Shard ingestion-01 2 0 0 0 0 0
✅ Shard reindex-01 28 0 0 0 0 0
✅ Shard search-01 11 0 0 0 0 0
✅ Shard search-rbac-01 27 0 0 2 0 0

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

@aniketkatkar97
aniketkatkar97 added this pull request to the merge queue Jul 28, 2026
Merged via the queue into main with commit 34e871c Jul 28, 2026
106 of 107 checks passed
@aniketkatkar97
aniketkatkar97 deleted the fix/mlmodelservice-search-alias-leak branch July 28, 2026 15:51
@gitar-bot

gitar-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Resolves a search alias casing mismatch by adding a fallback lookup from entity aliases to concrete service indexes, preventing mlModel assets from leaking into mlModelService queries. No issues found.

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar | Powered by Gitar — free for open source

aniketkatkar97 added a commit that referenced this pull request Jul 28, 2026
…ssets (#30574)

* fix(search): resolve mlModelService alias to its service index, not assets

index=mlModelService returned mlModel assets because the entityIndexMap key
(mlmodelService) differs in casing from the alias clients send (mlModelService),
so the resolver's by-key lookup missed and the token fell through to ES alias
expansion across mlmodel_search_index. Resolve a token by an entity's own alias
(not just its key) so it collapses to the single concrete service index.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* test(search): make MlModelServiceSearchAliasIT engine-independent

The IT flaked on the postgres-opensearch CI lane: the service await timed out
because free-text queries on the long underscore-laden entity name matched
unreliably in the mlmodel_service index analyzer. Query by id (a keyword field)
instead, which behaves identically on Elasticsearch and OpenSearch, and raise
the indexing-convergence timeout to 120s for the heavily parallel IT lane.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
aniketkatkar97 added a commit that referenced this pull request Jul 28, 2026
…ssets (#30574)

* fix(search): resolve mlModelService alias to its service index, not assets

index=mlModelService returned mlModel assets because the entityIndexMap key
(mlmodelService) differs in casing from the alias clients send (mlModelService),
so the resolver's by-key lookup missed and the token fell through to ES alias
expansion across mlmodel_search_index. Resolve a token by an entity's own alias
(not just its key) so it collapses to the single concrete service index.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* test(search): make MlModelServiceSearchAliasIT engine-independent

The IT flaked on the postgres-opensearch CI lane: the service await timed out
because free-text queries on the long underscore-laden entity name matched
unreliably in the mlmodel_service index analyzer. Query by id (a keyword field)
instead, which behaves identically on Elasticsearch and OpenSearch, and raise
the indexing-convergence timeout to 120s for the heavily parallel IT lane.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

Search: index=mlModelService returns mlModel assets, not just services

3 participants