{"record":{"id":"5419da43c0133a11","repo":"thanos-io/thanos","slug":"the-format-of-level-is-invalid-expected-info-debu","errorCode":null,"errorMessage":"the format of level is invalid. Expected INFO/DEBUG/ERROR/WARNING, got this %v","messagePattern":"the format of level is invalid\\. Expected INFO/DEBUG/ERROR/WARNING, got this (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/logging/grpc.go","lineNumber":99,"sourceCode":"\tif !logStart && logEnd {\n\t\treturn grpc_logging.WithLogOnEvents(grpc_logging.FinishCall), nil\n\t}\n\tif logStart && logEnd {\n\t\treturn grpc_logging.WithLogOnEvents(grpc_logging.StartCall, grpc_logging.FinishCall), nil\n\t}\n\treturn nil, fmt.Errorf(\"log decision combination is not supported\")\n}\n\n// validateLevel validates the list of level entries.\n// Raise an error if empty or log level not in uppercase.\nfunc validateLevel(level string) error {\n\tif level == \"\" {\n\t\treturn fmt.Errorf(\"level field in YAML file is empty\")\n\t}\n\tif level == \"INFO\" || level == \"DEBUG\" || level == \"ERROR\" || level == \"WARNING\" {\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"the format of level is invalid. Expected INFO/DEBUG/ERROR/WARNING, got this %v\", level)\n}\n\nfunc InterceptorLogger(l log.Logger) grpc_logging.Logger {\n\treturn grpc_logging.LoggerFunc(func(_ context.Context, lvl grpc_logging.Level, msg string, fields ...any) {\n\t\tlargs := append([]any{\"msg\", msg}, fields...)\n\t\tswitch lvl {\n\t\tcase grpc_logging.LevelDebug:\n\t\t\t_ = level.Debug(l).Log(largs...)\n\t\tcase grpc_logging.LevelInfo:\n\t\t\t_ = level.Info(l).Log(largs...)\n\t\tcase grpc_logging.LevelWarn:\n\t\t\t_ = level.Warn(l).Log(largs...)\n\t\tcase grpc_logging.LevelError:\n\t\t\t_ = level.Error(l).Log(largs...)\n\t\tdefault:\n\t\t\tpanic(fmt.Sprintf(\"unknown level %v\", lvl))\n\t\t}\n\t})","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/logging/grpc.go#L81-L117","documentation":"validateLevel only accepts the exact uppercase strings INFO, DEBUG, ERROR, or WARNING. Any other non-empty value (including lowercase or unsupported levels like TRACE) fails with this formatted error that echoes the invalid value.","triggerScenarios":"Calling NewGRPCOption or NewHTTPOption with level values like 'info', 'debug', 'WARN', 'trace', or any typo in the logging YAML config.","commonSituations":"Users writing lowercase levels as in other frameworks; copy-pasting TRACE (unsupported here); mixed-case values from environment substitution.","solutions":["Change the level to one of INFO, DEBUG, ERROR, WARNING (uppercase, exact).","Uppercase/normalize the value in config management before rendering the YAML.","Add a pre-check rejecting values outside the allowed set."],"exampleFix":"// before\nlevel: info\n// after\nlevel: INFO","handlingStrategy":"validation","validationCode":"var validLevels = map[string]bool{\"INFO\": true, \"DEBUG\": true, \"ERROR\": true, \"WARNING\": true}\nif !validLevels[level] { return fmt.Errorf(\"level %q not one of INFO/DEBUG/ERROR/WARNING\", level) }","typeGuard":null,"tryCatchPattern":"if _, err := logging.NewGRPCOption(cfg); err != nil {\n  return fmt.Errorf(\"log level invalid: %w\", err)\n}","preventionTips":["Uppercase levels in config templates before rendering","Normalize (strings.ToUpper) then validate against the allowed set","Document the exact allowed level strings for users"],"tags":["logging","config-validation","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}