{"record":{"id":"1464067b40fd38ae","repo":"alibaba/open-code-review","slug":"invalid-effort-q-must-be-one-of-s","errorCode":null,"errorMessage":"invalid effort %q: must be one of %s","messagePattern":"invalid effort %q: must be one of (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/config/template/effort.go","lineNumber":44,"sourceCode":"\treturn []string{string(EffortLow), string(EffortMedium), string(EffortHigh)}\n}\n\n// EffortPreset is the concrete knob set an Effort level expands to.\ntype EffortPreset struct {\n\tMaxReviewRounds int\n}\n\nvar effortPresets = map[Effort]EffortPreset{\n\tEffortLow:    {MaxReviewRounds: 1},\n\tEffortMedium: {MaxReviewRounds: 2},\n\tEffortHigh:   {MaxReviewRounds: 3},\n}\n\n// ParseEffort validates a user-supplied effort value.\nfunc ParseEffort(s string) (Effort, error) {\n\te := Effort(strings.ToLower(s))\n\tif _, ok := effortPresets[e]; !ok {\n\t\treturn \"\", fmt.Errorf(\"invalid effort %q: must be one of %s\", s, strings.Join(EffortNames(), \", \"))\n\t}\n\treturn e, nil\n}\n\n// Preset returns the knob set for e.\nfunc (e Effort) Preset() EffortPreset {\n\tif p, ok := effortPresets[e]; ok {\n\t\treturn p\n\t}\n\treturn effortPresets[EffortDefault]\n}\n\n// ApplyEffort overwrites the effort-controlled template scalars.\nfunc (t *Template) ApplyEffort(e Effort) {\n\tp := e.Preset()\n\tt.MaxReviewRounds = p.MaxReviewRounds\n}\n","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/internal/config/template/effort.go#L26-L62","documentation":"ParseEffort validates the user-supplied effort level against the known presets (case-insensitively, via strings.ToLower). If the value is not one of the EffortNames() list, this error is returned describing the allowed values. Effort selects the review depth preset.","triggerScenarios":"setConfigValue, resolveEffort, or validateReviewOptions receives an effort string such as \"high\", \"extreme\", \"\", or \" maximum\" (leading space) that is not in effortPresets.","commonSituations":"Typo in --effort flag (e.g. `higth`); an old effort name removed/renamed in a newer ocr version; a config file key set to a value copied from different tooling; whitespace around the value in YAML/JSON config.","solutions":["Use one of the exact accepted names printed in the error (strings.Join(EffortNames(), \", \")) — e.g. `ocr review --effort max`","Trim whitespace and check case is irrelevant (ToLower is applied, so case is fine but spaces are not)","Upgrade/downgrade awareness: check `ocr --help` for the effort values supported by your installed version","Grep internal/config/template/effort.go for effortPresets to see the authoritative list"],"exampleFix":"// before\nocr review --effort extreme\n// after\nocr review --effort max","handlingStrategy":"validation","validationCode":"import \"strings\"\nvar validEfforts = map[string]bool{\"low\": true, \"medium\": true, \"high\": true} // match EffortNames()\nfunc validEffort(s string) bool { return validEfforts[strings.ToLower(strings.TrimSpace(s))] }","typeGuard":null,"tryCatchPattern":"eff, err := template.ParseEffort(flagValue)\nif err != nil {\n    var inv *template.EffortError // or check message prefix \"invalid effort\"\n    fmt.Fprintf(os.Stderr, \"usage: ocr review --effort <%s>\\n\", strings.Join(template.EffortNames(), \"|\"))\n    os.Exit(2)\n}","preventionTips":["Copy effort values from `ocr review --help`, not from memory","Trim and avoid whitespace in config values for effort","When upgrading ocr, diff the EffortNames list for renames","Use shell completion or a wrapper script that restricts effort to known values"],"tags":["go","config","validation","cli-flags"],"backgroundTag":"invalid-enum-value","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}