{"record":{"id":"a3290e862faae885","repo":"alibaba/open-code-review","slug":"invalid-audience-value-q-must-be-human-or-a","errorCode":null,"errorMessage":"invalid --audience value %q: must be 'human' or 'agent'","messagePattern":"invalid --audience value %q: must be 'human' or 'agent'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/shared_flags.go","lineNumber":110,"sourceCode":"\t}\n\tif modeCount > 1 {\n\t\treturn fmt.Errorf(\"only one review mode allowed (--from/--to or --commit)\")\n\t}\n\tif from != \"\" && to == \"\" {\n\t\treturn fmt.Errorf(\"--to is required when --from is specified\")\n\t}\n\tif to != \"\" && from == \"\" {\n\t\treturn fmt.Errorf(\"--from is required when --to is specified\")\n\t}\n\treturn nil\n}\n\nfunc validateAudience(audience string) error {\n\tswitch audience {\n\tcase \"human\", \"agent\":\n\t\treturn nil\n\tdefault:\n\t\treturn fmt.Errorf(\"invalid --audience value %q: must be 'human' or 'agent'\", audience)\n\t}\n}\n\nfunc validateOutputFormat(format string) (string, error) {\n\tnormalized := strings.ToLower(strings.TrimSpace(format))\n\tswitch normalized {\n\tcase \"text\", \"json\", \"sarif\":\n\t\treturn normalized, nil\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"invalid --format value %q: must be 'text', 'json', or 'sarif'\", format)\n\t}\n}\n\nfunc validateReviewOptions(opts *reviewOptions) error {\n\tif err := validateDiffMode(opts.from, opts.to, opts.commit); err != nil {\n\t\treturn err\n\t}\n\tif opts.preview && opts.resume != \"\" {","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/shared_flags.go#L92-L128","documentation":"validateAudience whitelists exactly 'human' or 'agent'. Any other --audience value (wrong case, typo, empty string if not defaulted elsewhere) is rejected with this error naming the offending value and the allowed set.","triggerScenarios":"Passing --audience Human, --audience ai, --audience llm, or any string other than the exact lowercase literals 'human'/'agent' to review or scan (via validateReviewOptions / validateScanOptions).","commonSituations":"Case-sensitivity mistakes (Human vs human); reusing vocabulary from other tools (reviewer/ai/bot); scripts interpolating an unset AUDIENCE variable producing an empty or bogus value.","solutions":["Use exactly --audience human or --audience agent (lowercase)","Fix the typo / casing in your script or alias","Guard interpolated values: ensure AUDIENCE is one of human|agent before invoking","Omit --audience if the default suits you"],"exampleFix":"// before\nocr review --from main --to HEAD --audience Agent\n// after\nocr review --from main --to HEAD --audience agent","handlingStrategy":"validation","validationCode":"case \"$AUDIENCE\" in human|agent) ;; *) echo \"invalid audience: $AUDIENCE\"; exit 2;; esac","typeGuard":"function isAudience(v) { return v === 'human' || v === 'agent'; }","tryCatchPattern":"out=$(ocr review --audience \"$AUDIENCE\" 2>&1) || { echo \"$out\" | grep -q 'invalid --audience' && AUDIENCE=human && ocr review --audience \"$AUDIENCE\"; }","preventionTips":["Use only the exact lowercase literals human and agent","Validate interpolated env vars before passing them as flags","Keep the allowed values in a shell case statement in wrappers","Check --help when unsure; values are case-sensitive"],"tags":["cli","flags","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}