{"record":{"id":"47d4fa896d6b2903","repo":"googleapis/mcp-toolbox","slug":"log-level-must-be-one-of-debug-info-warn","errorCode":null,"errorMessage":"log level must be one of \"debug\", \"info\", \"warn\", or \"error\"","messagePattern":"log level must be one of \"debug\", \"info\", \"warn\", or \"error\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/server/config.go","lineNumber":153,"sourceCode":"\ntype StringLevel string\n\n// String is used by both fmt.Print and by Cobra in help text\nfunc (s *StringLevel) String() string {\n\tif string(*s) != \"\" {\n\t\treturn strings.ToLower(string(*s))\n\t}\n\treturn \"info\"\n}\n\n// validate log level flag\nfunc (s *StringLevel) Set(v string) error {\n\tswitch strings.ToLower(v) {\n\tcase \"debug\", \"info\", \"warn\", \"error\":\n\t\t*s = StringLevel(v)\n\t\treturn nil\n\tdefault:\n\t\treturn fmt.Errorf(`log level must be one of \"debug\", \"info\", \"warn\", or \"error\"`)\n\t}\n}\n\n// Type is used in Cobra help text\nfunc (s *StringLevel) Type() string {\n\treturn \"stringLevel\"\n}\n\ntype SourceConfigs map[string]sources.SourceConfig\ntype AuthServiceConfigs map[string]auth.AuthServiceConfig\ntype EmbeddingModelConfigs map[string]embeddingmodels.EmbeddingModelConfig\ntype ToolConfigs map[string]tools.ToolConfig\ntype PromptConfigs map[string]prompts.PromptConfig\ntype GroupConfigs map[string]group.GroupConfig\n\nfunc UnmarshalPrimitiveConfig(ctx context.Context, raw []byte) (SourceConfigs, AuthServiceConfigs, EmbeddingModelConfigs, ToolConfigs, PromptConfigs, GroupConfigs, error) {\n\t// prepare configs map\n\tvar sourceConfigs SourceConfigs","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/server/config.go#L135-L171","documentation":"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.","triggerScenarios":"Running the toolbox with --log-level set to values like \"trace\", \"verbose\", \"fatal\", \"warning\", or \"0\".","commonSituations":"Migrating from other loggers that use \"warning\"/\"fatal\" levels, scripting with numeric levels, typos such as \"infO \" with whitespace.","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"],"exampleFix":"// before\ntoolbox --log-level warning\n// after\ntoolbox --log-level warn","handlingStrategy":"validation","validationCode":"const ALLOWED = ['debug', 'info', 'warn', 'error'];\nif (!ALLOWED.includes(logLevel.toLowerCase())) {\n  throw new Error(`log level must be one of ${ALLOWED}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["cli","flags","logging","validation"],"backgroundTag":"invalid-cli-flag-value","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}