Skip to content

BUG: Missing validation for empty IMAP/SMTP server config #618

@andrinoff

Description

@andrinoff

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions