From 562791f53ef8e798a7419376bdf04a50fdae6058 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 18 Nov 2025 00:57:40 +0000 Subject: [PATCH 1/3] fix(api): resolve undefined err variable in stubs.go Fixed compilation errors in GetMetrics function where the err variable was being used outside its scope. Declared err at function level and updated assignments from := to = in nested blocks. Fixes: - internal/api/stubs.go:735: undefined: err - internal/api/stubs.go:744: undefined: err - internal/api/stubs.go:745: undefined: err - internal/api/stubs.go:758: undefined: err - internal/api/stubs.go:765: undefined: err - internal/api/stubs.go:766: undefined: err --- api/internal/api/stubs.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/internal/api/stubs.go b/api/internal/api/stubs.go index 3820e77b..c233ec54 100644 --- a/api/internal/api/stubs.go +++ b/api/internal/api/stubs.go @@ -676,6 +676,7 @@ func (h *Handler) GetMetrics(c *gin.Context) { ctx := c.Request.Context() // Initialize default values + var err error totalNodes := 0 readyNodes := 0 totalCPU := int64(0) @@ -685,7 +686,7 @@ func (h *Handler) GetMetrics(c *gin.Context) { // Get cluster nodes (handle nil k8sClient gracefully) if h.k8sClient != nil { - nodes, err := h.k8sClient.GetNodes(ctx) + nodes, err = h.k8sClient.GetNodes(ctx) if err != nil { log.Printf("Failed to get cluster nodes: %v", err) // Continue with default values instead of failing @@ -715,7 +716,7 @@ func (h *Handler) GetMetrics(c *gin.Context) { } // Get all pods to calculate resource usage - pods, err := h.k8sClient.GetPods(ctx, h.namespace) + pods, err = h.k8sClient.GetPods(ctx, h.namespace) if err == nil { usedPods = len(pods.Items) } From d3433727245a7d090d1d224d9111745e5331e87f Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 18 Nov 2025 01:02:54 +0000 Subject: [PATCH 2/3] fix(api): declare nodes and pods variables at function level Fixed compilation errors by declaring nodes and pods variables at the function level alongside err. This allows them to be properly assigned within nested blocks without redeclaration. Fixes: - internal/api/stubs.go:689: undefined: nodes - internal/api/stubs.go:694: undefined: nodes - internal/api/stubs.go:697: undefined: nodes - internal/api/stubs.go:719: undefined: pods - internal/api/stubs.go:721: undefined: pods --- api/internal/api/stubs.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/internal/api/stubs.go b/api/internal/api/stubs.go index c233ec54..c1606070 100644 --- a/api/internal/api/stubs.go +++ b/api/internal/api/stubs.go @@ -677,6 +677,8 @@ func (h *Handler) GetMetrics(c *gin.Context) { // Initialize default values var err error + var nodes *corev1.NodeList + var pods *corev1.PodList totalNodes := 0 readyNodes := 0 totalCPU := int64(0) From 8fb9d5cadc3638969c7e30282aeb255cd1d39b4e Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 18 Nov 2025 01:09:37 +0000 Subject: [PATCH 3/3] fix(ui): prevent undefined groups access in UserDetail Add optional chaining to safely check if userGroups.groups exists before accessing its length property. This prevents the TypeError: "can't access property 'length', b.groups is undefined" when the groups property is not returned by the API. --- ui/src/pages/admin/UserDetail.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/pages/admin/UserDetail.tsx b/ui/src/pages/admin/UserDetail.tsx index 5b48a2eb..0579908b 100644 --- a/ui/src/pages/admin/UserDetail.tsx +++ b/ui/src/pages/admin/UserDetail.tsx @@ -459,7 +459,7 @@ export default function UserDetail() { - {userGroups && userGroups.groups.length > 0 ? ( + {userGroups?.groups && userGroups.groups.length > 0 ? (