worker+voice: per-conn context, store error hygiene, StateDir wiring, pipe leak
worker/server.go: dispatch now receives a per-connection context instead of context.Background(), so handler cancellation propagates on conn close. voice/server.go: same — per-conn context fed through safeDispatch into HandlePushToTalk instead of context.Background(). store/reminders.go: propagate LastInsertId error. store/nudges.go: propagate LastInsertId and RowsAffected errors. store/tools.go: propagate RowsAffected error. config/config.go: applyDefaults now respects StateDir when set, using it as the base for empty DBPath/SocketPath instead of silently ignoring it. phraser/llmphraser.go: close stderr pipe fd when cmd.Start() fails.
This commit is contained in:
@@ -42,7 +42,10 @@ func (s *Store) RecordNudge(ctx context.Context, rule, channel, message string,
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("record nudge: %w", err)
|
||||
}
|
||||
id, _ := res.LastInsertId()
|
||||
id, err := res.LastInsertId()
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("record nudge: last insert id: %w", err)
|
||||
}
|
||||
return id, nil
|
||||
}
|
||||
|
||||
@@ -62,7 +65,10 @@ func (s *Store) ResolveNudge(ctx context.Context, id int64, outcome string, ts t
|
||||
if err != nil {
|
||||
return fmt.Errorf("resolve nudge: %w", err)
|
||||
}
|
||||
n, _ := res.RowsAffected()
|
||||
n, err := res.RowsAffected()
|
||||
if err != nil {
|
||||
return fmt.Errorf("resolve nudge: rows affected: %w", err)
|
||||
}
|
||||
if n == 0 {
|
||||
// either no such row, or it was already resolved — distinguish so callers
|
||||
// can tell a bug from a race.
|
||||
|
||||
@@ -34,7 +34,10 @@ func (s *Store) CreateReminder(ctx context.Context, fire time.Time, payload stri
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("create reminder: %w", err)
|
||||
}
|
||||
id, _ := res.LastInsertId()
|
||||
id, err := res.LastInsertId()
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("create reminder: last insert id: %w", err)
|
||||
}
|
||||
return id, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,10 @@ func (s *Store) ProposeTool(ctx context.Context, name, utterance string, ts time
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("propose tool: %w", err)
|
||||
}
|
||||
n, _ := res.RowsAffected()
|
||||
n, err := res.RowsAffected()
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("propose tool: rows affected: %w", err)
|
||||
}
|
||||
return n > 0, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user