From 86988fccf47ff2838c483c377abd37b08f1333c8 Mon Sep 17 00:00:00 2001 From: Daan van Etten Date: Sat, 18 Oct 2025 18:33:34 +0200 Subject: [PATCH] Fix nil pointer dereference in bd show command (#80) The show command was crashing with a nil pointer dereference when accessing issue.CompactionLevel. This occurred due to two issues in the daemon mode response handling: 1. The IssueDetails struct incorrectly embedded *types.Issue as a pointer, causing the JSON unmarshaling to leave it nil. Changed to embed types.Issue directly. 2. Missing null check for non-existent issues. The daemon returns null when an issue is not found, which wasn't handled properly. Added explicit null checking before parsing the response to provide a clear error message when issues don't exist. Fixes panic when running: bd show --- cmd/bd/main.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/bd/main.go b/cmd/bd/main.go index 13a0389c..d28e06c4 100644 --- a/cmd/bd/main.go +++ b/cmd/bd/main.go @@ -1347,9 +1347,15 @@ var showCmd = &cobra.Command{ if jsonOutput { fmt.Println(string(resp.Data)) } else { + // Check if issue exists (daemon returns null for non-existent issues) + if string(resp.Data) == "null" || len(resp.Data) == 0 { + fmt.Fprintf(os.Stderr, "Issue %s not found\n", args[0]) + os.Exit(1) + } + // Parse response and use existing formatting code type IssueDetails struct { - *types.Issue + types.Issue Labels []string `json:"labels,omitempty"` Dependencies []*types.Issue `json:"dependencies,omitempty"` Dependents []*types.Issue `json:"dependents,omitempty"` @@ -1359,7 +1365,7 @@ var showCmd = &cobra.Command{ fmt.Fprintf(os.Stderr, "Error parsing response: %v\n", err) os.Exit(1) } - issue := details.Issue + issue := &details.Issue cyan := color.New(color.FgCyan).SprintFunc()