Skip to content

fix(search): drop flattened/flat_object highlight fields before query - #28674

Closed
mohityadav766 wants to merge 12 commits into
mainfrom
fix-highlight-flattened-fields
Closed

mohityadav766 wants to merge 12 commits into
mainfrom
fix-highlight-flattened-fields

Conversation

@mohityadav766

@mohityadav766 mohityadav766 commented Jun 3, 2026 •

Copy link
Copy Markdown
Member

Summary

When SearchSettings has a highlight field that targets a flattened
(Elasticsearch) / flat_object (OpenSearch) mapping subfield — most
commonly a custom property under extension.*, but also columns.children.*,
columns.extension.*, dataModel.columns.*, or schema-field children paths
— the search source builders were forwarding it straight into the highlight
clause.

Subfields of those mappings are stored as raw keywords with no
analyzer
, so the highlight phase fails at the shard level with
Field [...] has no associated analyzer. That surfaces to the caller
as all shards failed, returns a 500 from /v1/search/query, and
breaks every workflow that runs the affected query (e.g. Automator
matching containers). Reindexing does not fix this — the bad config
lives in Search Settings, not in the index.

The customer-visible exception:

org.openmetadata.sdk.exception.SearchException: Search failed due to
Request failed: [search_phase_execution_exception] all shards failed
| Root cause: [illegal_argument_exception:
Field [extension.foundry_rid] has no associated analyzer]

This change adds a single source of truth for the set of flattened
field paths on SearchSourceBuilderFactory and filters configured
highlight fields against it in both OpenSearchSourceBuilderFactory.buildHighlightsV2
and ElasticSearchSourceBuilderFactory.buildHighlightsV2. Dropped
fields are logged at DEBUG. The query stays valid and the customer no
longer needs to manually toggle Highlight Fields off to unblock.

The audit covered every index mapping under
openmetadata-spec/src/main/resources/elasticsearch/. The full set of
flattened paths now centralized:

Path Where it appears
extension 27 entity indexes
columns.extension, columns.children table, worksheet, dashboard_data_model
dataModel.columns.extension, dataModel.columns.children container
fields.children search_entity
messageSchema.schemaFields.children topic
requestSchema.schemaFields.children, responseSchema.schemaFields.children api_endpoint

If a new flattened field is added to any mapping in the future, add
its dotted path to FLATTENED_FIELD_PATHS to keep highlight safe.

Files changed

  • openmetadata-service/.../search/SearchSourceBuilderFactory.java — new FLATTENED_FIELD_PATHS set, isHighlightUnsafeField, filterHighlightSafeFields
  • openmetadata-service/.../search/opensearch/OpenSearchSourceBuilderFactory.java — sanitize highlight fields in buildHighlightsV2
  • openmetadata-service/.../search/elasticsearch/ElasticSearchSourceBuilderFactory.java — sanitize highlight fields in buildHighlightsV2
  • openmetadata-service/.../search/SearchSourceBuilderFactoryTest.java — three new regression tests

Test plan

  • mvn -pl openmetadata-service test -Dtest=SearchSourceBuilderFactoryTest — 15/15 pass (3 new tests fail without the fix)
  • mvn -pl openmetadata-service spotless:check — clean
  • Reviewer: regression test that flattened paths configured on assetConfig.highlightFields are dropped
  • Reviewer: regression test that flattened paths configured on globalSettings.highlightFields (fallback path) are dropped
  • Reviewer: classifier test (isHighlightUnsafeField) pins behaviour for known roots, dotted subfields, lookalikes like extensionLabel, and null/empty
  • Reviewer: same assertions run against both OpenSearch and Elasticsearch factories

Follow-up (out of scope for this PR)

Save-time validation in SearchSettingsResource that warns / rejects
highlight fields targeting flattened paths, so misconfig is caught at
config time rather than relying on the runtime guard. The runtime guard
in this PR fully unblocks the customer; the save-time check is a
separate, larger change that touches the UI affordance as well.

🤖 Generated with Claude Code


