slackhq/nebula · error
not a valid logging level: %q
Error message
not a valid logging level: %q
What it means
ParseLevel converts a string log level to slog.Level and returns this error for unrecognized strings. Accepted values include debug/info/warn/warning/error/fatal/panic (per the switch); everything else fails. Called by ApplyConfig and sshLogLevel.
Source
Thrown at logging/logger.go:214
// "warn"/"warning", "error", "fatal"/"panic") to a slog.Level. "fatal" and
// "panic" are accepted for backwards compatibility with pre-slog configs
// and both map to slog.LevelError.
func ParseLevel(s string) (slog.Level, error) {
switch s {
case "trace":
return LevelTrace, nil
case "debug":
return slog.LevelDebug, nil
case "info":
return slog.LevelInfo, nil
case "warn", "warning":
return slog.LevelWarn, nil
case "error":
return slog.LevelError, nil
case "fatal", "panic":
return slog.LevelError, nil
default:
return 0, fmt.Errorf("not a valid logging level: %q", s)
}
}
// LevelName returns a human-readable name for a slog.Level matching the
// strings accepted by ParseLevel.
func LevelName(l slog.Level) string {
switch {
case l <= LevelTrace:
return "trace"
case l <= slog.LevelDebug:
return "debug"
case l <= slog.LevelInfo:
return "info"
case l <= slog.LevelWarn:
return "warn"
default:
return "error"
}View on GitHub (pinned to dd8f660c0a)
Solutions
- Use a supported level string: debug, info, warn/warning, error, fatal/panic
- Trim and lowercase the level string before parsing
- Remove stray quotes/whitespace in the YAML value
Example fix
// before
lvl, err := logging.ParseLevel("trace")
// after
s, err2 := sanitize(level)
if err2 != nil { return err2 }
lvl, err := logging.ParseLevel(strings.ToLower(strings.TrimSpace(s))) Defensive patterns
Strategy: validation
Validate before calling
lvl, err := logging.ParseLevel(strings.ToLower(strings.TrimSpace(cfgLevel)))
if err != nil {
lvl = slog.LevelInfo // or fail fast
} Prevention
- Use only documented levels: debug, info, warn, warning, error, fatal, panic
- Note there is no 'trace' or 'verbose' level in this library
- Trim/lowercase level values parsed from YAML or SSH console input
When it happens
Trigger: Setting a level in config or via SSH console (sshLogLevel) such as 'verbose', 'trace', 'WARN ' (whitespace), or a numeric level string that the switch does not handle.
Common situations: Using 'trace' or 'verbose' from other tools' conventions; trailing whitespace/quotes in YAML; case-sensitive input like 'DEBUG'.
Related errors
- unknown log format `%s`. possible formats: %s
- unknown protocol %v
- %s failed to parse, should be an array of rules
- %s rule #%v; only one of port or code should be provided
- %s rule #%v; at least one of host, group, cidr, local_cidr,
AI-assisted analysis of slackhq/nebula@dd8f660c0a (2026-09-03).
Data as JSON: /api/errors/4b689c94fcd9d95a.
Report an issue: GitHub.