Fix undefined variable error in Quotas component#68
Merged
JoshuaAFerguson merged 10 commits intoNov 17, 2025
Merged
Conversation
- Add defensive checks to ensure quotas array is never undefined - Use optional chaining (?.) and nullish coalescing (??) for all quota properties - Set empty array as fallback when API returns undefined or on error - Apply same defensive pattern as QuotaCard component - Prevents "TypeError: can't access property 'length', k is undefined" error Fixes error occurring at Quotas.tsx:322 when API returns undefined data.
- Add defensive checks to ensure templates array is never undefined - Use optional chaining (?.) for template property access - Set empty array as fallback when API returns undefined or on error - Add fallback values for totalPages to prevent undefined errors - Apply same defensive pattern as other components Fixes error occurring at EnhancedCatalog.tsx:308 when API returns undefined data.
- Add defensive error handling for 404 responses from node APIs - Return empty arrays/null when API endpoints not implemented - Ensure nodes array is never undefined to prevent crashes - Handle Promise.all rejections individually with .catch() The node management APIs (/admin/nodes, /admin/nodes/stats) haven't been implemented in the backend yet. This fix allows the UI to load without errors while those endpoints are being developed.
Add comprehensive node management API for cluster administrators with full CRUD operations for node labels, taints, and scheduling. Backend Implementation: - Create NodeHandler with 10 admin-only endpoints - List all nodes with detailed status and resource info - Get cluster-wide statistics (ready/not ready nodes, aggregate capacity) - Add/remove node labels for pod scheduling affinity - Add/remove node taints for workload isolation - Cordon/uncordon nodes to control scheduling - Drain nodes with graceful pod eviction K8s Client Extensions: - Add GetNode() for fetching individual node details - Add PatchNode() for strategic merge patches - Add UpdateNodeTaints() for taint management - Add CordonNode()/UncordonNode() for scheduling control - Add DrainNode() with graceful pod eviction and DaemonSet filtering API Routes (all require admin role): - GET /admin/nodes - List all cluster nodes - GET /admin/nodes/stats - Get aggregate cluster statistics - GET /admin/nodes/:name - Get specific node details - PUT /admin/nodes/:name/labels - Add node label - DELETE /admin/nodes/:name/labels/:key - Remove node label - POST /admin/nodes/:name/taints - Add node taint - DELETE /admin/nodes/:name/taints/:key - Remove node taint - POST /admin/nodes/:name/cordon - Mark node unschedulable - POST /admin/nodes/:name/uncordon - Mark node schedulable - POST /admin/nodes/:name/drain - Evict all pods from node Features: - Admin-only authentication required for all operations - Comprehensive node metadata (OS, kernel, kubelet version, runtime) - Cloud provider info extraction (region, zone, instance type) - Safe pod eviction during drain (skips DaemonSets and static pods) - Configurable grace period for pod eviction - Detailed error handling and validation Related UI fix: - Fix 404 errors in AdminNodes page by providing graceful fallbacks - UI will now load without errors even before backend deployment Fixes #AdminNodes 404 errors in UI
- Add defensive error handling for 404 responses from compliance APIs - Ensure frameworks, policies, and violations arrays are never undefined - Set default metrics object when API fails - Fix typo: loadMetrics() → loadDashboard() - Return empty arrays/default objects when endpoints not implemented The compliance APIs (/compliance/frameworks, /compliance/policies, /compliance/violations, /compliance/dashboard) are handled by the streamspace-compliance plugin. This fix allows the UI to load without errors when the plugin is not installed. Fixes compliance 404 errors in admin UI
- Add defensive checks for all data loading functions - Ensure lbPolicies, nodes, asPolicies, and scalingHistory are never undefined - Set empty arrays as fallback when API returns undefined or on error - Apply same defensive pattern as other admin pages Fixes error at Scaling.tsx:427 when trying to access nodes.length on undefined value. Related APIs: - /scaling/load-balancing/policies - /scaling/load-balancing/nodes - /scaling/autoscaling/policies - /scaling/autoscaling/history
- Add defensive checks for loadWebhooks() and loadIntegrations() - Ensure webhooks and integrations arrays are never undefined - Set empty arrays as fallback when API returns undefined or on error - Apply same defensive pattern as other admin pages Fixes error at Integrations.tsx:374 when trying to access webhooks.length on undefined value. Related APIs: - /integrations/webhooks - /integrations/external
- Add defensive check in loadPlugins() to ensure array is never undefined - Add optional chaining to stats calculation for extra safety - Set empty array as fallback when API returns undefined or on error - Apply same defensive pattern as other admin pages Fixes error at Plugins.tsx:263 when trying to access plugins.length on undefined value. Related API: - /plugins/installed
…shboard error handling - Fixed AdminDashboard.tsx error handling bug where setError was called but error is not a state variable - Added defensive checks in AdminDashboard.tsx to handle undefined or incorrect metrics data structure - Implemented proper GetMetrics API handler that returns cluster metrics (nodes, sessions, resources, users) - GetMetrics now queries Kubernetes for node status and resource allocation - GetMetrics queries database for session counts (running, hibernated, terminated) and user counts (total, active) - Added fmt import to stubs.go for proper int64 to string conversion - Resource usage estimation based on running session counts (1000m CPU, 2GiB memory per session) This fixes the "Failed to load Metrics" error on /admin/dashboard that was caused by GetMetrics returning connection tracker stats instead of the expected cluster metrics structure. Related to: undefined array error fixes across admin pages
- Added Users menu item to admin navigation (/admin/users) - Added Groups menu item to admin navigation (/admin/groups) - Imported Groups icon from Material-UI - Menu items positioned after Admin Dashboard for easy access - Routes already exist in App.tsx, pages are implemented and working - Both Users.tsx and Groups.tsx already have defensive error handling This fixes the issue where user and group management pages existed but were not accessible from the navigation menu, requiring manual URL entry to access. Related to: admin page navigation improvements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.