From 52693eb53e1f7dfafabcd528ffee89fcd3586853 Mon Sep 17 00:00:00 2001 From: SagarRajput-7 <162284829+SagarRajput-7@users.noreply.github.com> Date: Wed, 5 Mar 2025 11:13:51 +0530 Subject: [PATCH] fix: added safety checks for buildgraph functions and revert upgrades (#7215) --- frontend/package.json | 6 +----- .../NewDashboard/DashboardVariablesSelection/util.ts | 6 +++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index 6c8140f456..af78690982 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -250,10 +250,6 @@ "body-parser": "1.20.3", "http-proxy-middleware": "3.0.3", "cross-spawn": "7.0.5", - "cookie": "^0.7.1", - "react-router/path-to-regexp": "^1.7.0", - "webpack-dev-server/path-to-regexp": "^1.7.0", - "express/path-to-regexp": "^1.7.0", - "@types/webpack-dev-server/path-to-regexp": "^1.7.0" + "cookie": "^0.7.1" } } diff --git a/frontend/src/container/NewDashboard/DashboardVariablesSelection/util.ts b/frontend/src/container/NewDashboard/DashboardVariablesSelection/util.ts index 3b79111bfa..b0a76e934b 100644 --- a/frontend/src/container/NewDashboard/DashboardVariablesSelection/util.ts +++ b/frontend/src/container/NewDashboard/DashboardVariablesSelection/util.ts @@ -106,7 +106,7 @@ export const buildDependencyGraph = ( Object.keys(dependencies).forEach((node) => { if (!inDegree[node]) inDegree[node] = 0; if (!adjList[node]) adjList[node] = []; - dependencies[node].forEach((child) => { + dependencies[node]?.forEach((child) => { if (!inDegree[child]) inDegree[child] = 0; inDegree[child]++; adjList[node].push(child); @@ -126,13 +126,13 @@ export const buildDependencyGraph = ( } topologicalOrder.push(current); - adjList[current].forEach((neighbor) => { + adjList[current]?.forEach((neighbor) => { inDegree[neighbor]--; if (inDegree[neighbor] === 0) queue.push(neighbor); }); } - if (topologicalOrder.length !== Object.keys(dependencies).length) { + if (topologicalOrder.length !== Object.keys(dependencies)?.length) { console.error('Cycle detected in the dependency graph!'); }