argoproj/argo-workflows · error
invalid log type: %s
Error message
invalid log type: %s
What it means
TypeFromString converts a log-format string into the LogType enum; only "json" and "text" are accepted (case-insensitive). Anything else returns the default Text type plus this error so callers can report a misconfigured ARGO_LOG_FORMAT or equivalent setting.
Source
Thrown at util/logging/logging.go:46
JSON LogType = "json"
Text LogType = "text"
)
func TypeFromStringOr(s string, defaultType LogType) (LogType, error) {
if s == "" {
return defaultType, nil
}
return TypeFromString(s)
}
func TypeFromString(s string) (LogType, error) {
switch strings.ToLower(s) {
case "json":
return JSON, nil
case "text":
return Text, nil
default:
return Text, fmt.Errorf("invalid log type: %s", s)
}
}
// Level is used to indicate log level
type Level string
const (
// Debug level events
Debug Level = "debug"
// Info level events
Info Level = "info"
// Warn level events
Warn Level = "warn"
// Error level events
Error Level = "error"
)
func ParseLevelOr(s string, defaultLevel Level) (Level, error) {View on GitHub (pinned to 35bff19146)
Solutions
- Set the format to exactly "json" or "text" (case-insensitive).
- Prefer TypeFromStringOr/ContextWithLogger with an empty value so the default is applied instead of erroring.
- Trim the value before passing: strings.TrimSpace(os.Getenv(...)).
- If you need structured logs of a different shape, wrap the existing JSON logger rather than requesting a new type.
Example fix
// before
fmt, err := logging.TypeFromString("logfmt")
// after
fmt, err := logging.TypeFromStringOr(strings.TrimSpace(cfg.Format), logging.Text) Defensive patterns
Strategy: validation
Validate before calling
var validLogTypes = map[string]bool{"json": true, "text": true}
func logTypeValid(s string) bool { return s == "" || validLogTypes[strings.ToLower(strings.TrimSpace(s))] } Try / catch
lt, err := logging.TypeFromStringOr(strings.TrimSpace(raw), logging.Text)
if err != nil {
log.Printf("bad log format %q, using text", raw)
lt = logging.Text
} Prevention
- Restrict config knobs to json/text and document them.
- Trim env values before parsing.
- Use the ...Or variants with a default instead of hard-failing on unset/odd values.
When it happens
Trigger: Setting the log format env var (e.g. ARGO_LOG_FORMAT) or calling TypeFromString/ContextWithLogger with values like "pretty", "logfmt", "console", or a trailing-space/newline-contaminated value.
Common situations: Deploy manifests or Helm values copying a log format from another tool (zap/logrus options); YAML env values that pick up quotes or whitespace; documentation drift after the logger migration to the repo's own util/logging.
Related errors
AI-assisted analysis of argoproj/argo-workflows@35bff19146 (2026-09-03).
Data as JSON: /api/errors/0d58a79a7b2d41b4.
Report an issue: GitHub.