Skip to content

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

Open
Copilot wants to merge 6 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 6 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.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 16, 2026

❌ UI Checkstyle Failed

❌ ESLint + Prettier + Organise Imports (src)

One or more source files have linting or formatting issues.

Affected files
  • openmetadata-ui/src/main/resources/ui/src/components/Explore/AdvanceSearchProvider/AdvanceSearchProvider.component.tsx

Fix locally (fast — only checks files changed in this branch):

make ui-checkstyle-changed

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 16, 2026

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 61%
61.94% (60266/97295) 41.98% (31615/75300) 45% (9495/21099)

Copilot AI review requested due to automatic review settings April 21, 2026 01:46
@open-metadata open-metadata deleted a comment from github-actions Bot Apr 21, 2026
@gitar-bot
Copy link
Copy Markdown

gitar-bot Bot commented Apr 21, 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

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

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

Comment on lines +114 to +118
if (isArray(searchIndex)) {
return undefined;
}
const mapping = searchClassBase.getSearchIndexEntityTypeMapping();
const mapped = mapping[searchIndex];
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

effectiveEntityType returns undefined for any array searchIndex, even when the array contains a single index. In flows that pass a single selected entity as an array (e.g., onChangeSearchIndex([SearchIndex.TABLE])), this keeps the old extension namespace behavior and can reintroduce the same custom-property query mismatch. Consider deriving the entity type when searchIndex is an array of length 1 (and only treating it as multi-entity when length > 1).

Suggested change
if (isArray(searchIndex)) {
return undefined;
}
const mapping = searchClassBase.getSearchIndexEntityTypeMapping();
const mapped = mapping[searchIndex];
const normalizedSearchIndex = isArray(searchIndex)
? searchIndex.length === 1
? searchIndex[0]
: undefined
: searchIndex;
if (isNil(normalizedSearchIndex)) {
return undefined;
}
const mapping = searchClassBase.getSearchIndexEntityTypeMapping();
const mapped = mapping[normalizedSearchIndex];

Copilot uses AI. Check for mistakes.
Comment on lines +284 to +291
let extensionSubField =
customPropsEntityTypeRef.current === effectiveEntityType
? customProps
: null;
if (extensionSubField === null) {
extensionSubField = await fetchCustomPropertyType();
setCustomProps(extensionSubField);
customPropsEntityTypeRef.current = effectiveEntityType;
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

This change causes getAllCustomProperties() to be re-fetched whenever effectiveEntityType changes (e.g., each Explore tab switch). Since the API response is global and only the derived subfields shape changes, consider caching the raw custom properties response once and rebuilding extensionSubField locally per entity type (or caching computed subfields per entity type) to avoid repeated network calls and recomputation.

Copilot uses AI. Check for mistakes.
Comment on lines 288 to 292
if (extensionSubField === null) {
extensionSubField = await fetchCustomPropertyType();
setCustomProps(extensionSubField);
customPropsEntityTypeRef.current = effectiveEntityType;
}
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

loadData() can run concurrently when users switch tabs quickly (it’s triggered by searchIndex changes). Because it awaits fetchCustomPropertyType() and then updates customProps and customPropsEntityTypeRef, a slower previous request can complete after a newer one and overwrite the cache/ref for the current tab. Consider guarding with a monotonically increasing request id / "latest only" check (or abort/cancel) before applying setCustomProps, customPropsEntityTypeRef.current = ..., and setConfig.

Copilot uses AI. Check for mistakes.
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown
Contributor

🟡 Playwright Results — all passed (23 flaky)

✅ 3687 passed · ❌ 0 failed · 🟡 23 flaky · ⏭️ 89 skipped

Shard Passed Failed Flaky Skipped
🟡 Shard 1 479 0 2 4
🟡 Shard 2 652 0 4 7
🟡 Shard 3 659 0 6 1
🟡 Shard 4 646 0 2 27
🟡 Shard 5 610 0 1 42
🟡 Shard 6 641 0 8 8
🟡 23 flaky test(s) (passed on retry)
  • Flow/Tour.spec.ts › Tour should work from welcome screen (shard 1, 1 retry)
  • Pages/UserCreationWithPersona.spec.ts › Create user with persona and verify on profile (shard 1, 1 retry)
  • Features/BulkEditEntity.spec.ts › Database service (shard 2, 1 retry)
  • Features/BulkEditEntity.spec.ts › Table (shard 2, 1 retry)
  • Features/BulkImport.spec.ts › Keyboard Delete selection (shard 2, 1 retry)
  • Features/Glossary/GlossaryWorkflow.spec.ts › should inherit reviewers from glossary when term is created (shard 2, 1 retry)
  • Features/IncidentManager.spec.ts › Complete Incident lifecycle with table owner (shard 3, 1 retry)
  • Features/LandingPageWidgets/DomainDataProductsWidgets.spec.ts › Domain asset count should update when assets are added (shard 3, 1 retry)
  • Features/RestoreEntityInheritedFields.spec.ts › Validate restore with Inherited domain and data products assigned (shard 3, 1 retry)
  • Features/RestoreEntityInheritedFields.spec.ts › Validate restore with Inherited domain and data products assigned (shard 3, 1 retry)
  • Features/RTL.spec.ts › Verify Following widget functionality (shard 3, 1 retry)
  • Pages/Customproperties-part2.spec.ts › Enum (shard 3, 1 retry)
  • Pages/Customproperties-part2.spec.ts › entityReferenceList shows item count, scrollable list, no expand toggle (shard 4, 1 retry)
  • Pages/DataContracts.spec.ts › Create Data Contract and validate for MlModel (shard 4, 1 retry)
  • Pages/Glossary.spec.ts › Add and Remove Assets (shard 5, 1 retry)
  • Pages/Lineage/DataAssetLineage.spec.ts › verify create lineage for entity - Table (shard 6, 2 retries)
  • Pages/Lineage/DataAssetLineage.spec.ts › verify create lineage for entity - Topic (shard 6, 1 retry)
  • Pages/Lineage/DataAssetLineage.spec.ts › verify create lineage for entity - Stored Procedure (shard 6, 1 retry)
  • Pages/Lineage/LineageFilters.spec.ts › Verify lineage schema filter selection (shard 6, 1 retry)
  • Pages/Lineage/LineageRightPanel.spec.ts › Verify custom properties tab IS visible for supported type: searchIndex (shard 6, 1 retry)
  • Pages/Users.spec.ts › Permissions for table details page for Data Consumer (shard 6, 1 retry)
  • Pages/Users.spec.ts › Check permissions for Data Steward (shard 6, 1 retry)
  • VersionPages/EntityVersionPages.spec.ts › Directory (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

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