Skip to content

Fixes #27945: surface exact/prefix matches first in QuickFilter aggregation - #29231

Merged
pmbrull merged 5 commits into
mainfrom
fix-quickfilter-exact-match-sorting
Jun 22, 2026
Merged

pmbrull merged 5 commits into
mainfrom
fix-quickfilter-exact-match-sorting

Conversation

@chirag-madlani

@chirag-madlani chirag-madlani commented Jun 19, 2026 •

Copy link
Copy Markdown
Collaborator

Describe your changes:

Fixes #27945

The /search/aggregate endpoint used a single terms aggregation with include: ".*term.*" ordered alphabetically with a fixed size=10. When more than 10 values matched the pattern, exact matches (e.g. name) were silently dropped in favour of alphabetically-earlier contains-matches (e.g. first_name, display_name).

Replace the single aggregation with three targeted sub-aggregations sent in one ES/OS round-trip:

  • __exact — include: "term" (size 1, O(1) dictionary lookup — always finds the exact match regardless of dataset size)
  • __prefix — include: "term.*" (size N, B-tree prefix scan, efficient)
  • __contains — include: ".*term.*" (size N, full wildcard, unchanged behaviour)

The backend merges the three bucket lists in priority order (exact → prefix → contains), deduplicates, trims to the requested size, and rewrites the response under the original sterms#field key — no frontend changes required.

Type of change:

  • Bug fix

High-level design:

Root cause: ES/OS terms aggregation with include regexp collects size matching buckets ordered alphabetically. With include: ".*name.*" and size=10, name (exact) is cut if 10 alphabetically-earlier terms (e.g. column_name, display_name, first_name) exist. Fetching more candidates and sorting on the backend is a band-aid that still fails at scale.

Proper fix: Industry-standard approach — split the single wildcard aggregation into three targeted ones in one round-trip:

Sub-agg Include pattern ES behaviour Purpose
__exact name O(1) dict lookup Guarantees exact match always returned
__prefix name.* B-tree prefix scan Efficient starts-with matches
__contains .*name.* Full scan (unchanged) Catches suffix/interior matches

Backend merges with dedup: exact → prefix → contains, trims to size. The expensive wildcard agg now only fills slots the first two didn't cover.

New SearchUtils helpers:

  • isBestMatchSearchPattern(includeValue) — detects whether a real user term is being searched
  • extractRawSearchValue(includeValue) — strips .* prefix/suffix added by the frontend
  • exactAggKey / prefixAggKey / containsAggKey — deterministic sub-agg naming
  • mergeBestMatchAggregations — JSON merge/dedup/trim applied to both ES and OS responses

Both ElasticSearchAggregationManager and OpenSearchAggregationManager updated identically.

Tests:

Use cases covered

  • User types name → name (exact) appears first, then named/names (prefix), then first_name/last_name (contains)
  • Exact term missing from index → prefix and contains results still returned in correct order
  • All three sub-aggs return overlapping keys → each key appears exactly once in merged response
  • Result count exceeds display limit → trimmed to size
  • ES/OS returns malformed JSON → original response returned unchanged (no throw)

Unit tests

  • I added unit tests for the new/changed logic.
  • Files added/updated: openmetadata-service/src/test/java/org/openmetadata/service/search/SearchUtilsTest.java
  • 12 new parametrised and scenario tests covering: isBestMatchSearchPattern (7 cases), extractRawSearchValue (6 cases), include-pattern derivation (3 cases), key-name helpers, merge ordering, dedup, trimming, missing exact bucket, sub-agg key removal, empty aggs, contains-only fallback, malformed JSON fallback.

Backend integration tests

  • Not applicable — no new API endpoint; existing /search/aggregate contract is unchanged (same response shape).

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

  1. Hit GET /api/v1/search/aggregate?index=dataAsset&field=columns.name.keyword&value=.*name.*&q=&deleted=false
  2. Verified response bucket order: name → named/names → display_name/first_name/last_name

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 #27945 above.
  • 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

This PR fixes the QuickFilter aggregation ordering bug where exact matches (e.g. name) were silently dropped when more than size alphabetically-earlier terms matched the contains regex. The fix replaces the single terms aggregation with three targeted sub-aggregations (__exact, __prefix, __contains) in one round-trip, then merges and deduplicates the results in priority order on the backend before returning the canonical sterms#field response the frontend already expects.

  • SearchUtils: adds isBestMatchSearchPattern, extractRawSearchValue, key-name helpers, and mergeBestMatchAggregations (with graceful fallback) as shared utilities for both ES and OS managers.
  • ElasticSearchAggregationManager / OpenSearchAggregationManager: the three-sub-agg strategy activates only when a real user search term is present and sourceFields are not requested; all other code paths keep the previous single-agg behaviour unchanged.
  • SearchUtilsTest: 12 new parameterised and scenario tests added; the fallback-on-failure test currently exercises the happy path rather than the exception branch.

Confidence Score: 5/5

Safe to merge — the new three-sub-agg path is gated behind explicit conditions so all other callers are unaffected.

The core merge logic is straightforward and covered by the new unit tests. The graceful fallback ensures the frontend always receives a valid response. All findings are non-blocking and do not affect correctness of the live code path.

No files require special attention, though the dot-only regex escaping in buildBestMatchAggregations is worth revisiting if field names with other metacharacters become common.

Important Files Changed

Filename Overview
openmetadata-service/src/main/java/org/openmetadata/service/search/SearchUtils.java Adds three-sub-agg helpers and mergeBestMatchAggregations to produce priority-ordered, deduplicated aggregation results; merged agg hardcodes sum_other_doc_count to 0.
openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchAggregationManager.java Replaces single terms agg with three targeted sub-aggs when isBestMatchSearchPattern is true and no sourceFields are present; dot-only regex escaping in buildBestMatchAggregations is a minor gap.
openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchAggregationManager.java Mirror of ElasticSearchAggregationManager changes for OpenSearch; identical three-sub-agg strategy applied with the same dot-only escaping limitation.
openmetadata-service/src/test/java/org/openmetadata/service/search/SearchUtilsTest.java Adds 12 tests covering isBestMatchSearchPattern, extractRawSearchValue, merge ordering/dedup/trim, and edge cases; the FallsBackToContainsAggOnMergeFailure test does not exercise the catch-branch fallback.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant FE as Frontend
    participant AGG as AggregationManager
    participant ES as Elasticsearch / OpenSearch
    participant SU as SearchUtils
    FE->>AGG: "GET /search/aggregate?field=col&value=.*name.*"
    AGG->>AGG: isBestMatchSearchPattern true, extractRawSearchValue name
    AGG->>ES: 3 sub-aggs in one request
    ES-->>AGG: "sterms#col__exact, sterms#col__prefix, sterms#col__contains"
    AGG->>SU: mergeBestMatchAggregations
    SU->>SU: merge exact to prefix to contains, dedup, trim
    SU-->>AGG: "sterms#col in priority order"
    AGG-->>FE: "aggregations sterms#col buckets"
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant FE as Frontend
    participant AGG as AggregationManager
    participant ES as Elasticsearch / OpenSearch
    participant SU as SearchUtils
    FE->>AGG: "GET /search/aggregate?field=col&value=.*name.*"
    AGG->>AGG: isBestMatchSearchPattern true, extractRawSearchValue name
    AGG->>ES: 3 sub-aggs in one request
    ES-->>AGG: "sterms#col__exact, sterms#col__prefix, sterms#col__contains"
    AGG->>SU: mergeBestMatchAggregations
    SU->>SU: merge exact to prefix to contains, dedup, trim
    SU-->>AGG: "sterms#col in priority order"
    AGG-->>FE: "aggregations sterms#col buckets"
Loading

