Fix bd-120: Fix nil pointer crash in export command when daemon is running

Amp-Thread-ID: https://ampcode.com/threads/T-f6d324a9-aa24-4cf8-9962-7391602c8c91
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Steve Yegge
2025-10-17 17:40:16 -07:00
parent afae421032
commit e9729abd73
2 changed files with 19 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ import (
"strings"
"github.com/spf13/cobra"
"github.com/steveyegge/beads/internal/storage/sqlite"
"github.com/steveyegge/beads/internal/types"
)
@@ -62,6 +63,23 @@ Output to stdout by default, or use -o flag for file output.`,
os.Exit(1)
}
// Export command doesn't work with daemon - need direct access
// Ensure we have a direct store connection
if store == nil {
// Initialize store directly even if daemon is running
var err error
if dbPath == "" {
fmt.Fprintf(os.Stderr, "Error: no database path found\n")
os.Exit(1)
}
store, err = sqlite.New(dbPath)
if err != nil {
fmt.Fprintf(os.Stderr, "Error: failed to open database: %v\n", err)
os.Exit(1)
}
defer store.Close()
}
// Build filter
filter := types.IssueFilter{}
if statusFilter != "" {