Skip to content

Fixes #39123: Knowledge Graph toolbar refreshes filter options after a level change - #39158

Open
detail-app[bot] wants to merge 2 commits into
mainfrom
detail/bug-fix/fixes-39123-knowledge-graph-toolbar-refreshes-filt-a327e3
Open

detail-app[bot] wants to merge 2 commits into
mainfrom
detail/bug-fix/fixes-39123-knowledge-graph-toolbar-refreshes-filt-a327e3

Conversation

@detail-app

@detail-app detail-app Bot commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Detail bug report: View on Detail

Describe your changes:

Fixes #39123

I worked on refreshing the Knowledge Graph toolbar's Entity Type and Relationship Type filter pickers after a graph level change, because the shared core TreeSelect caches its fetched tree for the lifetime of the instance — useTreeSelectData only re-calls fetchData on mount and on search-term changes, never when fetchData would return different nodes. The pickers worked around the initial empty → non-empty case with a remount key={roots.length === 0 ? 'empty' : 'ready'}, but that key only flips on the empty boundary.

filterOptions is depth-scoped (the server aggregates option lists and counts from the traversal at the requested depth), and useRetainedValue keeps the previous graph result during a level-change refetch, so a level change replaces filterOptions in place — non-empty → non-empty. The key never flipped, so the TreeSelect kept serving the previous level's cached tree with stale counts and missing/extra types.

Type of change:

  • Bug fix

High-level design:

Small change — no high-level design needed. The fix keys the TreeSelect remount on an option-content signature (id:count joined) instead of emptiness, in both EntityTypePicker and RelationshipTypePicker. The signature changes whenever the depth-scoped option list or counts change, forcing a remount so the new instance re-fetches the fresh tree. The fix is consumer-only — use-tree-select-data.ts and the shared TreeSelect are untouched, so every other consumer (glossary term picker, domain scope picker, etc.) is unaffected. Alternatives considered: re-fetching in useTreeSelectData when fetchData identity changes — rejected because it would change behavior for every consumer, including those that fetch paginated/async roots.

Tests:

Use cases covered

  • Entity Type picker remounts (and so re-fetches fresh options/counts) when its option content changes while non-empty — the level-change scenario.
  • Relationship Type picker remounts when its option content changes while non-empty.
  • Neither picker remounts when filterOptions is a new object with identical id+count content (no spurious remounts on unrelated re-renders).
  • Remount fires on count-only changes (same ids, deeper level surfaces more nodes), on a type being added, and on a type being dropped at a shallower level.
  • Empty → non-empty first paint still remounts once and transitions disabled true → false.
  • Successive level changes (non-empty throughout) remount on each transition.

Unit tests

  • I added unit tests for the new/changed logic.
  • Files added/updated: openmetadata-ui/src/main/resources/ui/src/components/discovery/knowledge-graph/KnowledgeGraphToolbar.test.tsx (new). The suite stubs the shared TreeSelect with a mount-counting stand-in (jsdom cannot render the react-aria popover) and asserts the remount contract for both pickers.
  • The new suite fails 5/7 without the fix and passes 7/7 with it, confirming it pins the bug.

Backend integration tests

  • Not applicable (no backend API changes). The fix is entirely in the UI toolbar; filterOptions is already computed server-side per depth.

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not applicable — the existing Knowledge Graph Playwright spec mocks the graph endpoint but still requires a live backend for auth/entity creation, which could not be started in this environment. The jsdom unit suite covers the remount contract deterministically.

Manual testing performed

  • Verified via the new unit suite and the existing Knowledge Graph Jest suites (171 tests, 9 suites, all pass).
  • ESLint, Prettier, organize-imports, and license-header checks are clean on both changed files.
  • yarn tsc:check (app) reports 34 errors, identical to the pre-existing baseline — zero new type errors (all pre-existing errors are in unrelated SSOUtils.test.ts / ChartDetailsUtils.test.tsx). yarn type-check (core-components) passes.
  • yarn build succeeds for both the app and core-components packages.
  • End-to-end verification against a running OpenMetadata stack could not be performed: the 2.0.0-SNAPSHOT server/db/ingestion Docker images are not on the registry, the Elasticsearch image fails to materialize under this sandbox's overlay2 storage, and available RAM (~2.4 GB) is insufficient for Elasticsearch + MySQL + the server JVM. The behavioral contract that E2E would verify (fresh options/counts after a level change) is covered by the unit suite, which asserts the remount contract that is the root cause of the staleness.

UI screen recording:

Not applicable — this is a bug fix to existing filter picker behavior (correctness of the option list after a level change), not a new UI feature or feature task with UI impact. The fix has no visible UI beyond the dropdown already showing the correct options.

Checklist:

  • I have read CONTRIBUTING.md (the pre-review gate) and the contributor docs.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.
  • For a UI feature or feature task: as part of PR creation, I ran the PR build in Docker with sample data and embedded a verified GitHub-hosted recording plus build/health evidence above (or explained why this requirement is not applicable).
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • Self-review: I reviewed the final diff against REVIEW.md (the pr-checklist skill runs it) and fixed every 🔴 finding, or answered it on the line below.
  • Decision check: if this PR decides something the next contributor could undo — a schema field, REST path or format another component or repo must agree with, a new default or limit, an ordering that must hold, or a rule stated only in this description — it adds a record under docs/decisions/ (see its README.md). This description is gone from git log after the squash-merge.
  • I have added a test that covers the exact scenario we are fixing. For complex issues, comment the issue number in the test for future reference.

Automatic Fixes PRs can be configured here.

@detail-app
detail-app Bot force-pushed the detail/bug-fix/fixes-39123-knowledge-graph-toolbar-refreshes-filt-a327e3 branch from 2f73152 to 3652ddf Compare November 28, 2026 06:11

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Detail Bug] Knowledge Graph toolbar filters show stale entity/relationship type options after changing graph level

2 participants