Skip to content

ATLAS-5348: Atlas React UI: Upgrading frontend transitive dependencies - #703

Open
Brijesh619 wants to merge 13 commits into
apache:masterfrom
Brijesh619:ATLAS-5348
Open

Brijesh619 wants to merge 13 commits into
apache:masterfrom
Brijesh619:ATLAS-5348

Conversation

@Brijesh619

@Brijesh619 Brijesh619 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

This PR resolves ATLAS-5348 by upgrading several outdated frontend transitive dependencies in the Atlas React UI (/dashboard).

Previously, this patch relied heavily on manual overrides in package.json to bump specific sub-dependencies. However, forcing those overrides (like minimatch, js-yaml, and postcss) caused "invalid tree" errors and forced modern tooling (like Vite and ESLint) backward.

Instead, this PR safely updates package-lock.json, upgrades the main libraries responsible for bringing in vulnerable sub-dependencies, and only uses an override when strictly necessary to avoid breaking changes.

Main Library Upgrades:

  • recharts (bumped to ^3.10.1): Resolves the lodash vulnerability by removing older dependencies (like victory-vendor).
  • react-quill-new (bumped to ^3.8.3): Resolves the lodash-es vulnerability.

Recharts v3 Migration & Code Quality Improvements:
Because upgrading to Recharts v3 introduced significant API changes, this PR includes a comprehensive refactor of the dashboard's charting components to ensure production stability, strict type safety, and accessibility:

  • Strict TypeScript Compliance & Central Abstraction: Completely eradicated unsafe any types, @ts-expect-error suppressions, and redundant inline casting across all chart components (ClassificationDistributionCard, EntityStatsChart, EntityStatusDonut, EntityTypeBarChart, MessageConsumptionChart). Recharts click event payloads are now centrally validated using a generic getPayloadFromRechartsEvent<T> helper in metricsUtils.ts (now used consistently across all charts including EntityStatusDonut), ensuring strict type safety and eliminating code duplication. We also strongly typed custom renderActiveShape parameters using PieSectorDataItem to safely extract payload properties.
  • API Alignment & Pie Chart Interactions: Updated Recharts <Tooltip> and <LabelList> components to comply with the stricter v3 formatter signatures (RenderableText). Because Recharts v3 currently breaks Pie sector hover animations when isAnimationActive=true is used alongside the new shape prop, we successfully restored the native smooth hover effect on EntityStatusDonut by creating a strongly-typed component wrapper (AnimatedPie) to securely accept legacy activeIndex and activeShape props without violating strict TypeScript compilation rules.
  • Legend Accessibility & Performance Refactor: Completely rewrote the <Legend> implementation in EntityStatsChart. The legacy payload manipulation was replaced with a custom content renderer utilizing native MUI <ButtonBase> components memoized via useCallback. This restores native keyboard accessibility (Enter/Space keys) and semantic ARIA roles without custom onKeyDown handlers. Payload parsing is wrapped in useMemo to prevent array reallocations.
  • SCSS Custom Property Styling & Dark Mode Support: Enforced SCSS modularity by removing all inline styling and MUI sx props across typography and chart layouts, replacing them entirely with standard SCSS classes (e.g., .chart-card-title, .donut-status-active). Chart colors are now defined as CSS custom properties in the :root scope of stats.scss providing seamless, duplicate-free dark mode support natively. We also removed hardcoded #1a1a1a typography colors that previously broke dark-mode legibility.
  • Dashboard Layout Enhancements: Refactored the LatestEntitiesList component to display the entity display name and type name on two distinct lines for improved readability. We also extracted the display limits into a centralized LATEST_ENTITIES_DISPLAY_LIMIT (now configured to 6) constant to eliminate duplicate magic numbers.
  • Test Suite Synchronization & Expansion:
    • Added dedicated unit tests in metricsUtils.test.ts for getPayloadFromRechartsEvent covering valid payload objects, null/undefined inputs, primitive inputs (number, string, boolean, symbol), and specifically handling the new Recharts v3 flat payload structure fallback logic.
    • Expanded ClassificationDistributionCard.test.tsx and EntityTypeBarChart.test.tsx with full feature parity for custom Y-axis tick renderer interactions (click events, keyboard Enter/Space activation, and unhandled key guards).
    • Expanded EntityStatsChart.test.tsx to verify keyboard interactions (Enter/Space) on legend <ButtonBase> elements, CSS custom property --legend-color rendering, and unhandled key guards.
    • Updated EntityStatusDonut.test.tsx to precisely mock Recharts v3 payload structures, verify getPayloadFromRechartsEvent integration, pie slice navigation, and invalid payload guards.

