From db1ebb7a3f9310ca2cc483d65e9c0e578c2eb4ff Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Sun, 8 Mar 2026 20:40:47 +0000 Subject: config: Default() returns error Default() now returns (*Config, error) so callers can detect TOML parse failures rather than silently falling back to zero values. Co-Authored-By: Claude Sonnet 4.6 --- internal/config/config.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'internal/config/config.go') diff --git a/internal/config/config.go b/internal/config/config.go index da7f264..12adf68 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -1,6 +1,8 @@ package config import ( + "errors" + "fmt" "os" "path/filepath" ) @@ -16,8 +18,14 @@ type Config struct { WebhookURL string `toml:"webhook_url"` } -func Default() *Config { - home, _ := os.UserHomeDir() +func Default() (*Config, error) { + home, err := os.UserHomeDir() + if err != nil { + return nil, fmt.Errorf("cannot determine home directory: %w", err) + } + if home == "" { + return nil, errors.New("cannot determine home directory: HOME is empty") + } dataDir := filepath.Join(home, ".claudomator") return &Config{ DataDir: dataDir, @@ -27,7 +35,7 @@ func Default() *Config { MaxConcurrent: 3, DefaultTimeout: "15m", ServerAddr: ":8484", - } + }, nil } // EnsureDirs creates the data directory structure. -- cgit v1.2.3