Skip to content

Commit 67c482a

Browse files
Grivnclaude
andcommitted
Check EmbeddingStats query errors consistently
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f396d90 commit 67c482a

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

cmd/embed.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ Modes:
3636

3737
// Status mode
3838
if embedStatus {
39-
total, embedded, _ := db.EmbeddingStats()
39+
total, embedded, err := db.EmbeddingStats()
40+
if err != nil {
41+
return fmt.Errorf("embedding stats: %w", err)
42+
}
4043
output := map[string]interface{}{
4144
"total_insights": total,
4245
"embedded": embedded,

internal/store/node.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,8 +669,12 @@ func (db *DB) ScanEmbeddings(fn func(id string, blob []byte) bool) error {
669669

670670
// EmbeddingStats returns total insights and how many have embeddings.
671671
func (db *DB) EmbeddingStats() (total int, embedded int, err error) {
672-
db.execer().QueryRow(`SELECT COUNT(*) FROM insights WHERE deleted_at IS NULL`).Scan(&total)
673-
db.execer().QueryRow(`SELECT COUNT(*) FROM insights WHERE deleted_at IS NULL AND embedding IS NOT NULL`).Scan(&embedded)
672+
if err := db.execer().QueryRow(`SELECT COUNT(*) FROM insights WHERE deleted_at IS NULL`).Scan(&total); err != nil {
673+
return 0, 0, fmt.Errorf("count active insights: %w", err)
674+
}
675+
if err := db.execer().QueryRow(`SELECT COUNT(*) FROM insights WHERE deleted_at IS NULL AND embedding IS NOT NULL`).Scan(&embedded); err != nil {
676+
return 0, 0, fmt.Errorf("count embedded insights: %w", err)
677+
}
674678
return total, embedded, nil
675679
}
676680

0 commit comments

Comments
 (0)