matcha icon indicating copy to clipboard operation
matcha copied to clipboard

BUG: Missing validation for empty IMAP/SMTP server config

Open andrinoff opened this issue 7 months ago • 2 comments

Describe the bug

In config/config.go lines 86 and 115, empty IMAPServer and SMTPServer values return empty strings without validation:

func (a *Account) GetIMAPServer() string {
    if a.IMAPServer == "" {
        return ""  // No error
    }
    return a.IMAPServer
}

Error caught later in fetcher/fetcher.go:236, but better to validate early at config load.

To reproduce

  1. Create config with empty imap_server field
  2. Start matcha
  3. Connection fails with unclear error downstream
  4. Should fail fast with clear validation error

Expected behavior

Validate config on load:

func (c *Config) Validate() error {
    for _, acc := range c.Accounts {
        if acc.IMAPServer == "" {
            return fmt.Errorf("account %q: imap_server is required", acc.Email)
        }
        if acc.SMTPServer == "" {
            return fmt.Errorf("account %q: smtp_server is required", acc.Email)
        }
    }
    return nil
}

Screenshots

N/A

Additional context

  • File: config/config.go
  • Lines: 86, 115
  • Severity: Low-Medium - poor error UX
  • Fix complexity: Easy - add validation function

andrinoff avatar Apr 16 '26 20:04 andrinoff

This has had no activity for 30 days. It will be closed in 14 days unless updated. Comment or remove the stale label to keep it open.

floatpanebot avatar May 17 '26 05:05 floatpanebot

Closing due to inactivity. Reopen if still relevant.

floatpanebot avatar May 31 '26 06:05 floatpanebot