Skip to content

fix(lineage): use namespace import for @dagrejs/dagre to avoid undefined graphlib#29949

Open
SAY-5 wants to merge 1 commit into
open-metadata:mainfrom
SAY-5:fix-lineage-dagre-named-import
Open

fix(lineage): use namespace import for @dagrejs/dagre to avoid undefined graphlib#29949
SAY-5 wants to merge 1 commit into
open-metadata:mainfrom
SAY-5:fix-lineage-dagre-named-import

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jul 11, 2026

Copy link
Copy Markdown

Fixes #29556.

EntityLineageLayoutUtils.ts imports @dagrejs/dagre with named imports (import { graphlib, layout }), but that package is CommonJS and assigns everything through module.exports = { graphlib, layout, ... }. Under the dev bundler's CJS/ESM interop the named graphlib binding can resolve to undefined, so graphlib.Graph throws Cannot read properties of undefined (reading 'Graph') when the lineage layout runs. The sibling WorkflowLayout.ts already imports the module as a whole and reads dagre.graphlib.Graph, which is why it does not hit this.

This switches the file to a namespace import (import * as dagre) and accesses dagre.graphlib.Graph / dagre.layout, matching the working WorkflowLayout.ts and binding the full module object regardless of how the bundler handles the CJS named exports. I confirmed the pattern type-checks with the project's tsconfig flags and that dagre.graphlib.Graph / dagre.layout are defined at runtime; I could not reproduce the exact dev-server interop failure locally, so I mirrored the already-working import style rather than guessing at a bundler config change.

Greptile Summary

This PR changes how the lineage layout utility reads Dagre. The main changes are:

  • Replaces named Dagre imports with a module namespace import.
  • Reads graphlib.Graph from the Dagre module object.
  • Calls layout through the Dagre module object.

Confidence Score: 5/5

This looks safe to merge after checking the Dagre module shape used by the app bundler.

  • The changed layout behavior is narrow and keeps the same Dagre calls.
  • The only remaining concern is conditional on the resolved Dagre entry exposing the module object only as default.

openmetadata-ui/src/main/resources/ui/src/utils/EntityLineageLayoutUtils.ts

Important Files Changed

Filename Overview
openmetadata-ui/src/main/resources/ui/src/utils/EntityLineageLayoutUtils.ts Updates Dagre access in the lineage layout utility, with a remaining conditional risk around namespace import shape.

Reviews (1): Last reviewed commit: "fix(lineage): use namespace import for @..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

Context used (3)

  • Context used - CLAUDE.md (source)
  • Context used - openmetadata-ui-core-components/CLAUDE.md (source)
  • Context used - AGENTS.md (source)

…ned graphlib

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
@SAY-5 SAY-5 requested a review from a team as a code owner July 11, 2026 05:34
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@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!

@gitar-bot

gitar-bot Bot commented Jul 11, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Switches to a namespace import for @dagrejs/dagre to ensure proper CommonJS interop in the lineage layout. This resolves the runtime 'undefined' reference error for graphlib.

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 👍 / 👎 | Gitar

*/

import { graphlib, layout } from '@dagrejs/dagre';
import * as dagre from '@dagrejs/dagre';

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 Namespace Shape Can Hide Dagre

If Vite or Jest resolves @dagrejs/dagre through its ESM entry instead of the CommonJS wrapper, import * as dagre can produce a namespace where the module object is under default. In that case the changed dagre.graphlib.Graph and dagre.layout reads become undefined, so opening lineage still crashes instead of fixing the interop path. The sibling working pattern uses a default import for this module object.

Context Used: CLAUDE.md (source)

@github-actions

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 63%
64.06% (74405/116134) 47.59% (43831/92096) 48.6% (13362/27489)

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

🟡 Playwright Results — all passed (26 flaky)

✅ 4464 passed · ❌ 0 failed · 🟡 26 flaky · ⏭️ 129 skipped

Shard Passed Failed Flaky Skipped
🟡 Shard 1 423 0 4 16
✅ Shard 2 11 0 0 0
🟡 Shard 3 781 0 10 42
🟡 Shard 4 815 0 1 18
🟡 Shard 5 826 0 1 5
🟡 Shard 6 828 0 1 46
🟡 Shard 7 780 0 9 2
🟡 26 flaky test(s) (passed on retry)
  • Features/TeamsHierarchy.spec.ts › Add teams in hierarchy (shard 1, 1 retry)
  • Pages/Bots.spec.ts › Bots Page should work properly (shard 1, 1 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 fully denied user sees neither asset type when browsing (shard 1, 1 retry)
  • Features/BulkEditOperationBadges.spec.ts › Database service bulk edit search filters rows and clear restores them (shard 3, 1 retry)
  • Features/BulkImportWithDotInName.spec.ts › CSV with quoted FQN loads correctly in import grid (shard 3, 1 retry)
  • Features/BulkImportWithDotInName.spec.ts › Bulk edit existing entity with dot in service name (shard 3, 1 retry)
  • Features/ContextCenterArticles.spec.ts › Article listing search filters, clears, and shows empty state (shard 3, 1 retry)
  • Features/ContextCenterArticles.spec.ts › Article list cards, recently viewed widget, and pagination work (shard 3, 1 retry)
  • Features/ContextCenterArticles.spec.ts › description: switching articles does not bleed unsaved content into next article (shard 3, 1 retry)
  • Features/ContextCenterMemories.spec.ts › clearing search restores the unfiltered list (shard 3, 1 retry)
  • Features/ContextCenterMemories.spec.ts › closing the modal removes ?memory= param from the URL (shard 3, 1 retry)
  • Features/ContextCenterMemories.spec.ts › copy link button copies URL containing the ?memory= param (shard 3, 1 retry)
  • Features/ContextCenterMemories.spec.ts › changing visibility from Shared to Private shows "visible only to you" after save (shard 3, 1 retry)
  • Features/SearchExport.spec.ts › Export queues a background job and downloads from the jobs tray (shard 4, 1 retry)
  • Pages/CustomProperties.spec.ts › Set & Update all CP types on searchIndex (shard 5, 1 retry)
  • Pages/ExplorePageRightPanel_KnowledgeCenter.spec.ts › Should remove user owner for knowledgeCenter (shard 6, 1 retry)
  • Pages/ExplorePageRightPanel.spec.ts › Should NOT show restricted edit buttons for Data Steward for searchIndex (shard 7, 1 retry)
  • Pages/Glossary.spec.ts › Drag and Drop Glossary Term (shard 7, 1 retry)
  • Pages/GlossaryImportExport.spec.ts › Import partial success - some terms pass, some fail (shard 7, 1 retry)
  • Pages/GlossaryImportExport.spec.ts › Glossary CSV import preserves typed relations (shard 7, 1 retry)
  • Pages/Lineage/LineageFilters.spec.ts › Verify Impact Analysis service filter selection (shard 7, 1 retry)
  • Pages/Lineage/LineageRightPanel.spec.ts › Verify custom properties tab is NOT visible for pipelineService in platform lineage (shard 7, 1 retry)
  • Pages/Lineage/LineageRightPanel.spec.ts › Verify custom properties tab is NOT visible for apiService in platform lineage (shard 7, 1 retry)
  • Pages/ServiceEntity.spec.ts › Tier Add, Update and Remove (shard 7, 1 retry)
  • Pages/TestSuite.spec.ts › Logical TestSuite (shard 7, 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.

Cannot read properties of undefined (reading 'Graph')

2 participants