Skip to content

Commit 094bbbb

Browse files
wesmclaude
andcommitted
Propagate DB errors from findGmailSource instead of masking as nil
A query failure in GetSourcesByIdentifier was silently converted to "account not found" with exit code 0. Now findGmailSource returns an error, and verify propagates it. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8d18bf0 commit 094bbbb

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

cmd/msgvault/cmd/addaccount.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,21 +145,22 @@ Examples:
145145

146146
func findGmailSource(
147147
s *store.Store, email string,
148-
) *store.Source {
148+
) (*store.Source, error) {
149149
sources, err := s.GetSourcesByIdentifier(email)
150150
if err != nil {
151-
return nil
151+
return nil, fmt.Errorf("look up sources for %s: %w", email, err)
152152
}
153153
for _, src := range sources {
154154
if src.SourceType == "gmail" {
155-
return src
155+
return src, nil
156156
}
157157
}
158-
return nil
158+
return nil, nil
159159
}
160160

161161
func hasGmailSource(s *store.Store, email string) bool {
162-
return findGmailSource(s, email) != nil
162+
src, _ := findGmailSource(s, email)
163+
return src != nil
163164
}
164165

165166
func init() {

cmd/msgvault/cmd/verify.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ Examples:
9292
// under the identifier from add-account. Filter to Gmail
9393
// specifically since the same identifier may exist for
9494
// other source types (mbox, imap).
95-
source := findGmailSource(s, email)
95+
source, err := findGmailSource(s, email)
96+
if err != nil {
97+
return fmt.Errorf("get source: %w", err)
98+
}
9699
if source == nil {
97100
fmt.Printf("Gmail account %s not found in database.\n", email)
98101
fmt.Println("Run 'sync-full' first to populate the archive.")

0 commit comments

Comments
 (0)