fix(graph): pass subgraph to renderGraph to fix nil pointer crash
The renderGraph function was being called with nil instead of the loaded subgraph, causing a nil pointer dereference in computeDependencyCounts when iterating over subgraph.Dependencies. Changes: - Pass subgraph variable to renderGraph instead of nil - Add defensive nil check in computeDependencyCounts - Add test case for nil subgraph handling Fixes GH#657 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -425,6 +425,10 @@ func computeDependencyCounts(subgraph *TemplateSubgraph) (blocks map[string]int,
|
||||
blocks = make(map[string]int)
|
||||
blockedBy = make(map[string]int)
|
||||
|
||||
if subgraph == nil {
|
||||
return blocks, blockedBy
|
||||
}
|
||||
|
||||
for _, dep := range subgraph.Dependencies {
|
||||
if dep.Type == types.DepBlocks {
|
||||
// dep.DependsOnID blocks dep.IssueID
|
||||
|
||||
@@ -202,6 +202,16 @@ func stringContains(s, substr string) bool {
|
||||
}
|
||||
|
||||
func TestComputeDependencyCounts(t *testing.T) {
|
||||
t.Run("nil subgraph", func(t *testing.T) {
|
||||
blocks, blockedBy := computeDependencyCounts(nil)
|
||||
if len(blocks) != 0 {
|
||||
t.Errorf("expected empty blocks map for nil subgraph, got %d entries", len(blocks))
|
||||
}
|
||||
if len(blockedBy) != 0 {
|
||||
t.Errorf("expected empty blockedBy map for nil subgraph, got %d entries", len(blockedBy))
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("empty subgraph", func(t *testing.T) {
|
||||
subgraph := &TemplateSubgraph{
|
||||
Root: &types.Issue{ID: "root-1"},
|
||||
|
||||
Reference in New Issue
Block a user