SigNoz/signoz · error

CodeInvalidInput

CodeInvalidInput

Error message

unexpected server challenge

What it means

smtp/client's LOGIN auth implementation answers the server's challenge prompts ('username:' / 'password:'). If the server sends any other challenge string, the client cannot respond and aborts with 'unexpected server challenge'.

Source

Thrown at pkg/smtp/client/auth.go:31

}

func LoginAuth(username, password string) smtp.Auth {
	return &loginAuth{username, password}
}

func (auth *loginAuth) Start(server *smtp.ServerInfo) (string, []byte, error) {
	return "LOGIN", []byte{}, nil
}

func (auth *loginAuth) Next(fromServer []byte, more bool) ([]byte, error) {
	if more {
		switch strings.ToLower(string(fromServer)) {
		case "username:":
			return []byte(auth.username), nil
		case "password:":
			return []byte(auth.password), nil
		default:
			return nil, errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "unexpected server challenge")
		}
	}
	return nil, nil
}

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Use PLAIN or CRAM-MD5 auth instead of LOGIN if the server advertises it
  2. Inspect the raw SMTP dialogue (enable client debug logging) to see the actual challenge string
  3. Add the observed challenge to the switch in auth.go Next (if you control the fork)

Example fix

// before
client.SetAuth(smtp.LoginAuth(user, pass))

// after
client.SetAuth(smtp.PlainAuth("", user, pass, host))
Defensive patterns

Strategy: fallback

Validate before calling

// prefer PLAIN when the server offers it, avoiding LOGIN quirks
if strings.Contains(ehloAuthLine, "PLAIN") {
    auth = plainAuth
}

Try / catch

if err := client.Do(ctx); err != nil {
    if strings.Contains(err.Error(), "unexpected server challenge") {
        // retry with PLAIN/CRAM-MD5 auth mechanism
    }
}

Prevention

When it happens

Trigger: Authenticating to an SMTP server using LOGIN auth where the server sends a non-standard prompt (different casing is handled, but different wording is not), or the server sends an extra prompt after username/password.

Common situations: Non-compliant or proxy SMTP servers (some Exchange front-ends, load balancers) that phrase prompts differently; servers that request additional steps like 'password again'.

Related errors


AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28). Data as JSON: /api/errors/3cef264eb9c5a599. Report an issue: GitHub.