Skip to content

Fixes: Advanced Search Filter failing for Custom Properties at Database Schema level#27320

Open
Copilot wants to merge 4 commits intomainfrom
copilot/fix-advanced-search-filter-database-schema
Open

Fixes: Advanced Search Filter failing for Custom Properties at Database Schema level#27320
Copilot wants to merge 4 commits intomainfrom
copilot/fix-advanced-search-filter-database-schema

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 13, 2026

Advanced search filters for custom properties on the Database Schema explore tab return no results. The query builder generates paths like extension.databaseSchema.informationOwners.displayName.keyword, but Elasticsearch's flattened type stores extension data without the entity type prefix — the actual key is informationOwners.displayName.

Root Cause

AdvanceSearchProvider receives no entityType prop on the Explore page, so processEntityTypeFields adds an entity type namespace to all extension field paths. This works for display purposes but produces ES queries that never match any document, regardless of entity type.

The bug was most visible on Database Schema because it was the reported case — the same namespace mismatch affects any entity type tab when using the "all entities" mode custom property cache.

Changes — AdvanceSearchProvider.component.tsx

  • effectiveEntityType (useMemo): Derives entity type from searchIndex via searchClassBase.getSearchIndexEntityTypeMapping() when the entityType prop is absent. SearchIndex.DATABASE_SCHEMA"databaseSchema", multi-entity indexes or EntityType.ALLundefined (preserves existing namespace behavior for the all-entities tab).

  • customPropsEntityTypeRef (useRef): Tracks which entity type was used to populate the customProps cache. Avoids relying on React state update timing for cache invalidation — the ref is checked synchronously inside loadData when the user switches tabs.

  • fetchCustomPropertyType: Uses effectiveEntityType instead of entityType, so on the Database Schema tab only databaseSchema properties are included with direct paths (no namespace prefix).

  • Cache invalidation in loadData: Compares customPropsEntityTypeRef.current === effectiveEntityType; on mismatch, refetches and updates the ref.

Before → After (Database Schema tab):

extension.databaseSchema.informationOwners.displayName.keyword   ← no match
extension.informationOwners.displayName.keyword                  ← matches ES flattened key

Type of change:

  • Bug fix

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.

@github-actions
Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

Copilot AI and others added 2 commits April 13, 2026 13:37
When the user is on a specific entity type's explore tab (e.g., Database
Schema), the AdvanceSearchProvider now correctly derives the entity type
from the current searchIndex. This ensures that custom property extension
field paths do not include the entity type namespace prefix
(e.g., `extension.informationOwners.displayName.keyword` instead of
`extension.databaseSchema.informationOwners.displayName.keyword`),
matching the actual Elasticsearch document structure where extension data
is stored without the entity type prefix.

Key changes:
- Add `effectiveEntityType` useMemo that derives the entity type from
  `searchIndex` when `entityType` prop is not explicitly provided
- Add `customPropsEntityTypeRef` useRef to track cache validity by entity
  type context, enabling correct cache invalidation on tab switches
- Use `effectiveEntityType` in `fetchCustomPropertyType` so extension
  subfields are built with the correct path context

Agent-Logs-Url: https://github.com/open-metadata/OpenMetadata/sessions/a304e4a7-a4f1-4848-b390-7616f043352c

Co-authored-by: aniketkatkar97 <51777795+aniketkatkar97@users.noreply.github.com>
Agent-Logs-Url: https://github.com/open-metadata/OpenMetadata/sessions/a304e4a7-a4f1-4848-b390-7616f043352c

Co-authored-by: aniketkatkar97 <51777795+aniketkatkar97@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix advanced search filter for custom properties at database schema level Fixes: Advanced Search Filter failing for Custom Properties at Database Schema level Apr 13, 2026
Copilot AI requested a review from aniketkatkar97 April 13, 2026 13:40
@sonika-shah sonika-shah marked this pull request as ready for review April 13, 2026 20:14
@sonika-shah sonika-shah requested a review from a team as a code owner April 13, 2026 20:14
Copilot AI review requested due to automatic review settings April 13, 2026 20:14
@sonika-shah sonika-shah added the safe to test Add this label to run secure Github workflows on PRs label Apr 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

