{"record":{"id":"96abedca4f1f76ac","repo":"thanos-io/thanos","slug":"level-field-in-yaml-file-is-empty","errorCode":null,"errorMessage":"level field in YAML file is empty","messagePattern":"level field in YAML file is empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/logging/grpc.go","lineNumber":94,"sourceCode":"// getGRPCLoggingOption returns the logging ENUM based on logStart and logEnd values.\nfunc getGRPCLoggingOption(logStart, logEnd bool) (grpc_logging.Option, error) {\n\tif !logStart && !logEnd {\n\t\treturn grpc_logging.WithLogOnEvents(), nil\n\t}\n\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:","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/logging/grpc.go#L76-L112","documentation":"validateLevel checks the 'level' string from the logging YAML config. An empty string means the level field was not provided at all, so validation fails with this error before the value is checked against allowed levels.","triggerScenarios":"Calling NewGRPCOption or NewHTTPOption with a config whose level entry is empty — e.g. 'level: \"\"' or a level list containing an empty element.","commonSituations":"YAML key present with no value; templating that substituted an empty string; users commenting out the level value but keeping the key.","solutions":["Provide a valid level value: INFO, DEBUG, ERROR, or WARNING.","Remove the empty level entry if default logging behavior is desired.","Validate the YAML non-empty before passing to NewGRPCOption/NewHTTPOption."],"exampleFix":"// before\nlevel: \"\"\n// after\nlevel: INFO","handlingStrategy":"validation","validationCode":"if level == \"\" { return fmt.Errorf(\"logging level must be a non-empty string\") }","typeGuard":null,"tryCatchPattern":"if _, err := logging.NewHTTPOption(cfg); err != nil {\n  return fmt.Errorf(\"http logging config invalid: %w\", err)\n}","preventionTips":["Never leave the level key with an empty value in YAML","Fail fast on empty strings during config rendering","Use schema validation (e.g. jsonschema) on logging config"],"tags":["logging","config-validation","yaml"],"backgroundTag":"empty-required-field","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"}