From eb930b0794ea7711aeb96eda62b50d3fdccc802f Mon Sep 17 00:00:00 2001 From: Harry Culpan Date: Tue, 30 Jun 2026 20:37:39 -0400 Subject: [PATCH] Improve email config error to name the missing variable(s) Co-Authored-By: Claude Sonnet 4.6 --- pkg/email/config.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/pkg/email/config.go b/pkg/email/config.go index b11bc65..ddaa08b 100644 --- a/pkg/email/config.go +++ b/pkg/email/config.go @@ -3,6 +3,7 @@ package email import ( "fmt" "os" + "strings" "github.com/emersion/go-imap/client" "github.com/joho/godotenv" @@ -44,8 +45,21 @@ func NewConfigFromEnv() (*Config, error) { fetchServer = os.Getenv("IMAP_SERVER") sendServer = os.Getenv("SMTP_SERVER") - if len(username) == 0 || len(password) == 0 || len(fetchServer) == 0 || len(sendServer) == 0 { - return nil, fmt.Errorf("missing configuration variables") + var missing []string + if len(username) == 0 { + missing = append(missing, "EMAIL_USERNAME") + } + if len(password) == 0 { + missing = append(missing, "EMAIL_PASSWORD") + } + if len(fetchServer) == 0 { + missing = append(missing, "IMAP_SERVER") + } + if len(sendServer) == 0 { + missing = append(missing, "SMTP_SERVER") + } + if len(missing) > 0 { + return nil, fmt.Errorf("missing configuration variables: %s", strings.Join(missing, ", ")) } return NewConfig(username, password, fetchServer, sendServer), nil