Reviews (4): Last reviewed commit: "fix(search): fix dot-escaping test expec..." | Re-trigger Greptile

…ation

Fixes #27945

The /search/aggregate endpoint used a single terms aggregation with
include: ".*term.*", ordered alphabetically with a fixed size=10. When
more than 10 values matched the pattern, exact matches (e.g. "name")
were silently dropped in favour of alphabetically-earlier contains
matches (e.g. "first_name", "display_name").

Replace the single agg with three targeted sub-aggregations sent in one
ES/OS round-trip:
  • __exact   – include: "term"     (size 1, O(1) dict lookup)
  • __prefix  – include: "term.*"   (size N, B-tree prefix scan)
  • __contains – include: ".*term.*" (size N, full wildcard, unchanged)

The backend merges the three bucket lists in priority order
(exact → prefix → contains), deduplicates, trims to the requested size,
and rewrites the response under the original sterms#field key so the
frontend requires no changes.

Add SearchUtils helpers: isBestMatchSearchPattern, extractRawSearchValue,
exactAggKey/prefixAggKey/containsAggKey, mergeBestMatchAggregations.
Cover all helpers and merge edge cases in SearchUtilsTest (12 new tests).

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@github-actions

github-actions Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs UI UI specific issues labels Jun 19, 2026
Comment on lines 189 to 191
throw new IOException("Failed to execute aggregation: " + e.getMessage(), e);
}
}

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.

P2 Best-match strategy skipped for sourceFields queries

When hasSourceFields is true the code falls through to the old single-terms aggregation, meaning the exact-match ordering fix does not apply to those requests. Any caller that passes source fields (e.g. type-ahead with top-hit enrichment) will still silently drop the exact bucket when more than size alphabetically-earlier terms exist. The same gap exists in OpenSearchAggregationManager. This is not explicitly documented in the PR as out-of-scope.

@github-actions

github-actions Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

🟡 Playwright Results — all passed (15 flaky)

✅ 4305 passed · ❌ 0 failed · 🟡 15 flaky · ⏭️ 88 skipped

Shard Passed Failed Flaky Skipped
🟡 Shard 1 301 0 1 4
🟡 Shard 2 813 0 2 9
🟡 Shard 3 812 0 4 8
🟡 Shard 4 855 0 4 12
🟡 Shard 5 731 0 2 47
🟡 Shard 6 793 0 2 8
🟡 15 flaky test(s) (passed on retry)
  • Pages/Roles.spec.ts › Roles page should work properly (shard 1, 1 retry)
  • Features/DataQuality/ColumnLevelTests.spec.ts › Column Values To Be Between (shard 2, 1 retry)
  • Features/DataQuality/TestCaseImportExportE2eFlow.spec.ts › EditAll User: Complete export-import-validate flow (shard 2, 1 retry)
  • Features/IncidentManager.spec.ts › Resolving incident & re-run pipeline (shard 3, 1 retry)
  • Features/KnowledgeCenterList.spec.ts › Knowledge Center List - Verify Recently Viewed widget (shard 3, 1 retry)
  • Features/Table.spec.ts › Tags term should be consistent for search (shard 3, 1 retry)
  • Features/Tasks/TaskNavigation.spec.ts › navigating to /table/TASK-XXXXX should show 404 (invalid URL pattern) (shard 3, 2 retries)
  • Flow/PersonaDeletionUserProfile.spec.ts › User profile loads correctly before and after persona deletion (shard 4, 1 retry)
  • Flow/PersonaFlow.spec.ts › Set default persona for team should work properly (shard 4, 1 retry)
  • Pages/CustomProperties.spec.ts › Markdown (shard 4, 1 retry)
  • Pages/CustomProperties.spec.ts › Table (shard 4, 1 retry)
  • Pages/Entity.spec.ts › Tier Add, Update and Remove (shard 5, 1 retry)
  • Pages/ExplorePageRightPanel_KnowledgeCenter.spec.ts › Should remove user owner for knowledgeCenter (shard 5, 1 retry)
  • Pages/Lineage/DataAssetLineage.spec.ts › Column lineage for mlModel -> topic (shard 6, 1 retry)
  • Pages/Lineage/LineageFilters.spec.ts › Verify lineage schema filter selection (shard 6, 1 retry)

📦 Download artifacts

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

chirag-madlani and others added 3 commits June 20, 2026 13:09
- mergeBestMatchAggregations: on merge failure, degrade to renaming
  the __contains sub-agg to sterms#<field> so the UI always receives
  the key it expects; double-catches so even fallback parse failures
  are silent
- buildBestMatchAggregations (ES + OS): escape '.' in rawValue before
  using as Lucene regexp include for exact and prefix sub-aggs, preventing
  field names like 'user.id' from being treated as wildcards and preventing
  unbalanced-regexp 500s
- isBestMatchSearchPattern: guard against null input
- SearchUtilsTest: fix two broken parametrized cases (.* → expected '',
  remove null-passing CSV row), add dedicated null test, add fallback-path
  and dot-escaping tests

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@sonarqubecloud

Copy link
Copy Markdown

@chirag-madlani
chirag-madlani enabled auto-merge (squash) June 22, 2026 11:35
@pmbrull
pmbrull disabled auto-merge June 22, 2026 11:40
@pmbrull
pmbrull merged commit 26c9b51 into main Jun 22, 2026
57 of 60 checks passed
@pmbrull
pmbrull deleted the fix-quickfilter-exact-match-sorting branch June 22, 2026 11:40
@gitar-bot

gitar-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 2 resolved / 2 findings

Replaces single wildcard aggregations with three ranked sub-aggregations to ensure exact matches are surfaced first in search results. This resolves the previous issues with leaky sub-agg keys and unescaped regex search values.

✅ 2 resolved
✅ Bug: Merge failure leaks sub-agg keys and breaks QuickFilter UI

📄 openmetadata-service/src/main/java/org/openmetadata/service/search/SearchUtils.java:103-117 📄 openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchAggregationManager.java:181-185 📄 openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchAggregationManager.java:180-184
In the best-match path the ES/OS response only contains the three sub-aggregations sterms#<field>__exact, sterms#<field>__prefix, sterms#<field>__contains — there is no sterms#<field> key until mergeBestMatchAggregations rewrites it. mergeBestMatchAggregations catches ALL exceptions and silently returns the ORIGINAL responseJson unchanged (SearchUtils.java:108-110). For the best-match path that original JSON has no sterms#<field> key, only the three internal sub-agg keys.