Overrides Added:

  • d3-color (Override added for 3.1.0): Mitigates a High-severity ReDoS vulnerability. We opted for an override here because upgrading the main d3 library from v5 to v7 introduces significant architectural breaking changes to the graph components.

(Note: Prior overrides for brace-expansion, js-yaml, postcss, semver, minimatch, lodash, and lodash-es were removed as they are either resolved via the upgrades above or were creating invalid dependency trees).

This PR also incorporates fixes for the following automated Dependabot PRs targeting the dashboard:

(Note: Dependabot PRs #644 (qs) and #584 (serialize-javascript / webpack) which targeted /dashboard/src/views/Lineage/atlas-lineage are now obsolete. That sub-directory and its package files were deleted in commit ATLAS-5328.)

Known / Unresolved Issues & Deferred Upgrades
While running npm audit, there are a few items intentionally excluded from this PR:

1. Deferred to Separate Jiras (Breaking Changes):

  • react-router-dom: Upgrading this package to v7 involves significant architectural changes and deprecations that introduce breaking issues in the current test suite. This migration has been isolated into its own Jira to be handled carefully without blocking these security patches.
  • sanitize-html: Upgrading this library from v1 to v2 introduces breaking ESM syntax via its underlying htmlparser2 dependency, causing the Jest test environment to completely crash. This will be handled in a separate Jira so we can properly implement Jest mocks and isolated testing.

2. No Patched Version Available:

  • quill (=2.0.3): There is currently 1 low-severity vulnerability flagged for this package. However, 2.0.3 is currently the latest version available on npm. There is no patched version available yet, so this cannot be resolved until the maintainers release a newer update.

How was this patch tested?

  • Manual Verification: Ran npm audit locally in the /dashboard directory to verify that all fixable warnings (that do not cause breaking framework issues) have been successfully cleared and npm ls returns a perfectly valid dependency tree.
  • Build & Type Tests: Ran npm run build, npm run typecheck, and npm run lint to ensure the React UI complies strictly with TypeScript configurations without emitting any warnings or errors.
  • Automated Testing: Ran npm run test (Jest + React Testing Library) to verify all 196 test suites and 4,882 assertions continue to pass successfully, explicitly verifying that the Recharts v3 custom Legend DOM interactions execute correctly, missing payload scenarios fail gracefully, and label formatters work reliably.
  • Runtime Test: Started the local dev server and toggled between Light and Dark mode to verify the UI loads and functions as expected.

@Brijesh619

Copy link
Copy Markdown
Contributor Author
Screenshot from 2026-07-22 10-51-37

@Brijesh619

Copy link
Copy Markdown
Contributor Author
Screenshot from 2026-07-23 11-20-05

@Brijesh619

Copy link
Copy Markdown
Contributor Author
Screenshot from 2026-07-23 11-20-32

Comment thread dashboard/package.json Outdated
Comment thread dashboard/package.json Outdated
Comment thread dashboard/package.json Outdated
Comment thread dashboard/package-lock.json Outdated
@Brijesh619

Copy link
Copy Markdown
Contributor Author
Screenshot from 2026-08-05 17-35-17

We can currently solve 0 of the remaining 3 vulnerabilities without causing major issues for this PR.

Here is exactly why we can't safely fix them right now:

quill (1 vuln): There is simply no patched version published on npm yet for this specific advisory (GHSA-v3m3-f69x-jf25). We are physically unable to fix it until the package maintainers release a patch.
react-router (2 vulns): The security patch was only released in version 7.x. The dashboard is currently on version 6 (6.30.4). Upgrading from React Router v6 to v7 is a massive breaking change that would require rewriting the application's routing logic. A framework migration like that is far too risky and out-of-scope for a simple dependency-bump PR.

@Brijesh619
Brijesh619 force-pushed the ATLAS-5348 branch 2 times, most recently from d2a353c to fbd566d Compare August 19, 2026 05:33
@Brijesh619

Copy link
Copy Markdown
Contributor Author
Screenshot from 2026-08-19 11-03-11

@Brijesh619

Copy link
Copy Markdown
Contributor Author
Screenshot from 2026-08-19 11-04-02

Note:
Upgrade Summary Note: This PR successfully upgrades all outdated, non-breaking dependencies via npm audit fix and explicit package.json overrides (including picomatch, postcss, axios, etc.). quill remains unresolved as version 2.0.3 has no available patch yet. Additionally, the upgrades for react-router and sanitize-html have been deferred to separate Jira tickets, as upgrading them introduces breaking architectural and Jest environment issues that require isolated testing.

@Brijesh619

Copy link
Copy Markdown
Contributor Author
Screenshot from 2026-08-19 11-21-57

Comment thread dashboard/package.json
Comment thread dashboard/package.json Outdated
Comment thread dashboard/package.json Outdated
Comment thread dashboard/package.json Outdated
Comment thread dashboard/package.json
@Brijesh619

Copy link
Copy Markdown
Contributor Author
Screenshot from 2026-08-24 11-55-27 Screenshot from 2026-08-24 11-52-39

@Brijesh619
Brijesh619 force-pushed the ATLAS-5348 branch 2 times, most recently from b9be68d to b32f484 Compare August 24, 2026 15:25
@Brijesh619

Copy link
Copy Markdown
Contributor Author
Screenshot from 2026-08-24 20-51-44 Screenshot from 2026-08-24 20-57-04

Comment thread dashboard/src/views/Statistics/EntityStatsChart.tsx Outdated
Comment thread dashboard/src/views/Statistics/__tests__/EntityStats.test.tsx
Comment thread dashboard/src/styles/stats.scss Outdated
Comment thread dashboard/src/styles/stats.scss
Comment thread dashboard/src/views/DashboardOverview/EntityStatusDonut.tsx
Comment thread dashboard/src/views/DashboardOverview/dashboardChartPalette.ts Outdated
Comment thread dashboard/src/views/Statistics/EntityStatsChart.tsx Outdated
Comment thread dashboard/src/views/Statistics/EntityStatsChart.tsx Outdated
@Brijesh619

Copy link
Copy Markdown
Contributor Author
Screenshot from 2026-08-26 12-26-48 Screenshot from 2026-08-26 12-22-48

Comment thread dashboard/src/views/DashboardOverview/EntityStatusDonut.tsx
Comment thread dashboard/src/styles/stats.scss Outdated
Comment thread dashboard/src/views/DashboardOverview/EntityStatusDonut.tsx Outdated
Comment thread dashboard/src/views/DashboardOverview/MessageConsumptionChart.tsx
Comment thread dashboard/src/views/DashboardOverview/ClassificationDistributionCard.tsx Outdated
@Brijesh619

Copy link
Copy Markdown
Contributor Author
Screenshot from 2026-08-27 18-06-30 Screenshot from 2026-08-27 18-02-37

Comment thread dashboard/src/utils/metricsUtils.ts
Comment thread dashboard/src/views/DashboardOverview/EntityStatusDonut.tsx
Comment thread dashboard/src/views/Statistics/__tests__/EntityStatsChart.test.tsx
Comment thread dashboard/src/views/Statistics/EntityStatsChart.tsx Outdated
@Brijesh619

Copy link
Copy Markdown
Contributor Author
Screenshot from 2026-09-03 22-45-55 Screenshot from 2026-09-03 22-43-28

Comment thread dashboard/src/styles/stats.scss
Comment thread dashboard/src/views/DashboardOverview/EntityStatusDonut.tsx Outdated
@Brijesh619

Copy link
Copy Markdown
Contributor Author
Screenshot from 2026-09-04 15-44-29 Screenshot from 2026-09-04 15-43-07

@pawarprasad123 pawarprasad123 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.

Changes LGTM.
Minor non blocker changes n related to the hardcoded color in charts, and test case.
this can be done in dashboard performance task.

@Brijesh619

Copy link
Copy Markdown
Contributor Author
Screenshot from 2026-09-10 11-22-43 Screenshot from 2026-09-10 11-20-46

@Brijesh619

Copy link
Copy Markdown
Contributor Author
Screenshot from 2026-09-10 23-54-05 Screenshot from 2026-09-10 23-51-31

@pawarprasad123 pawarprasad123 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.

The fonts on some of the dashboard cards are mismatched; please update them properly to match the rest of the cards.

@pawarprasad123 pawarprasad123 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.

Latest master requires lint-staged@17.0.8 which declares node >= 22.22.1. On Node 20, use NPM_CONFIG_ENGINE_STRICT=false npm install in /dashboard. CI likely uses Node 22+.

@Brijesh619

Copy link
Copy Markdown
Contributor Author

The fonts on some of the dashboard cards are mismatched; please update them properly to match the rest of the cards.

handled in ATLAS-5324
PR:#688

@Brijesh619

Copy link
Copy Markdown
Contributor Author

Latest master requires lint-staged@17.0.8 which declares node >= 22.22.1. On Node 20, use NPM_CONFIG_ENGINE_STRICT=false npm install in /dashboard. CI likely uses Node 22+.

Fixed. I set engine-strict=false in the .npmrc configuration so that npm install runs smoothly on Node 20 without requiring any extra environment variables.

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.

2 participants