Summary by Gitar

  • Schema Updates:
    • Added highlight boolean to Field schema in searchSettings.json to identify highlightable fields.
  • Data Migration:
    • Added v11211 data migration to clean up invalid highlight fields from existing SearchSettings by referencing the highlight: true flag in defaults.
  • UI Enhancements:
    • Added isHighlightAllowed logic to FieldConfiguration to disable the highlight toggle for unsupported fields.
  • Search Configuration:
    • Updated searchSettings.json to mark standard text fields (e.g., name, description) as eligible for highlighting ("highlight": true).
  • Testing:
    • Added MigrationUtilTest and SearchSettingsHandlerTest to verify that invalid highlight fields are correctly identified and stripped during migration.

This will update automatically on new commits.

Greptile Summary

This PR addresses search failures caused by highlighting configured on flattened/flat_object or enabled:false mapping fields (e.g., extension.*, columns.children.*). These fields have no associated analyzer, causing all shards failed 500s when the highlight phase runs.

  • Adds a highlight boolean to the Field schema in searchSettings.json so each allowedFields entry explicitly declares whether its underlying mapping is a highlightable (analyzed) text field, providing the UI with a static allow-list.
  • Adds a v1.12.11 data migration that reads stored SearchSettings, strips any highlightFields entries not marked highlight: true in the defaults, and writes the cleaned settings back—removing misconfigurations without requiring a reindex.
  • Updates FieldConfiguration.tsx to disable the highlight toggle for any field whose allowedFields entry lacks highlight: true, preventing future misconfigurations via the UI.

Confidence Score: 4/5

Safe to merge with awareness: the migration cleans up stored highlight settings and the UI guard prevents future misconfigurations, but if the migration fails silently the next search query on an affected entity will still return a 500 until settings are manually corrected.

The migration-only approach means the system's correctness entirely depends on the migration completing successfully. If getSearchSettingsFromDatabase() or saveSearchSettings() fail, the exception is caught and logged but the broken configuration remains. The remainder of the change — schema additions, highlight: true annotations across ~60 fields verified against actual index mappings, and the UI disable logic — is accurate and well-tested.

openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v11211/MigrationUtil.java — the silent exception swallow on lines 53-55 and the global-set approach on lines 58-66 are the main areas to scrutinise before merging.

Important Files Changed

