{"record":{"id":"0d2ff688c81bb0d8","repo":"istio/istio","slug":"invalid-level-option","errorCode":null,"errorMessage":"invalid level option","messagePattern":"invalid level option","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"istioctl/pkg/util/formatting/msg_threshold.go","lineNumber":45,"sourceCode":"\tdiag.Level\n}\n\n// String is a function declared in the pflag.Value interface\nfunc (m *MessageThreshold) String() string {\n\treturn m.Level.String()\n}\n\n// Type is a function declared in the pflag.Value interface\nfunc (m *MessageThreshold) Type() string {\n\treturn \"Level\"\n}\n\n// Set is a function declared in the pflag.Value interface\nfunc (m *MessageThreshold) Set(s string) error {\n\tlevelMap := diag.GetUppercaseStringToLevelMap()\n\tlevel, ok := levelMap[strings.ToUpper(s)]\n\tif !ok {\n\t\treturn errors.New(\"invalid level option\")\n\t}\n\tm.Level = level\n\treturn nil\n}\n","sourceCodeStart":27,"sourceCodeEnd":50,"githubUrl":"https://github.com/istio/istio/blob/8dc789c5cf17517c64e3c36cb3288230f149dfae/istioctl/pkg/util/formatting/msg_threshold.go#L27-L50","documentation":"MessageThreshold implements pflag.Value for istioctl's --threshold/-l log-level flags. Set uppercases the input and looks it up in diag.GetUppercaseStringToLevelMap() (e.g. ERROR, WARNING, INFO); unknown strings return 'invalid level option'. This is strict CLI argument parsing before any command runs.","triggerScenarios":"Passing a level string not in the map, e.g. `istioctl analyze -l verbose`, `-l err`, `-l fatal` (if unsupported), or locale variants like 'Warn' spelled differently; anything except the documented level names.","commonSituations":"Muscle memory from other tools (logrus/zap levels like 'fatal', 'debug'); scripting with dynamically built flag values that are empty or misspelled; version differences in accepted level names.","solutions":["Use one of the valid values printed in the flag usage / diag.GetAllLevelStrings() — typically ERROR, WARNING, INFO","Check for trailing whitespace/typos in scripted flag values","Run the command with -h to see the accepted list for your istioctl version"],"exampleFix":"# before\nistioctl precheck -l verbose\n\n# after\nistioctl precheck -l WARNING","handlingStrategy":"validation","validationCode":"valid := map[string]bool{\"ERROR\": true, \"WARNING\": true, \"INFO\": true}\nlevel := strings.ToUpper(strings.TrimSpace(input))\nif !valid[level] {\n    return fmt.Errorf(\"invalid level %q; valid: ERROR, WARNING, INFO\", input)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Read accepted levels with istioctl <cmd> -h before scripting","Uppercase and trim level strings in wrappers","Avoid porting level vocabularies (debug/fatal) from other logging tools"],"tags":["istioctl","cli","log-level","flag-parsing","validation"],"backgroundTag":null,"analyzedSha":"8dc789c5cf17517c64e3c36cb3288230f149dfae","analyzedAt":"2026-08-15T15:16:55.434Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}