Skip to content

fix: null-guard intelligence display to prevent TypeError crashes#1086

Open
SNooZyy2 wants to merge 1 commit intoruvnet:mainfrom
SNooZyy2:fix/null-guard-intelligence-display
Open

fix: null-guard intelligence display to prevent TypeError crashes#1086
SNooZyy2 wants to merge 1 commit intoruvnet:mainfrom
SNooZyy2:fix/null-guard-intelligence-display

Conversation

@SNooZyy2
Copy link

@SNooZyy2 SNooZyy2 commented Feb 6, 2026

Summary

  • Added 15 null-guards to the hooks intelligence display code
  • Prevents TypeError: Cannot read properties of undefined (reading 'toFixed') when MCP response fields are absent
  • Guards cover all 5 display sections: SONA, MoE, HNSW, Embeddings, V3 Performance

Problem

Running claude-flow hooks intelligence crashes immediately after printing the SONA header because the MCP tool handler (hooks_intelligence) does not include computed fields like learningTimeMs, adaptationTimeMs, avgQuality etc. in its response. The display code calls .toFixed() on undefined values.

Fix

Uses ?? (nullish coalescing) to provide safe defaults:

  • ?? 0 for numeric fields
  • ?? 'N/A' for string fields
  • ?. for optional parent objects (result.performance?.flashAttention)

Test plan

  • Run claude-flow hooks intelligence — should display full dashboard without crash (exit 0)
  • Run claude-flow hooks intelligence --format json — should output valid JSON
  • Verify all 5 sections render: SONA, MoE, HNSW, Embeddings, Performance

Generated with claude-flow

…shes

The hooks intelligence command crashes with 'TypeError: Cannot read
properties of undefined (reading toFixed)' when the MCP tool response
is missing optional fields (learningTimeMs, adaptationTimeMs, avgQuality,
expertsActive, routingAccuracy, loadBalance, searchSpeedup, memoryUsage,
dimension, cacheHitRate, performance section).

Added 15 null-guards using ?? operator across 5 display sections (SONA,
MoE, HNSW, Embeddings, V3 Performance) to handle absent fields gracefully.

Ref: ADR-015

Co-Authored-By: claude-flow <ruv@ruv.net>
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.

1 participant