Filename Overview
openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v11211/MigrationUtil.java Core migration logic: builds a global allowed-field name set from defaults and uses removeIf to strip disallowed highlight entries from stored settings. Two previously-flagged concerns remain: the global (cross-entity) allowlist and silent exception swallowing; the in-place removeIf assumes a mutable list from Jackson deserialization, which holds in practice.
openmetadata-service/src/main/resources/json/data/settings/searchSettings.json Adds highlight: true to ~60 analyzed text fields across all entity types. Verified against index mappings: all flagged fields (name, displayName, description, path, extractedText, dataModel.columns.*, etc.) are backed by om_analyzer text mappings; flattened/disabled fields are deliberately excluded.
openmetadata-spec/src/main/resources/json/schema/configuration/searchSettings.json Adds optional highlight boolean property (default false) to the Field schema definition. Schema change is backward-compatible; existing stored settings without the flag default to false.
openmetadata-ui/src/main/resources/ui/src/components/SearchSettings/FieldConfiguration/FieldConfiguration.tsx Looks up highlight flag from entityFieldConfig to derive isHighlightAllowed; disables the switch and short-circuits checked to false for disallowed fields. A previously-flagged concern: when isHighlightAllowed is false the switch always shows OFF, hiding the stored state if migration silently failed.
openmetadata-service/src/test/java/org/openmetadata/service/resources/system/SearchSettingsHandlerTest.java New test everyDefaultHighlightFieldIsMarkedHighlightableInAllowedFields verifies that every field in the default highlightFields lists has a corresponding allowedFields entry with highlight: true, acting as a compile-time guard against future drift between the two config sections.
openmetadata-service/src/test/java/org/openmetadata/service/migration/utils/v11211/MigrationUtilTest.java Unit tests covering the two core helpers with both positive and negative cases. Uses new ArrayList<>() wrappers ensuring removeIf mutability assumptions are satisfied in tests.
openmetadata-service/src/main/java/org/openmetadata/service/migration/mysql/v11211/Migration.java Standard migration boilerplate delegating to MigrationUtil.removeUnsupportedHighlightFields().
openmetadata-ui/src/main/resources/ui/src/components/SearchSettings/FieldConfiguration/FieldConfiguration.test.tsx New test confirms the highlight toggle is disabled and onHighlightFieldsChange is not called when entityFields lacks highlight: true for the current field.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant DB as Database
    participant MU as MigrationUtil (v11211)
    participant SMU as SearchSettingsMergeUtil
    participant UI as FieldConfiguration (UI)
    participant ES as Elasticsearch/OpenSearch

    Note over MU: Migration runs on upgrade to 1.12.11
    MU->>SMU: getSearchSettingsFromDatabase()
    SMU-->>MU: stored Settings
    MU->>SMU: loadSearchSettingsFromFile()
    SMU-->>MU: defaults SearchSettings
    MU->>MU: highlightableFields(defaults) builds global Set
    MU->>MU: removeDisallowedHighlightFields via removeIf
    alt Any fields removed
        MU->>SMU: saveSearchSettings(stored, settings)
        SMU->>DB: persist cleaned settings
        Note over DB: extension.*, columns.children.* removed
    end

    Note over UI: User opens Search Settings
    UI->>UI: "isHighlightAllowed = entityFieldConfig?.highlight ?? false"
    UI->>UI: Switch disabled when isHighlightAllowed is false

    Note over ES: Query time after migration
    ES->>ES: highlightFields no longer contain flattened paths
    ES-->>ES: Highlight phase succeeds
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 DB as Database
    participant MU as MigrationUtil (v11211)
    participant SMU as SearchSettingsMergeUtil
    participant UI as FieldConfiguration (UI)
    participant ES as Elasticsearch/OpenSearch

    Note over MU: Migration runs on upgrade to 1.12.11
    MU->>SMU: getSearchSettingsFromDatabase()
    SMU-->>MU: stored Settings
    MU->>SMU: loadSearchSettingsFromFile()
    SMU-->>MU: defaults SearchSettings
    MU->>MU: highlightableFields(defaults) builds global Set
    MU->>MU: removeDisallowedHighlightFields via removeIf
    alt Any fields removed
        MU->>SMU: saveSearchSettings(stored, settings)
        SMU->>DB: persist cleaned settings
        Note over DB: extension.*, columns.children.* removed
    end

    Note over UI: User opens Search Settings
    UI->>UI: "isHighlightAllowed = entityFieldConfig?.highlight ?? false"
    UI->>UI: Switch disabled when isHighlightAllowed is false

    Note over ES: Query time after migration
    ES->>ES: highlightFields no longer contain flattened paths
    ES-->>ES: Highlight phase succeeds
Loading

Reviews (3): Last reviewed commit: "Merge branch 'main' into fix-highlight-f..." | Re-trigger Greptile

When SearchSettings has a highlight field that targets a flattened
mapping subfield (e.g. `extension.foundry_rid` from a custom property,
or `columns.children.*`), both factories were forwarding it straight to
the search engine. flat_object/flattened subfields have no analyzer, so
the highlight phase fails at the shard level with "Field [...] has no
associated analyzer", which surfaces as `all shards failed` and breaks
every workflow that runs the affected query (e.g. Automator over the
container index). Reindexing does not fix this — the bad config lives
in Search Settings.

Filter highlight fields against the known set of flattened paths
(`extension`, `columns.extension`, `columns.children`,
`dataModel.columns.*`, schema-field `children` paths) in both the
OpenSearch and Elasticsearch source builder factories before adding
them to the highlight clause. Misconfigured fields are silently
dropped and logged at DEBUG; the search query stays valid and the
customer no longer needs to manually toggle Highlight Fields off to
unblock.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings June 3, 2026 17:31
@github-actions github-actions Bot added backend safe to test Add this label to run secure Github workflows on PRs labels Jun 3, 2026

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.

Pull request overview