❌ Playwright Lint Check Failed — ESLint + Prettier + Organise Imports

The following files have style issues that need to be fixed:

Fix locally (fast — only for changed files in the branch):

make ui-checkstyle-playwright-changed

Or to fix all playwright files:

make ui-checkstyle-playwright

@github-actions
Copy link
Copy Markdown
Contributor

❌ I18n Sync Check Failed

Translation files are out of sync. Changed files:

Fix locally:

make i18n-sync-fix

@github-actions
Copy link
Copy Markdown
Contributor

❌ Lint Check Failed — ESLint + Prettier + Organise Imports (src)

The following files have style issues that need to be fixed:

Fix locally (fast — only for changed files in the branch):

make ui-checkstyle-src-changed

Or to fix all files:

make ui-checkstyle-src

@github-actions
Copy link
Copy Markdown
Contributor

❌ App Docs Check Failed

Generated app docs are stale. Changed files:

Fix locally:

make generate-app-docs

@github-actions
Copy link
Copy Markdown
Contributor

❌ Licence Header Check Failed

The following files are missing or have outdated licence headers:

Fix locally:

make license-header-fix

@github-actions
Copy link
Copy Markdown
Contributor

The Python checkstyle failed.

Please run make py_format and py_format_check in the root of your repository and commit the changes to this PR.
You can also use pre-commit to automate the Python code formatting.

You can install the pre-commit hooks with make install_test precommit_install.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes Advanced Search filters for custom properties on Explore tabs (notably Database Schema) by ensuring extension field paths match how Elasticsearch flattened stores extension keys (without an entity-type namespace when appropriate).

Changes:

  • Derives an effectiveEntityType from searchIndex when the entityType prop is not provided.
  • Uses a ref (customPropsEntityTypeRef) to synchronously track which entity type context populated the cached custom properties.
  • Invalidates/refetches the custom properties cache when the effective entity type changes to rebuild extension subfields with the correct path context.

Comment on lines +104 to +121
// When entityType is not explicitly provided, derive it from the current searchIndex
// so that custom property extension field paths do not include the entity type namespace
// prefix. The Elasticsearch `extension` field uses the `flattened` type and stores data
// WITHOUT the entity type prefix (e.g., key is "informationOwners.displayName", not
// "databaseSchema.informationOwners.displayName"), so omitting the prefix is required
// for queries to match actual documents.
const effectiveEntityType = useMemo(() => {
if (entityType) {
return entityType;
}
if (isArray(searchIndex)) {
return undefined;
}
const mapping = searchClassBase.getSearchIndexEntityTypeMapping();
const mapped = mapping[searchIndex];
// EntityType.ALL represents a multi-entity context — preserve namespace prefixes
return mapped && mapped !== EntityType.ALL ? mapped : undefined;
}, [entityType, searchIndex]);
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

This change alters how custom property paths are generated (deriving an effective entity type from searchIndex and changing cache invalidation). There’s currently no active unit test covering the Explore-tab scenario where entityType is undefined and ensuring extension fields are built without the entity-type namespace. Please add/enable a test that asserts fetchCustomPropertyType/processEntityTypeFields are invoked with the derived entity type (e.g., DATABASE_SCHEMA → "databaseSchema") and that switching tabs causes the customProps cache to be refetched with the new context.

Copilot uses AI. Check for mistakes.
@gitar-bot
Copy link
Copy Markdown

gitar-bot bot commented Apr 13, 2026

Code Review ✅ Approved

Advanced Search Filter now works correctly for Custom Properties at the Database Schema level. No issues found.

Options

Display: compact → Showing less information.

Comment with these commands to change:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Advanced Search Filter failing for Custom Properties at Database Schema level

4 participants