The frontend reads the bucket list strictly as res.data.aggregations[\sterms#${searchKeyToUse}`].buckets(ExploreQuickFilters.tsx:124,195). If the merge ever throws (e.g. serialization fallback produced unexpected JSON, orroot/aggregationsis not an ObjectNode), the UI will throwCannot read properties of undefined (reading 'buckets')and the QuickFilter breaks — and it also exposes internal__exact/__prefix/__contains` keys in the public response.

The documented fallback contract ("return original response unchanged") is only safe for the legacy single-agg path; for the best-match path the original response is itself invalid for consumers. The catch should guarantee a sterms#<field> key is always present (e.g. fall back to the __contains sub-agg renamed to sterms#<field>, or strip the three sub-agg keys), rather than returning a response with leaked internal keys and no expected key.

✅ Edge Case: User search value used as ES regexp without escaping

📄 openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchAggregationManager.java:194-207 📄 openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchAggregationManager.java:194-206 📄 openmetadata-service/src/main/java/org/openmetadata/service/search/SearchUtils.java:91-95
extractRawSearchValue strips the .* wrappers and the result is fed directly into Lucene include(regexp) for the exact agg (rawValue) and prefix agg (rawValue + ".*"). The value is the raw user-typed filter term and is never regex-escaped. Two consequences: (1) terms containing regexp metacharacters (e.g. a column name like user.id or v1(beta)) are interpreted as regex — . matches any char so the "exact" agg is not truly exact, and unbalanced [/( produces an invalid Lucene RegExp that throws, failing the whole /search/aggregate call with a 500. The contains agg already had this exposure pre-change, but the PR adds two new unescaped uses (exact and prefix). Consider escaping regexp metacharacters in extractRawSearchValue's output / when building the prefix and exact patterns.

Options

Display: compact → Showing less information.

Comment with these commands to change:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

pmbrull pushed a commit that referenced this pull request Jun 22, 2026
…gation (#29231)

* fix(search): surface exact/prefix matches first in QuickFilter aggregation

Fixes #27945

The /search/aggregate endpoint used a single terms aggregation with
include: ".*term.*", ordered alphabetically with a fixed size=10. When
more than 10 values matched the pattern, exact matches (e.g. "name")
were silently dropped in favour of alphabetically-earlier contains
matches (e.g. "first_name", "display_name").

Replace the single agg with three targeted sub-aggregations sent in one
ES/OS round-trip:
  • __exact   – include: "term"     (size 1, O(1) dict lookup)
  • __prefix  – include: "term.*"   (size N, B-tree prefix scan)
  • __contains – include: ".*term.*" (size N, full wildcard, unchanged)

The backend merges the three bucket lists in priority order
(exact → prefix → contains), deduplicates, trims to the requested size,
and rewrites the response under the original sterms#field key so the
frontend requires no changes.

Add SearchUtils helpers: isBestMatchSearchPattern, extractRawSearchValue,
exactAggKey/prefixAggKey/containsAggKey, mergeBestMatchAggregations.
Cover all helpers and merge edge cases in SearchUtilsTest (12 new tests).

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(search): address PR review — safe fallback, dot-escaping, null guard

- mergeBestMatchAggregations: on merge failure, degrade to renaming
  the __contains sub-agg to sterms#<field> so the UI always receives
  the key it expects; double-catches so even fallback parse failures
  are silent
- buildBestMatchAggregations (ES + OS): escape '.' in rawValue before
  using as Lucene regexp include for exact and prefix sub-aggs, preventing
  field names like 'user.id' from being treated as wildcards and preventing
  unbalanced-regexp 500s
- isBestMatchSearchPattern: guard against null input
- SearchUtilsTest: fix two broken parametrized cases (.* → expected '',
  remove null-passing CSV row), add dedicated null test, add fallback-path
  and dot-escaping tests

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(search): add missing ObjectNode import in SearchUtilsTest

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(search): fix dot-escaping test expectations — trailing .* wildcard must not be escaped

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

---------

Co-authored-by: Claude Sonnet 4.6 <[email protected]>
harshach added a commit that referenced this pull request Jun 23, 2026
…cs (#29201)

* feat(ai): add DERIVED_FROM, Metric.provider, ContextMemory.ontologyStats, AISettings schema

- Append DERIVED_FROM as last entry in entityRelationship.json enum (ordinal-safe)
- Add provider (ProviderType) field to metric.json and createMetric.json
- Add ontologyStats definition and property to contextMemory.json (OntologyStats javaType)
- Create configuration/aiSettings.json (AISettings, MemoryExtractionSettings, OntologyAgentSettings, PromptConfig, AIPrompts, AIDeletionPolicy)
- Register aiSettings in settings.json enum and config_value oneOf
- Add default seed openmetadata-service/src/main/resources/json/data/settings/aiSettings.json

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* feat(ai): AISettings handler, cache seed/merge, and system settings REST branch

Implements Task 2: AISettingsHandler (validate + merge), SettingsCache
seed/merge block for aiSettings.json mirroring searchSettings, and
SystemResource PUT branch + reset extension for AI_SETTINGS.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(ai): propagate AISettings default-load IO errors and single-return reset

- loadDefaultAiSettings now declares throws IOException instead of
  swallowing it with an empty AISettings fallback; call sites in
  createOrUpdateSetting and resetSettingToDefault wrap with try/catch
  and re-throw as SystemSettingsException (matching the searchSettings
  error-handling pattern)
- resetSettingToDefault refactored to if/else-if/else with a single
  trailing return, eliminating the two early returns
- AISettingsHandlerTest: add incomingNullReturnsDefaults and
  nullNestedDefaultInheritsIncoming tests covering null-guard branches

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* feat(ai): gate file/page extraction on AISettings and externalize the extraction prompt

- Add AISettingsUtil: cache-backed AISettings accessor (never null, fails open)
  with isFileExtractionEnabled, isPageExtractionEnabled, isOntologyAgentEnabled,
  memoryExtractionPrompt, ontologyAgentPrompt helpers
- ContextMemoryExtractor.callLlm resolves the system prompt from AISettings at
  runtime, falling back to the SYSTEM_PROMPT constant
- ContextFileProcessingService.process and fileStatusAfterText gate on
  AISettingsUtil.isFileExtractionEnabled in addition to LLMClientHolder.isEnabled
- KnowledgePageRepository.schedulePillExtraction gates on
  AISettingsUtil.isPageExtractionEnabled in addition to LLMClientHolder.isEnabled
- TDD: AISettingsUtilTest written first (RED), then implementation (GREEN)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* feat(ai): ontology verdict DTO boundary

Add OntologyDerivation, OntologyVerdict (Jackson record DTOs with @JsonProperty on every component and @JsonIgnoreProperties), and OntologyAction constants (REUSE/CREATE/SKIP) as the anti-corruption boundary between untrusted LLM JSON and the domain model. Mirrors the KnowledgePill pattern. Covered by OntologyDerivationTest (lenient parse, unknown-field tolerance).

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* feat(ai): ontology grounding + extractor (pure derive)

Add OntologyContext/OntologyCandidate records, OntologyExtractor (calls LLM via completeStructured, returns SKIP/SKIP on empty result), OntologyPromptBuilder (renders memory + candidate lists), and OntologyGrounding (keyword-searches glossary-term/metric/glossary indexes via Entity.getSearchRepository, caps at 20, fails-safe per axis). Covered by OntologyExtractorTest (mocked LLM, two cases: verdict passthrough + empty-→SKIP/SKIP).

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(ai): use existing search/entity constants, dedupe helper, shorten prompt builder

Replace raw "_score"/"desc" with SearchConstants.DEFAULT_SORT_FIELD/DEFAULT_SORT_ORDER,
remove local FIELD_NAME/FIELD_DESCRIPTION in favour of Entity constants, dedupe
nullToEmpty via StringUtils.defaultString, extract renderMemory() so build() fits 15
lines, use CommonUtil.nullOrEmpty for the candidates guard, and replace raw "CREATE"/"SKIP"
string literals in tests with OntologyAction constants.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* feat(ai): ontology reconciler with ownership lifecycle (create/reuse/retire/cascade)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(ai): correct RELATED_TO edge direction, honor deletionPolicy on re-derive, no-op on all-SKIP

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* feat(ai): ontology processing engine with throttle and hash-gate

Adds OntologyProcessingEngine: a trailing-throttle debounce (mirroring
PageContextProcessingEngine) that collapses rapid memory edits into one
derivation run, protected by a SHA-256 content hash-gate so unchanged
memories are never re-derived. stampOntologyStats persists via
recordChange(updateVersion=false) in ContextMemoryUpdater, exactly
mirroring KnowledgePageRepository.recordExtractionStats, so no version
churn occurs and no postUpdate event fires for the stats field.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(ai): accurate recursion-contract docs, split term/metric stat counts, dedup scheduler

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* feat(ai): ContextMemory lifecycle hooks trigger the ontology agent + cascade

postCreate/postUpdate schedule the OntologyProcessingEngine (gated on
AISettingsUtil.isOntologyAgentEnabled). softDelete/hardDelete/restore
AdditionalChildren fire in-edge-window so DERIVED_FROM edges exist when
OntologyReconciler.onMemoryDeleted/onMemoryRestored run. Extracted
AISettingsUtil.deletionPolicy() to remove duplication between the engine
and the repository. Added OntologyReconciler.onMemoryRestored which
restores CASCADE-soft-deleted automation-owned entities (Include.ALL
query; ORPHAN/DEPRECATE-released entities correctly excluded because
their DERIVED_FROM edges were dropped at delete time). Three new unit
tests cover: owned restore, human-adopted skip, orphan-released skip.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* feat(ai): ontology-bot seed and adopt-on-touch provider release guards

Adds the ontology-bot principal seed files (bot + botUser JSON, auto-loaded
by BotResource.initialize at startup), the OntologyOwnership utility class
(centralized ONTOLOGY_BOT_NAME constant + releaseIfHumanEdited guard), and
wires the guard into the entitySpecificUpdate of GlossaryTermUpdater,
MetricUpdater and GlossaryUpdater so a human PATCH that changes an
agent-managed field flips provider AUTOMATION → USER permanently.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* feat(ai): AISettings admin page with toggles and prompt editors

Adds the AISettingsPage under Settings > Preferences with master enable
toggle, memory-extraction and ontology-agent toggles, a deletion-policy
Select, and two system-prompt Textareas. Registers the route, menu item,
and all i18n keys (synced to all 17 locales).

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(ai): i18n the AISettings deletion-policy option labels

Replace raw string literals ('cascade'/'orphan'/'deprecate') in
DELETION_POLICY_OPTIONS with i18n labelKey fields; add new keys
label.cascade / label.deprecate / label.orphan to en-us.json (alphabetical)
and sync all 17 other locales via yarn i18n.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* feat(ai): derived-entity provenance projections on memory/term/metric

Add three read-only derived fields (non-default, resolved at read, never
persisted) to expose File→Memory→Term/Metric provenance:

- ContextMemory.derivedEntities (entityReferenceList): terms+metrics
  created by the Ontology Agent via DERIVED_FROM edges
  (findFrom(memory, CONTEXT_MEMORY, DERIVED_FROM, GLOSSARY_TERM/METRIC))
- ContextMemory.reusedEntities (entityReferenceList): terms+metrics
  reused via RELATED_TO edges
  (findTo(memory, CONTEXT_MEMORY, RELATED_TO, GLOSSARY_TERM/METRIC))
- GlossaryTerm.derivedFrom (entityReference): memory that created the term
  (findTo(term, GLOSSARY_TERM, DERIVED_FROM, CONTEXT_MEMORY))
- Metric.derivedFrom (entityReference): memory that created the metric
  (findTo(metric, METRIC, DERIVED_FROM, CONTEXT_MEMORY))

Edge directions verified against OntologyReconciler Task-6 code:
addDerivedFromEdge stores from=entity→to=memory; reuse() stores
from=memory→to=entity for RELATED_TO.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* test(ai): integration tests for AISettings + ontology agent lifecycle

AISettingsResourceIT: deterministic GET/PUT/reset tests for /system/settings/aiSettings
covering default values (enabled=true, deletionPolicy=cascade), PUT persistence, and reset.

OntologyAgentIT: deterministic lifecycle tests seeding DERIVED_FROM edges via in-process
repository to replicate the reconciler's CREATE path, then driving cascade delete,
adopt-on-touch (provider flip), and derivedFrom/derivedEntities projection fields through
the public REST API without any LLM dependency.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* feat(ai): File→Memory→Term/Metric provenance panels in the UI

- Add derivedEntities/reusedEntities to ContextMemory generated type
- Add derivedFrom to GlossaryTerm and Metric generated types
- Add DERIVED_FROM/DERIVED_ENTITIES/REUSED_ENTITIES to TabSpecificField enum
- Add getContextMemoryById to contextMemoryAPI
- Create DerivedOntologyCard component (+ interface + test): fetches
  derivedEntities/reusedEntities from a memory and renders linked lists
- Embed DerivedOntologyCard into CreateMemoryModal view-only mode so
  every memory's derived/reused ontology is visible when viewing a memory
- Add derivedFrom field to GLOSSARY_TERM_DEFAULT_FIELDS and METRIC_DEFAULT_FIELDS
- Add "Derived from memory" link in GlossaryTermsV1 and MetricDetails when
  derivedFrom is present on the entity
- Add i18n keys: label.derived-from-memory, label.derived-ontology,
  label.reused, message.no-derived-ontology (synced to 19 locales)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(ai): seed/serve aiSettings correctly so GET /system/settings/aiSettings returns defaults

CollectionDAO$SettingsRowMapper.getSettings lacked an AI_SETTINGS case in its
switch, causing every getConfigWithKey("aiSettings") call to throw
IllegalArgumentException (swallowed, returning null) → HTTP 204 on every GET.
Added the missing case so aiSettings rows deserialise to AISettings.

Also fixed resetSettingToDefault for AI_SETTINGS: it was returning defaults
without persisting them to the DB (unlike the equivalent searchSettings reset
path which calls systemRepository.createOrUpdate). Now it persists first.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(ai): seed AUTOMATION provider via createInternal and set id/updatedAt so cascade, adopt-on-touch, and projection ITs all pass

The test helper createAutomationTerm used create-via-REST + termRepo.update to
set provider=AUTOMATION, but the EntityRepository update framework only writes to
DB when entityChanged=true; provider is not tracked by recordChange so the write
was silently no-op'd. Term stayed provider=null in the DB, causing:
- Scenario A timeout: isAutomationOwned read null, cascade skipped the term
- Scenario B: assertEquals(USER, null) failed at assertion after human PATCH
- Scenario C: cascade skipped term, glossary.delete failed with "glossary is not empty"

Fix: replace the two-step seed with termRepo.createInternal() directly, mirroring
OntologyReconciler.createTerm exactly. Also fixed the reconciler itself: createTerm,
createMetric, and resolveOrMintGlossary all called createInternal without setting id
or updatedAt; PostgreSQL GENERATED columns extract both from the stored JSON with
NOT NULL constraints, so omitting them would cause constraint failures in production.

Result: OntologyAgentIT 3/3 GREEN; OntologyReconcilerTest 20/20 + OntologyOwnershipTest
7/7 no regression.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(ai): wire AISettings reset-to-default, strengthen util test, import @transaction

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* docs(ai): document AISettings + Ontology Agent (§19) in the company-context spec

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* Update generated TypeScript types

* fix(ai): use design tokens and carry source-memory identity in provenance links

Replace palette classes (text-gray-500/400/900, text-brand-600) with semantic
tokens (text-tertiary, text-brand-secondary). Link both provenance anchors to
ROUTES.CONTEXT_CENTER_MEMORIES?memory=<name> so the memories-list auto-opens
the correct memory's view modal on arrival.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(ai): gate per-axis derive toggles, validate LLM entity names, narrow catches

- OntologyReconciler: add 5-arg reconcile() with explicit deriveTerms/deriveMetrics
  flags; reconcileAxis() gates BOTH apply and retire per flag, preventing mass-retire
  bug in the reviewer's suggested null-implied approach
- OntologyReconciler: isValidName() guards CREATE paths for term, metric, glossary
  mint — null/blank or FQN-reserved chars (. " /) become a logged SKIP instead of
  thrown exception (Fix #2+#6)
- OntologyProcessingEngine: read AISettings once in derive(), compute axis flags via
  deriveTermsEnabled/deriveMetricsEnabled helpers, pass to 5-arg reconcile() — no
  more settings coupling inside reconciler
- Narrow Exception catches: AISettingsUtil → RuntimeException; OntologyGrounding →
  IOException|RuntimeException; OntologyProcessingEngine#runScheduled → RuntimeException
  with explanatory comment (Fix #5)
- OntologyReconcilerTest: 4 new tests covering null/invalid-name SKIP behavior
  (27 total, 0 failures)
- OntologyAgentIT Scenario E: fully deterministic axis-toggle coverage — seeds
  AUTOMATION-owned metric, calls 5-arg reconcile with deriveMetrics=false, asserts
  0 metrics created + 0 retired + owned metric survives (4 tests, 0 failures)

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(ai): stamp content hash on reconcile failure to prevent re-derive poison-pill loop

Wrap reconciler.reconcile() in reconcileSafely() which catches RuntimeException,
logs the error with memory id, and returns null so the derive() method always
reaches stampOntologyStats(). buildStats() is made null-safe (zero counts when
result is null). LLM/network stages (fetchCandidates, extractor.derive) remain
outside the guard so transient failures still propagate and retry. Adds
stampsHashEvenWhenReconcileThrows test to prove the loop is broken.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(ai): fetch memories list with generic sourceEntity, not deprecated sourceFile

Page-sourced memories resolve their source via the generic sourceEntity ref;
the deprecated sourceFile alias only covers file-sourced ones.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(ai): reuse existing term/metric on FQN collision and cancel pending run on memory delete

P1: OntologyReconciler.createTerm/createMetric now precheck the target FQN via
findByFqn(repo, fqn) (NON_DELETED) before calling createInternal; on collision
they call reuseExisting() (same RELATED_TO edge + counts.reused++) instead of
throwing a unique-constraint violation. resolveOrMintGlossary also checks by
newGlossaryName before minting a duplicate glossary. Three new unit tests cover
the term-FQN-collision, metric-FQN-collision, and glossary-reuse-by-name paths.

P2: ContextMemoryRepository.softDeleteAdditionalChildren/hardDeleteAdditionalChildren
now call OntologyProcessingEngine.instance().cancel(memoryId) via a shared
cancelAndCascadeOntology helper before cascadeOntology, so any pending scheduled
derivation is cancelled when a memory is deleted, preventing spurious
EntityNotFoundException in runScheduled.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(ai): null-guard the LLM verdict list in OntologyExtractor.derive

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(ui): align AISettingsPage to codegen DeletionPolicy enum name

The TS-codegen bot regenerated aiSettings.ts exporting the enum as
DeletionPolicy (from the deletionPolicy schema key), not AIDeletionPolicy.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* feat(ai): centralize MCP Server and MCP Chat into AI Settings

MCP Server and MCP Chat are no longer internal Applications; they are managed
as platform settings.

- MCP Chat: new aiSettings.mcpChat (enabled + systemPrompt) drives a runtime
  McpChatServiceHolder, re-initialized on AI settings save/reset so chat
  toggles without a restart; McpClientResource reads the holder.
- MCP Server: registerMCPServer gates on mcpConfiguration.enabled (seeded by
  default) instead of an installed app; configurable via /system/mcp/config.
- McpApplicationBot seeded as a system bot with impersonation; McpApplication
  and McpChatApplication entities, marketplace defs and the mcpChatAppConfig
  schema removed.
- MCP usage telemetry re-anchored to a constant identity (read history kept).
- AI Settings page adds MCP Chat and MCP Server sections; chat sidebar gated
  on the setting.
- 2.0.0 migration carries prior app config/enablement into settings, then
  retires the apps (keeping the bots).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* Update generated TypeScript types

* refactor(ai): rename Ontology Agent to Memory Agent

Rename the agent's identity from "Ontology Agent" to "Memory Agent"
across all layers: the drive/ontology Java package and its Ontology*
pipeline/DTO classes, OntologyOwnership, the ontology-bot principal,
the aiSettings ontologyAgent config key, the ContextMemory
ontologyStats/OntologyProcessingStatus fields, the OntologyStatusBadge
UI component, and the ontology-agent i18n labels (synced across all
locales). Java models and generated TS types are regenerated from the
renamed schemas.

The unrelated Ontology Explorer (RDF glossary graph) feature and the
output-concept "Derived Ontology" provenance panels are intentionally
left unchanged, since they name the derived term/metric graph rather
than the agent.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* Update generated TypeScript types

* fix(ai): show MCP Chat in sidebar via setting + restrict MCP Server config

- MCP Chat sidebar: add authenticated GET /mcp-client/enabled and gate the
  McpChatPlugin sidebar entry on aiSettings.mcpChat.enabled. It was tied to the
  removed app, so it never appeared after enabling chat in AI Settings.
- MCP Server settings: expose only the enable toggle and Origin Header URI; the
  endpoint path is fixed at /api/v1/mcp and no longer editable; drop the origin
  validation and allowed origins fields.
- EnumBackwardCompatibilityTest: account for the appended DERIVED_FROM
  relationship (count 26 -> 27, new last ordinal).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(ai): drop MCP Chat config migration; derive MCP usage appId from name

- The MCP Chat app was never shipped to customers, so the 2.0.0 migration no
  longer carries its config into aiSettings.mcpChat — the seeded default shape
  is kept. Server enable-alignment and dead-app cleanup remain.
- McpToolCallUsage.appId: no MCP-usage query reads it (recorder writes, resource
  reads by appName), but apps_extension_time_series.appId is a NOT NULL generated
  column, so a value is required. Derive it deterministically from MCP_APP_NAME
  instead of a hardcoded UUID.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* format

* fix(ai): commit missing MemoryRelation DTO blocked by .gitignore

The bare `memory` pattern in .gitignore (a claude-flow tooling entry)
also matched the drive/memory Java package, so the newly added
MemoryRelation.java was silently ignored and never committed — breaking
CI with "cannot find symbol MemoryRelation" in MemoryVerdict and
MemoryReconciler. Scope the ignore to root-level /memory/ and add the file.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(ai): make file-extraction LLM gate fully injectable (fix unit tests)

ContextFileProcessingService gated knowledge-pill extraction on BOTH the
injected llmEnabledSupplier AND a direct static
AISettingsUtil.isFileExtractionEnabled(AISettingsUtil.get()). The static
read needs a live SettingsCache, so ContextFileProcessingServiceTest
(which injects the gate as () -> true) could not satisfy it: extraction
was skipped and 3 tests failed (wrong repository.update counts,
runExtraction never invoked).

Fold the AISettings check into the production default supplier and route
both call sites through one shouldExtractContext(...) helper, so the
status machine is unit-testable and the repeated compound condition lives
in one place. Production gate (LLM enabled AND file-extraction toggle) is
unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(ui): add missing label.general i18n key for AI Settings

AISettingsPage referenced t('label.general') but the key was absent
from en-us.json. Added it and synced all locale files via yarn i18n.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(ui): repair AISettingsPage and CreateMemoryModal jest mocks

AISettingsPage imports Input from ui-core-components but the test mock
omitted it, so the component rendered an undefined element ("Element type
is invalid"). Add the Input mock plus the missing settingConfigAPI mocks
(getMcpConfiguration/restoreSettingsConfig/updateMcpConfiguration) the
component calls.

CreateMemoryModal's partial DateTimeUtils mock dropped
getEpochMillisForPastDays, which profiler.constant.ts invokes at module
load via a deep import chain, failing the suite at import. Spread
requireActual to preserve the real exports, and stub DerivedOntologyCard
to cut the heavy transitive chain (EntityUtilClassBase -> DataProductsPage
-> ConnectionStepCard) that also pulled in unmocked antd internals.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* build(deps): bump undici from 6.25.0 to 6.27.0 and form-data to 4.0.5 in /openmetadata-ui/src/main/resources/ui (#29241)

* build(deps): bump undici in /openmetadata-ui/src/main/resources/ui

Bumps [undici](https://github.com/nodejs/undici) from 6.25.0 to 6.27.0.
- [Release notes](https://github.com/nodejs/undici/releases)
- [Commits](nodejs/undici@v6.25.0...v6.27.0)

---
updated-dependencies:
- dependency-name: undici
  dependency-version: 6.27.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

* update yarn

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Harsh Vador <[email protected]>

* change index from all to dataAsset for my data (#29209)

* change index from all to dataAsset for my data

* fix jest tests

* fix playwrights

* fix playwrights

---------

Co-authored-by: Shrabanti Paul <[email protected]>

* fix(fqn): support double-quotes in fully qualified names + guard/repair corrupt FQNs (#28697)

* fix(fqn): support double-quotes in fully qualified names + guard/repair corrupt FQNs

Names containing a double-quote could not be represented in an FQN: the Fqn
grammar had no escape mechanism, yet quoteName() backslash-escaped the quote and
stored an unparseable segment. Building the FQN is a pure string op, so such
values were written successfully (insert hashes only the entity's own FQN); they
then detonated later with a 500 (ParseCancellationException) the first time a
nested FQN was hashed (e.g. a tags read), and were painful to migrate.

Three layered fixes:

- Grammar + quoteName: NAME_WITH_RESERVED now allows any character with '"'
  escaped by doubling it (""). quoteName/unquoteName encode/decode accordingly
  and are idempotent. Names without a quote encode identically to before, so
  existing FQNs and their hashes are unchanged (no reindex/migration needed).

- Ingest guard: FullyQualifiedName.validateFqnName() asserts a name round-trips
  through encode->parse->decode, wired into every nested-FQN setter (columns,
  pipeline tasks, topic/searchIndex/apiEndpoint fields, mlFeatures). A name that
  cannot be hashed is now rejected at ingest with a clear 400 instead of being
  stored to fail later.

- Heal-on-read: FullyQualifiedName.isValid() detects legacy-corrupt FQNs;
  PipelineRepository repairs unparseable task FQNs on the fly by re-deriving them
  from the task name, so existing poisoned data reads cleanly (200) without a
  migration. The repair is in-memory and persists on the next update.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(fqn): repair corrupt pipeline task FQNs via migration, not heal-on-read

Heal-on-read (PipelineRepository.repairTaskFqns) ran a full ANTLR parse for
every task on every pipeline read to subsidize a finite set of already-corrupt
rows, was incomplete (the bulk/LIST/search path still 500'd), and could NPE on
a null task FQN. Replace it with a one-time migration so the corruption leaves
the stored data and reads pay no per-request cost.

- Remove repairTaskFqns and its setFields() call; keep the validateFqnName
  write-path guard that rejects un-representable names at ingest (400).
- Add migration v11211 (mysql + postgres): re-derive task FQNs where !isValid,
  persist only when changed.
- Harden FullyQualifiedName.isValid to treat null/empty as invalid (no NPE).
- Require >=1 char inside a quoted FQN segment (grammar + not *), rejecting
  empty quoted segments ("").

FullyQualifiedNameTest: 17/17.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(fqn): reject empty nested-object names at write time

validateFqnName returned early when quoteName(name) was unchanged, letting
empty names through (quoteName("") == ""). An empty pipeline task name (the
schema sets no minLength on task.name) then produced an unhashable empty FQN
segment ("parent.") that 500'd on the next FQN hash -- the same failure class
as unrepresentable names. Treat null/empty as invalid so every nested-FQN
setter (columns, tasks, fields, mlFeatures) rejects them up front with a 400.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(fqn): make pipeline task-FQN migration batched and observable

Address review feedback on the one-time repair migration:

- Performance: scan pipelines in pages of 1000 via listAfterWithOffset instead
  of selecting every id and calling findEntityById per pipeline, dropping the
  N+1 round-trips and the full id list held in memory. Only changed rows are
  written.
- Observability: track scanned/repaired/failed counts and log a prominent WARN
  with up to 100 pipeline ids that could not be repaired, instead of swallowing
  each failure as a lone WARN, so operators get a concrete remediation list.
- Search: document (completion log + schemaChanges) that repaired task FQNs are
  reflected in the search index after the standard post-upgrade reindex, matching
  existing FQN-fix migration behavior.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* test(fqn): cover pipeline task-FQN repair migration

Add MigrationUtilTest for the v11211 repairPipelineTaskFqns migration:
repair correctness (re-derive unparseable/null task FQNs, leave valid ones
untouched, skip task-less pipelines) and migration-path resilience -- a single
unreadable row or a failing update must not abort the upgrade.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* test(fqn): cover repair-migration pagination across pages

The existing repair-migration tests stubbed listAfterWithOffset for any
offset and returned data only at offset 0, so every case exercised a
single page. Add a test that stubs distinct pages by offset
(0 -> page 1, 1000 -> page 2, 2000 -> empty) and asserts the second page
is scanned and repaired, locking in correct limit/offset ordering and
offset advancement in repairPipelineTaskFqns.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* chore(migration): retarget pipeline task-FQN repair to 1.13.1

Move the pipeline task-FQN repair migration from 1.12.11 (package v11211)
to 1.13.1 (package v1131): the native SQL placeholder dir, the mysql and
postgres Migration handlers, the MigrationUtil, and its test. The
framework derives the handler package from the version dir via
MigrationFile.getVersionPackageName(), so 1.13.1 -> v1131; no logic
changes. Pure data migration, no DDL.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(fqn): correct repair-migration summary counts; unscope 1.13.1 DDL

Addresses code review on the 1.13.1 pipeline task-FQN repair migration.

1. Failed-to-persist pipelines were double-counted in the summary log.
   repairPipeline kept taskCount > 0 when pipelineDAO.update threw, so a row
   that never persisted was reported as both "re-derived N task FQNs" and
   "could not fix N pipeline(s)", overstating success. Reset taskCount to 0
   on the persistence-failure path so only rows that actually persisted count
   as repaired. repairPipelineTaskFqns now returns a RepairSummary so the
   counts are asserted directly (doesNotCountFailedPersistAsRepaired fails
   without the fix). The Migration handlers ignore the return value.

2. Revert bootstrap/sql/migrations/native/1.13.1/{mysql,postgres}/
   schemaChanges.sql to match main exactly. The intake_form_entity DDL there
   belongs to main (consumed by IntakeFormDAO) and arrived via the main
   merge, not this PR; only a local comment was added on top. Dropping that
   comment makes this PR's net change to those files zero and removes the
   "data migration only" text that contradicted the DDL. The FQN repair runs
   via the Java v1131 Migration handler and needs no SQL.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* Add migration for variuos childresn entities

---------

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Sriharsha Chintalapani <[email protected]>
Co-authored-by: Sriharsha Chintalapani <[email protected]>

* fix(mcp): OAuth login fails with 400 when SSO returns id_token in URL fragment (#29228)

* fix(mcp): handle active-session shortcut and implicit-flow fragment at /mcp/callback

Root cause: when a user has an active Google/Azure SSO session,
AuthenticationCodeFlowHandler.handleLogin() bypasses pac4j entirely and
calls sendRedirectWithToken() directly, committing the response as
302 /mcp/callback#id_token=... (token in URL fragment, no pac4j state).

This caused three failures:
1. UserSSOOAuthProvider.handleSSOAuthorization() found no pac4j state in
   session (expected — pac4j was never invoked) and threw AuthorizeException.
2. AuthorizationHandler.exceptionally() turned the exception into an error
   redirect URL; handleAuthorizeRequest() then called sendRedirect() on an
   already-committed response → IllegalStateException: Committed at line 503.
3. McpCallbackServlet received the callback with #id_token=... in the URL
   fragment (browser-only, server never sees it), so both pac4jState and
   idTokenParam were null → 400 'missing state'.

Fixes:
- UserSSOOAuthProvider: check response.isCommitted() before throwing;
  return SSO_REDIRECT_INITIATED for the active-session path.
- OAuthHttpStatelessServerTransportProvider: guard sendRedirect() with
  response.isCommitted() check to prevent Committed exception.
- McpCallbackServlet: serve a JS fragment-extraction page instead of
  returning 400 — JS reads window.location.hash, extracts id_token,
  retries /mcp/callback?id_token=... so handleDirectIdTokenFlow() runs.

Also adds debug logging throughout the MCP auth flow for easier
diagnosis of future SSO/OAuth callback issues.

* fix(mcp): address review — POST token from fragment, fix log field, import Collections

- serveFragmentExtractionPage: switch from GET redirect to form POST so
  the id_token never appears in a URL, browser history, or access logs
  (RFC 6819 §5.3.5). Add doPost() that reads id_token from the body and
  delegates to handleDirectIdTokenFlow().
- McpCallbackServlet debug log: rename hasFragment→refererPresent with a
  boolean so the field is meaningful (server cannot observe the fragment).
- UserSSOOAuthProvider: replace java.util.Collections FQN with import +
  simple name per project Java standards.

* Update openmetadata-mcp/src/main/java/org/openmetadata/mcp/server/auth/handlers/McpCallbackServlet.java

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* fix(mcp): address review — if/else in doPost, textContent XSS fix, unit tests

- doPost: replace early-return guard clauses with if/else per project standard
  (one return statement per method)
- serveFragmentExtractionPage: replace innerHTML with textContent in both
  error branches to eliminate the JS XSS antipattern (greptile finding)
- McpCallbackServlet: package-private constructor for test injection;
  resolveSsoHandler() promoted to protected for subclass override in tests
- Add McpCallbackServletTest: 7 tests covering serveFragmentExtractionPage
  (content-type, form POST shape, textContent usage) and doPost edge cases
  (null handler→503, null/empty id_token→400)
- Add OAuthHttpStatelessServerTransportProviderTest: 4 tests covering
  sanitizeRedirectUrlForLogging (with/without query, null) and the
  committed-response guard

* fix(mcp): CSRF protection on doPost; remove vacuous guard test; real CSRF tests

Security (P1): doPost accepted cross-origin form submissions without any
CSRF check. A malicious site holding a valid id_token for a different user
could craft a form targeting /mcp/callback and hijack a victim's pending
MCP auth session (victim's Claude Desktop authenticates as the attacker).

Fix: add isOriginAllowed() — rejects any POST whose Origin header does not
match the server's own base URL (resolved from MCP config or system
settings). Absent Origin (same-origin browsers may omit for non-CORS
requests) is treated as allowed. Package-private for testability.

Test quality: remove the vacuous handleAuthorizeRequest guard test that
never called the method under test and trivially passed — replaced with
a comment noting the guard is covered at integration level. Replace with
4 real CSRF tests: Origin absent, matching, mismatched, and full doPost
403 path verification.

* fix(mcp): CSRF default-port normalization and reject-on-unknown-origin

* refactor(mcp): string constants + lazy-cache server origin

- Extract all sendError message strings to package-visible static final
  constants (ERR_SSO_UNAVAILABLE, ERR_CSRF_ORIGIN_MISMATCH,
  ERR_MISSING_ID_TOKEN, ERR_CALLBACK_FAILED, ERR_MISSING_STATE,
  ERR_STATE_NOT_FOUND). Eliminates magic strings, gives callers a stable
  contract, catches typos at compile time.
- Add cachedServerOrigin volatile field + getServerOrigin() lazy-init
  helper: resolveServerOrigin() is now called at most once per server
  lifetime instead of on every POST. Non-null results are cached;
  null results (transient DB miss at startup) are not cached so the
  next request retries — fail-secure without permanently breaking CSRF.
- Update tests to reference constants instead of duplicating literals.
- Add two cache-behaviour tests: verifies resolveServerOrigin() is
  called exactly once after a successful resolution, and called again
  on each request when it returns null (no caching of null).

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* Load learning drawer chunk without a page-loader flash (#29280)

LearningIcon always mounts the lazy LearningDrawer, so its Suspense
fallback rendered the centered page Loader inline next to the icon on
mount, before any user interaction.

Make the fallback configurable on withSuspenseFallback (still defaults to
the existing Loader, so all current callers are unchanged) and have
LearningIcon opt out with null. The chunk now loads silently while the
drawer stays mounted, preserving the close animation and the in-drawer
resource player that relies on the drawer not unmounting.

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>

* Fixes #27945: surface exact/prefix matches first in QuickFilter aggregation (#29231)

* fix(search): surface exact/prefix matches first in QuickFilter aggregation

Fixes #27945

The /search/aggregate endpoint used a single terms aggregation with
include: ".*term.*", ordered alphabetically with a fixed size=10. When
more than 10 values matched the pattern, exact matches (e.g. "name")
were silently dropped in favour of alphabetically-earlier contains
matches (e.g. "first_name", "display_name").

Replace the single agg with three targeted sub-aggregations sent in one
ES/OS round-trip:
  • __exact   – include: "term"     (size 1, O(1) dict lookup)
  • __prefix  – include: "term.*"   (size N, B-tree prefix scan)
  • __contains – include: ".*term.*" (size N, full wildcard, unchanged)

The backend merges the three bucket lists in priority order
(exact → prefix → contains), deduplicates, trims to the requested size,
and rewrites the response under the original sterms#field key so the
frontend requires no changes.

Add SearchUtils helpers: isBestMatchSearchPattern, extractRawSearchValue,
exactAggKey/prefixAggKey/containsAggKey, mergeBestMatchAggregations.
Cover all helpers and merge edge cases in SearchUtilsTest (12 new tests).

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(search): address PR review — safe fallback, dot-escaping, null guard

- mergeBestMatchAggregations: on merge failure, degrade to renaming
  the __contains sub-agg to sterms#<field> so the UI always receives
  the key it expects; double-catches so even fallback parse failures
  are silent
- buildBestMatchAggregations (ES + OS): escape '.' in rawValue before
  using as Lucene regexp include for exact and prefix sub-aggs, preventing
  field names like 'user.id' from being treated as wildcards and preventing
  unbalanced-regexp 500s
- isBestMatchSearchPattern: guard against null input
- SearchUtilsTest: fix two broken parametrized cases (.* → expected '',
  remove null-passing CSV row), add dedicated null test, add fallback-path
  and dot-escaping tests

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(search): add missing ObjectNode import in SearchUtilsTest

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(search): fix dot-escaping test expectations — trailing .* wildcard must not be escaped

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

---------

Co-authored-by: Claude Sonnet 4.6 <[email protected]>

* fix(search): cap oversized dataModel column tree at index time (#29212)

* fix(search): cap oversized dataModel column tree at index time

A container/table with a pathologically large dataModel (a wide/nested schema with hundreds of thousands of columns) produces a multi-hundred-MB search document. The existing oversized-doc guard strips lineage but then ships the doc anyway, so the server stores ~196MB, parses it whole on every read and reindex, and can OOM.

Extend stripDocMapIfOversized (live index) and stripLineageForSize (bulk reindex) to also strip the nested column children and the derived columnNames/columnNamesFuzzy when the doc is still over the cap after lineage stripping. Top-level columns are kept, so column search and the column grid still work; the full schema stays available via the entity API. Gated by size, so normal entities are untouched. The nested children are mapped enabled:false (stored, not indexed), so nothing searchable is lost.

This bounds the indexed document at the source, so the server never holds the giant doc on read or reindex — complementing the read-side response streaming.

* perf(search): compute oversized-doc size once per mutation in strip path

Thread the serialized byte size through a local in stripDocMapIfOversized and stripLineageForSize instead of re-serializing the full document for each size gate and log line. On the oversized path this avoids redundant ~hundreds-of-MB pojoToJson/getBytes allocations exactly when memory and CPU are most constrained. Addresses review feedback on #29212.

* refactor(search): guard upstreamLineage strip and reuse post-strip size in logs

Guard the upstreamLineage removal in stripLineageForSize with a null check to match stripDocMapIfOversized, avoiding a wasted full-doc serialization and a misleading WARN when the field is absent on an oversized doc. Store the post-strip serialized size in a local for the column-strip log lines instead of recomputing inline. Addresses review feedback on #29212.

* fix(ui): exclude dataModel from Explore/suggestion search payloads

Complements the index-time column-tree strip (#29212): exclude dataModel from Explore and search-suggestion payloads, lazy-fetch it in the container summary panel via getContainerByFQN when absent, and make the service-insights asset-count query aggregation-only (pageSize 0, fetchSource false). Ported from #29200 so the index-side and UI-side fixes ship together. Relates to #29210.

* fix(search): address PR review — strip docs/logs + summary-panel error handling

Backend: document the column-tree strip in stripLineageForSize JavaDoc and include columnNamesFuzzy in both oversized-doc WARN logs. UI: in the container summary panel's on-demand dataModel fetch, reset previously-fetched columns when the container changes (so the prior container's schema isn't shown) and surface fetch failures via showErrorToast instead of silently rendering 'No data'. Addresses review comments on #29212.

* fix(ui): clear stuck loader on container switch + test on-demand dataModel fetch

Address follow-up review on the summary-panel lazy-fetch: clear isColumnsLoading in the effect's early-return so a now-cancelled in-flight getContainerByFQN can't leave the loader stuck on. Add tests covering the on-demand fetch (fires only when columns are absent from the search hit, not fetched when inline, and surfaces a toast on failure). Addresses review comments on #29212.

* fix(ui): prevent No-data flash on summary-panel mount + fix import order

Lazily initialize isColumnsLoading (loading when columns must be fetched on demand) so the container summary panel shows the loader on first render instead of briefly flashing 'No data available' (greptile P1). Also reorder imports (TablePureUtils before ToastUtils, drop stray blank) to fix UI checkstyle. Addresses review on #29212.

* fix(ui): align glossary term Related Terms section inside the left panel (#29284)

* fix(ui): align glossary term Related Terms section inside the left panel

* added unit test

* fix lint checks

* fix(ui): prevent ontology relations graph from crashing on large glossaries (#29270)

* fix(ui): prevent ontology relations graph from crashing on large glossaries

* nit

* fix(playwright): stop SSORenewal nightly flake from too-short token TTL (#29268)

The SSO Session Renewal suite swaps the server to a short SAML JWT TTL before
logging in. At 10s, on a loaded CI runner the initial app bootstrap
(loggedInUser, config, permissions) outran that window, so the first
/permissions fetch 401'd mid-load; the silent refresh succeeded but the
bootstrap request was not retried, leaving the app wedged on the global loading
spinner. dropdown-profile never rendered and the renewal tests timed out,
exhausting all retries on the 2026-06-22 nightly (run 27929661599).

- Raise SHORT_ACCESS_TTL_SECONDS 10 -> 30 so the token outlives bootstrap. 30s
  stays under EXPIRY_THRESHOLD_MILLES (60s), so the proactive-renewal timer
  still fires immediately and the refresh-on-expiry behavior under test is
  unchanged.
- Wait for dropdown-profile at the end of loginViaSaml so login is only "done"
  once the app shell has rendered, making any future bootstrap hang fail in
  beforeAll with a clear cause instead of mid-test.

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>

* fix(exasol): flush statistics before polling Exasol audit tables in integration tests (#29278)

* test(ui): update MCP Playwright specs for settings-driven MCP

- AISettings.spec: MCP Server section now exposes only Enable + Origin Header
  URI (path/originValidation removed), so assert/fill the origin header instead
  of the removed mcp-server-path field.
- McpChat.spec: enable MCP Chat via aiSettings.mcpChat.enabled (PUT
  /system/settings) and reset it afterwards, instead of installing the retired
  McpChatApplication app (which now 404s).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Harsh Vador <[email protected]>
Co-authored-by: shrabantipaul-collate <[email protected]>
Co-authored-by: Shrabanti Paul <[email protected]>
Co-authored-by: Mohit Yadav <[email protected]>
Co-authored-by: Sriharsha Chintalapani <[email protected]>
Co-authored-by: Sriharsha Chintalapani <[email protected]>
Co-authored-by: Vishnu Jain <[email protected]>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: Sid <[email protected]>
Co-authored-by: Chirag Madlani <[email protected]>
Co-authored-by: sonika-shah <[email protected]>
Co-authored-by: Anujkumar Yadav <[email protected]>
Co-authored-by: harshsoni2024 <[email protected]>
chirag-madlani added a commit that referenced this pull request Jun 24, 2026
…gation (#29231)

* fix(search): surface exact/prefix matches first in QuickFilter aggregation

Fixes #27945

The /search/aggregate endpoint used a single terms aggregation with
include: ".*term.*", ordered alphabetically with a fixed size=10. When
more than 10 values matched the pattern, exact matches (e.g. "name")
were silently dropped in favour of alphabetically-earlier contains
matches (e.g. "first_name", "display_name").

Replace the single agg with three targeted sub-aggregations sent in one
ES/OS round-trip:
  • __exact   – include: "term"     (size 1, O(1) dict lookup)
  • __prefix  – include: "term.*"   (size N, B-tree prefix scan)
  • __contains – include: ".*term.*" (size N, full wildcard, unchanged)

The backend merges the three bucket lists in priority order
(exact → prefix → contains), deduplicates, trims to the requested size,
and rewrites the response under the original sterms#field key so the
frontend requires no changes.

Add SearchUtils helpers: isBestMatchSearchPattern, extractRawSearchValue,
exactAggKey/prefixAggKey/containsAggKey, mergeBestMatchAggregations.
Cover all helpers and merge edge cases in SearchUtilsTest (12 new tests).

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(search): address PR review — safe fallback, dot-escaping, null guard

- mergeBestMatchAggregations: on merge failure, degrade to renaming
  the __contains sub-agg to sterms#<field> so the UI always receives
  the key it expects; double-catches so even fallback parse failures
  are silent
- buildBestMatchAggregations (ES + OS): escape '.' in rawValue before
  using as Lucene regexp include for exact and prefix sub-aggs, preventing
  field names like 'user.id' from being treated as wildcards and preventing
  unbalanced-regexp 500s
- isBestMatchSearchPattern: guard against null input
- SearchUtilsTest: fix two broken parametrized cases (.* → expected '',
  remove null-passing CSV row), add dedicated null test, add fallback-path
  and dot-escaping tests

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(search): add missing ObjectNode import in SearchUtilsTest

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(search): fix dot-escaping test expectations — trailing .* wildcard must not be escaped

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

---------

Co-authored-by: Claude Sonnet 4.6 <[email protected]>
(cherry picked from commit 26c9b51)
harshach added a commit that referenced this pull request Jun 26, 2026
SearchUtilsTest carried a dead `java.util.Arrays` import (pre-existing on
1.13, introduced by #29231). The java-checkstyle CI runs root
`mvn spotless:apply` and fails on any repo-wide diff, so this dead import
blocks the check on this PR. Removing it is exactly what spotless:apply
produces.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

This branch was previously deployed

1 inactive deployment
test — b46c0465 Deployed Jun 22, 2026 by chirag-madlani via playwright-ci-postgresql (1, 6) #52274
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.

Advanced Search Column is displaying missing values.

3 participants