googleapis/mcp-toolbox · error
log level must be one of "debug", "info", "warn", or "error"
Error message
log level must be one of "debug", "info", "warn", or "error"
What it means
StringLevel is the pflag type for the --log-level flag; its Set method accepts only debug, info, warn, or error (case-insensitive). Any other value returns this error and prevents startup. It is a strict CLI argument validation.
Source
Thrown at internal/server/config.go:153
type StringLevel string
// String is used by both fmt.Print and by Cobra in help text
func (s *StringLevel) String() string {
if string(*s) != "" {
return strings.ToLower(string(*s))
}
return "info"
}
// validate log level flag
func (s *StringLevel) Set(v string) error {
switch strings.ToLower(v) {
case "debug", "info", "warn", "error":
*s = StringLevel(v)
return nil
default:
return fmt.Errorf(`log level must be one of "debug", "info", "warn", or "error"`)
}
}
// Type is used in Cobra help text
func (s *StringLevel) Type() string {
return "stringLevel"
}
type SourceConfigs map[string]sources.SourceConfig
type AuthServiceConfigs map[string]auth.AuthServiceConfig
type EmbeddingModelConfigs map[string]embeddingmodels.EmbeddingModelConfig
type ToolConfigs map[string]tools.ToolConfig
type PromptConfigs map[string]prompts.PromptConfig
type GroupConfigs map[string]group.GroupConfig
func UnmarshalPrimitiveConfig(ctx context.Context, raw []byte) (SourceConfigs, AuthServiceConfigs, EmbeddingModelConfigs, ToolConfigs, PromptConfigs, GroupConfigs, error) {
// prepare configs map
var sourceConfigs SourceConfigsView on GitHub (pinned to 8cc6e09de2)
Solutions
- Use one of: --log-level=debug, info, warn, or error
- Replace "warning" with "warn" or "fatal" with "error"
- Omit the flag to use the default level
Example fix
// before toolbox --log-level warning // after toolbox --log-level warn
Defensive patterns
Strategy: validation
Validate before calling
const ALLOWED = ['debug', 'info', 'warn', 'error'];
if (!ALLOWED.includes(logLevel.toLowerCase())) {
throw new Error(`log level must be one of ${ALLOWED}`);
} Prevention
- Map external level names (warning->warn, fatal->error) before passing the flag
- Only pass debug/info/warn/error to --log-level
- Pin flag values in deployment scripts
When it happens
Trigger: Running the toolbox with --log-level set to values like "trace", "verbose", "fatal", "warning", or "0".
Common situations: Migrating from other loggers that use "warning"/"fatal" levels, scripting with numeric levels, typos such as "infO " with whitespace.
Related errors
- log format must be one of "standard", or "json"
- --name is required unless --group or --toolset is set, or ex
- unable to initialize http log: %w
- HTTP error! status: ${response.status}
- no document found
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/47d4fa896d6b2903.
Report an issue: GitHub.