This pull request hardens the search highlight builder so misconfigured highlight fields that target flattened (Elasticsearch) / flat_object (OpenSearch) mapped paths are dropped before query execution, preventing shard-level highlight failures that surface as all shards failed (500) from /v1/search/query.

Changes:

  • Centralizes known flattened field roots in SearchSourceBuilderFactory and adds a classifier + filter to exclude highlight-unsafe paths.
  • Applies highlight-field sanitization in both OpenSearch and Elasticsearch highlight builders (V2).
  • Adds regression tests covering asset-specific highlight config, global fallback highlight config, and the classifier contract.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
openmetadata-service/src/main/java/org/openmetadata/service/search/SearchSourceBuilderFactory.java Adds a centralized set of flattened roots plus helper methods to classify/filter highlight fields.
openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchSourceBuilderFactory.java Filters configured highlight fields to drop flat_object/flattened subfields before building the highlight clause.
openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchSourceBuilderFactory.java Filters configured highlight fields to drop flattened subfields before building the highlight clause.
openmetadata-service/src/test/java/org/openmetadata/service/search/SearchSourceBuilderFactoryTest.java Adds regression tests ensuring unsafe highlight paths are dropped for both factories and via global fallback.

@github-actions

github-actions Bot commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

🔴 Playwright Results — 4 failure(s), 18 flaky

✅ 4479 passed · ❌ 4 failed · 🟡 18 flaky · ⏭️ 38 skipped

Shard Passed Failed Flaky Skipped
🔴 Shard 1 440 1 2 16
🟡 Shard 2 800 0 8 8
🟡 Shard 3 808 0 1 7
🟡 Shard 4 810 0 1 5
🔴 Shard 5 855 1 1 0
🔴 Shard 6 766 2 5 2

Genuine Failures (failed on all attempts)

❌ Pages/SearchSettings.spec.ts › Update entity search settings (shard 1)
�[31mTest timeout of 60000ms exceeded.�[39m
❌ Pages/ExploreBrowse.spec.ts › service type drill-down disables unrelated roots and query-panel Clear resets it (shard 5)
�[31mTest timeout of 180000ms exceeded.�[39m
❌ Pages/SearchSettings.spec.ts › Search preview for searchable table (shard 6)
�[31mTest timeout of 60000ms exceeded.�[39m
❌ Pages/SearchSettings.spec.ts › Configure column search field settings (shard 6)
�[31mTest timeout of 60000ms exceeded.�[39m
🟡 18 flaky test(s) (passed on retry)
  • Pages/Lineage/LineageRightPanel.spec.ts › Verify custom properties tab IS visible for supported type: metric (shard 1, 1 retry)
  • Flow/SearchRBAC.spec.ts › a table-scoped user sees tables but never dashboards (shard 1, 2 retries)
  • Features/BulkEditEntity.spec.ts › Glossary (shard 2, 2 retries)
  • Features/BulkEditOperationBadges.spec.ts › Glossary bulk edit search filters rows and clear restores them (shard 2, 1 retry)
  • Features/BulkImport.spec.ts › Database service (shard 2, 1 retry)
  • Features/BulkImport.spec.ts › Table (shard 2, 1 retry)
  • Features/BulkImport.spec.ts › Keyboard Delete selection (shard 2, 1 retry)
  • Features/ContextCenterPermission.spec.ts › user with editAll permission can see restore action but not delete action on an archived document, and can restore it (shard 2, 1 retry)
  • Features/ContextCenterPermission.spec.ts › admin user can edit and save a memory owned by another user (shard 2, 1 retry)
  • Features/GlobalPageSize.spec.ts › Page size should persist across different pages (shard 2, 1 retry)
  • Features/SearchExport.spec.ts › Export queues a background job and downloads from the jobs tray (shard 3, 1 retry)
  • Pages/CustomProperties.spec.ts › Duration (shard 4, 1 retry)
  • Pages/ExplorePageRightPanel_KnowledgeCenter.spec.ts › Should remove user owner for knowledgeCenter (shard 5, 1 retry)
  • Pages/ExplorePageRightPanel.spec.ts › Should allow Data Steward to edit tags for searchIndex (shard 6, 1 retry)
  • Pages/GlossaryImportExport.spec.ts › Check for Circular Reference in Glossary Import (shard 6, 1 retry)
  • Pages/Lineage/LineageFilters.spec.ts › Verify Impact Analysis service filter selection (shard 6, 1 retry)
  • Pages/Lineage/LineageRightPanel.spec.ts › Verify custom properties tab is NOT visible for pipelineService in platform lineage (shard 6, 1 retry)
  • Pages/Lineage/LineageRightPanel.spec.ts › Verify custom properties tab is NOT visible for apiService in platform lineage (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

…t path

Address PR review on highlight flattened-field filtering:
- filterHighlightSafeFields returns the original list when no field is
  unsafe, avoiding an allocation/copy on the /v1/search/query hot path
- guard the "dropping highlight fields" debug log in both the ES and OS
  buildHighlightsV2 with LOG.isDebugEnabled() so the stream is not
  materialized when DEBUG is disabled

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings June 5, 2026 00:08

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.

Addresses the gitar-bot review finding on #28674: the hot-path optimization
made filterHighlightSafeFields return null for null input (it previously
always returned a non-null list), which both buildHighlightsV2 for-loops
would NPE on. Not reachable today (all callers null-guard), but it breaks
the documented "returns a list" contract. Return List.of() for null —
preserves null-safety with no extra allocation on the fast path. Adds a test
pinning the null / fast-path-identity / drop contract.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 2, 2026 10:05
Comment on lines +38 to +52
public static void removeUnsupportedHighlightFields() {
try {
Settings stored = SearchSettingsMergeUtil.getSearchSettingsFromDatabase();
SearchSettings defaults = SearchSettingsMergeUtil.loadSearchSettingsFromFile();
if (stored == null || defaults == null) {
LOG.warn("Search settings not available; skipping highlight-field cleanup");
} else {
SearchSettings settings = SearchSettingsMergeUtil.loadSearchSettings(stored);
if (removeDisallowedHighlightFields(settings, highlightableFields(defaults))) {
SearchSettingsMergeUtil.saveSearchSettings(stored, settings);
LOG.info("Removed unsupported highlight fields from stored search settings");
} else {
LOG.info("No unsupported highlight fields found in stored search settings");
}
}

@gitar-bot gitar-bot Bot Jul 2, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Edge Case: Migration swallows exceptions, permanently skipping highlight cleanup

removeUnsupportedHighlightFields() wraps its entire body in a try/catch that only logs the exception and returns normally (MigrationUtil.java:53-55). Because runDataMigration() (mysql/postgres v11211 Migration.java) then completes without throwing, the migration framework records 1.12.11 as successfully applied. If the DB read (getSearchSettingsFromDatabase) or loadSearchSettings fails transiently during startup — e.g. a slow/unavailable connection, or invalid JSON that loadSearchSettings throws on — the cleanup is silently skipped and will never be retried on subsequent startups. The stored SearchSettings then retain the invalid flattened highlight fields, and the customer-facing 500 (all shards failed / has no associated analyzer) that this PR is meant to fix persists with no operator-visible signal beyond a single ERROR log line.

Consider letting the exception propagate (remove the catch, or rethrow) so the migration is marked failed and retried, or at minimum raise the log to a level/alert that clearly flags the fix did not apply. Given there is no runtime guard in the query path in this PR, a silently-skipped migration means the bug is not fixed for that deployment.

Let exceptions propagate so a failed migration is not silently marked complete and is retried on the next startup.:

public static void removeUnsupportedHighlightFields() {
  Settings stored = SearchSettingsMergeUtil.getSearchSettingsFromDatabase();
  SearchSettings defaults = SearchSettingsMergeUtil.loadSearchSettingsFromFile();
  if (stored == null || defaults == null) {
    LOG.warn("Search settings not available; skipping highlight-field cleanup");
    return;
  }
  SearchSettings settings = SearchSettingsMergeUtil.loadSearchSettings(stored);
  if (removeDisallowedHighlightFields(settings, highlightableFields(defaults))) {
    SearchSettingsMergeUtil.saveSearchSettings(stored, settings);
    LOG.info("Removed unsupported highlight fields from stored search settings");
  } else {
    LOG.info("No unsupported highlight fields found in stored search settings");
  }
}

Was this helpful? React with 👍 / 👎

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.

Pull request overview

Copilot reviewed 11 out of 14 changed files in this pull request and generated 4 comments.

Comment on lines 162 to 166
checked={
searchSettings?.highlightFields?.includes(field.fieldName) ??
false
isHighlightAllowed &&
(searchSettings?.highlightFields?.includes(field.fieldName) ??
false)
}
Comment on lines +58 to +62
static Set<String> highlightableFields(SearchSettings settings) {
Set<String> names = new HashSet<>();
if (settings != null && settings.getAllowedFields() != null) {
for (AllowedSearchFields allowed : settings.getAllowedFields()) {
collectHighlightable(allowed.getFields(), names);
Comment on lines +107 to +111
Set<String> highlightable =
defaultSearchSettings.getAllowedFields().stream()
.flatMap(allowed -> allowed.getFields().stream())
.filter(field -> Boolean.TRUE.equals(field.getHighlight()))
.map(Field::getName)
Comment on lines +31 to +35
* Drop highlight fields that the search settings configuration does not mark as highlightable.
* Only fields flagged {@code "highlight": true} in {@code allowedFields} (analyzed text fields)
* can be highlighted; flattened/flat_object and non-indexed fields previously saved as highlight
* fields make the highlight phase fail (500) at query time. The allow-list comes from the shipped
* default settings (the source of truth for the flag); the stored highlightFields are filtered
@gitar-bot

gitar-bot Bot commented Jul 2, 2026 •

Copy link
Copy Markdown
Code Review 👍 Approved with suggestions 4 resolved / 5 findings

Adds a validation schema for searchable fields and a migration to strip unsupported highlight configurations, addressing the 500-error caused by flattened mapping fields. Consider refining the migration error handling to avoid silent failures if the cleanup process encounters connectivity issues.

💡 Edge Case: Migration swallows exceptions, permanently skipping highlight cleanup

📄 openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v11211/MigrationUtil.java:38-52 📄 openmetadata-service/src/main/java/org/openmetadata/service/migration/mysql/v11211/Migration.java:28-32

removeUnsupportedHighlightFields() wraps its entire body in a try/catch that only logs the exception and returns normally (MigrationUtil.java:53-55). Because runDataMigration() (mysql/postgres v11211 Migration.java) then completes without throwing, the migration framework records 1.12.11 as successfully applied. If the DB read (getSearchSettingsFromDatabase) or loadSearchSettings fails transiently during startup — e.g. a slow/unavailable connection, or invalid JSON that loadSearchSettings throws on — the cleanup is silently skipped and will never be retried on subsequent startups. The stored SearchSettings then retain the invalid flattened highlight fields, and the customer-facing 500 (all shards failed / has no associated analyzer) that this PR is meant to fix persists with no operator-visible signal beyond a single ERROR log line.

Consider letting the exception propagate (remove the catch, or rethrow) so the migration is marked failed and retried, or at minimum raise the log to a level/alert that clearly flags the fix did not apply. Given there is no runtime guard in the query path in this PR, a silently-skipped migration means the bug is not fixed for that deployment.

Let exceptions propagate so a failed migration is not silently marked complete and is retried on the next startup.
public static void removeUnsupportedHighlightFields() {
  Settings stored = SearchSettingsMergeUtil.getSearchSettingsFromDatabase();
  SearchSettings defaults = SearchSettingsMergeUtil.loadSearchSettingsFromFile();
  if (stored == null || defaults == null) {
    LOG.warn("Search settings not available; skipping highlight-field cleanup");
    return;
  }
  SearchSettings settings = SearchSettingsMergeUtil.loadSearchSettings(stored);
  if (removeDisallowedHighlightFields(settings, highlightableFields(defaults))) {
    SearchSettingsMergeUtil.saveSearchSettings(stored, settings);
    LOG.info("Removed unsupported highlight fields from stored search settings");
  } else {
    LOG.info("No unsupported highlight fields found in stored search settings");
  }
}
✅ 4 resolved
✅ Edge Case: filterHighlightSafeFields now returns null for null input

📄 openmetadata-service/src/main/java/org/openmetadata/service/search/SearchSourceBuilderFactory.java:339-353 📄 openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchSourceBuilderFactory.java:767-775 📄 openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchSourceBuilderFactory.java:298-307
The delta optimization changed filterHighlightSafeFields to initialize result = fields and only allocate a new list when an unsafe field is present. As a side effect, when fields is null the method now returns null (previously it always returned a non-null, possibly empty ArrayList).

Both buildHighlightsV2 implementations iterate the return value directly with for (String field : safeFields), which would throw a NullPointerException on a null result. The debug-log guard on the preceding line checks fields != null, but the for-loop does not.

Currently all callers (buildHighlightingIfNeededV2, addHighlightsIfConfiguredV2, and the new ArrayList<>()/List.of(...) sites) guard against null before calling, so this is not reachable today. However the method's Javadoc states it "returns a list," and any future caller passing a nullable getHighlightFields() would now NPE where the intermediate commit was null-safe. Consider returning List.of() (a singleton, no extra allocation) for null input to preserve the prior null-safety without sacrificing the hot-path optimization.

✅ Bug: Migration drops valid highlight fields columns.name/columns.description

📄 openmetadata-service/src/main/resources/json/data/settings/searchSettings.json:2248-2254 📄 openmetadata-service/src/main/resources/json/data/settings/searchSettings.json:2936-2946 📄 openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v11211/MigrationUtil.java:58-72
The default shipped highlightFields (e.g. the table assetType block at lines 2248-2254) include columns.name and columns.description. These are ordinary analyzed text fields ("Standard text analysis on column names") and highlight correctly — they are NOT flattened/flat_object subfields. However, the diff that added "highlight": true to allowedFields missed these two: the allowedFields entries columns.name (line 2936) and columns.description (lines 2546/2944) are left without the flag.

Consequences:

  1. MigrationUtil.removeUnsupportedHighlightFields() builds the allow-list only from fields marked highlight:true, so on existing installs it will strip columns.name and columns.description from the stored highlightFields — silently removing legitimate, working highlighting on column name/description in search results. The migration's intent was to remove only highlight-unsafe (flattened/non-indexed) fields, but it also deletes these safe fields because the allow-list is incomplete.
  2. The shipped default config is internally inconsistent: it lists columns.name/columns.description in highlightFields while the new UI (isHighlightAllowed) will render their toggles disabled.

Fix: mark columns.name and columns.description (under both the table and dashboardDataModel allowedFields) with "highlight": true, since they are valid analyzed text fields. Audit every entry currently present in any default highlightFields array to ensure each has a matching highlight:true allowedField, so the migration does not remove working highlights.

✅ Edge Case: Highlight toggle disabled for all fields while entityFields loads

📄 openmetadata-ui/src/main/resources/ui/src/components/SearchSettings/FieldConfiguration/FieldConfiguration.tsx:52-59 📄 openmetadata-ui/src/main/resources/ui/src/components/SearchSettings/FieldConfiguration/FieldConfiguration.tsx:160-170
In FieldConfiguration.tsx, isHighlightAllowed = entityFieldConfig?.highlight ?? false and disabled={!isHighlightAllowed}. entityFields is built in EntitySearchSettings.tsx from allowedFields (defaults to []) plus async-loaded customProperties, inside a useMemo. During initial render / before allowedFields resolves, entityFields is empty, so entityFieldConfig is undefined for every field, making every highlight toggle disabled and rendered unchecked — including fields the user currently has enabled in highlightFields. The checked state also becomes isHighlightAllowed && includes(...), so an already-enabled field whose config isn't present in entityFields displays as OFF while it is still saved in highlightFields, and the user cannot toggle it off (onChange is gated by the disabled switch). This is a transient/edge UX inconsistency; the stored value is still cleaned by the migration, but consider falling back to the saved state (or showing a loading state) until allowedFields has loaded.

✅ Edge Case: Migration strips custom highlightable fields not present in defaults

📄 openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v11211/MigrationUtil.java:38-52 📄 openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v11211/MigrationUtil.java:95-102
MigrationUtil.removeUnsupportedHighlightFields builds the highlightable allow-list from the shipped default settings file only (highlightableFields(defaults)), then removes any stored highlight field whose name is not in that set. If an operator added their own entry to allowedFields and marked it highlight: true in the stored search settings (a field that does not exist in the default config), the migration will silently strip it from globalSettings/assetConfig highlightFields even though it is a legitimately analyzed field. In practice most custom fields live under the flattened extension.* mapping (which we correctly want to drop), so impact is low, but deriving the allow-list from the stored settings' own allowedFields (falling back to defaults) would avoid removing valid operator-configured highlight fields. Dropped fields are not individually logged, so the change is hard to diagnose after the fact.

🤖 Prompt for agents
Code Review: Adds a validation schema for searchable fields and a migration to strip unsupported highlight configurations, addressing the 500-error caused by flattened mapping fields. Consider refining the migration error handling to avoid silent failures if the cleanup process encounters connectivity issues.

1. 💡 Edge Case: Migration swallows exceptions, permanently skipping highlight cleanup
   Files: openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v11211/MigrationUtil.java:38-52, openmetadata-service/src/main/java/org/openmetadata/service/migration/mysql/v11211/Migration.java:28-32

   `removeUnsupportedHighlightFields()` wraps its entire body in a try/catch that only logs the exception and returns normally (MigrationUtil.java:53-55). Because `runDataMigration()` (mysql/postgres v11211 Migration.java) then completes without throwing, the migration framework records 1.12.11 as successfully applied. If the DB read (`getSearchSettingsFromDatabase`) or `loadSearchSettings` fails transiently during startup — e.g. a slow/unavailable connection, or invalid JSON that `loadSearchSettings` throws on — the cleanup is silently skipped and will never be retried on subsequent startups. The stored SearchSettings then retain the invalid flattened highlight fields, and the customer-facing 500 (`all shards failed / has no associated analyzer`) that this PR is meant to fix persists with no operator-visible signal beyond a single ERROR log line.
   
   Consider letting the exception propagate (remove the catch, or rethrow) so the migration is marked failed and retried, or at minimum raise the log to a level/alert that clearly flags the fix did not apply. Given there is no runtime guard in the query path in this PR, a silently-skipped migration means the bug is not fixed for that deployment.

   Fix (Let exceptions propagate so a failed migration is not silently marked complete and is retried on the next startup.):
   public static void removeUnsupportedHighlightFields() {
     Settings stored = SearchSettingsMergeUtil.getSearchSettingsFromDatabase();
     SearchSettings defaults = SearchSettingsMergeUtil.loadSearchSettingsFromFile();
     if (stored == null || defaults == null) {
       LOG.warn("Search settings not available; skipping highlight-field cleanup");
       return;
     }
     SearchSettings settings = SearchSettingsMergeUtil.loadSearchSettings(stored);
     if (removeDisallowedHighlightFields(settings, highlightableFields(defaults))) {
       SearchSettingsMergeUtil.saveSearchSettings(stored, settings);
       LOG.info("Removed unsupported highlight fields from stored search settings");
     } else {
       LOG.info("No unsupported highlight fields found in stored search settings");
     }
   }

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 👍 / 👎 | Powered by Gitar — free for open source

@sonarqubecloud

sonarqubecloud Bot commented Jul 2, 2026

Copy link
Copy Markdown

@sonarqubecloud

sonarqubecloud Bot commented Jul 2, 2026

Copy link
Copy Markdown

This branch was previously deployed

1 inactive deployment
test — 911a8b4e Deployed Jul 2, 2026 by mohityadav766 via playwright-ci-postgresql (4, 6) #54446
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend safe to test Add this label to run secure Github workflows on PRs To release Will cherry-pick this PR into the release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants