alibaba/open-code-review · error
invalid --audience value %q: must be 'human' or 'agent'
Error message
invalid --audience value %q: must be 'human' or 'agent'
What it means
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.
Source
Thrown at cmd/opencodereview/shared_flags.go:110
}
if modeCount > 1 {
return fmt.Errorf("only one review mode allowed (--from/--to or --commit)")
}
if from != "" && to == "" {
return fmt.Errorf("--to is required when --from is specified")
}
if to != "" && from == "" {
return fmt.Errorf("--from is required when --to is specified")
}
return nil
}
func validateAudience(audience string) error {
switch audience {
case "human", "agent":
return nil
default:
return fmt.Errorf("invalid --audience value %q: must be 'human' or 'agent'", audience)
}
}
func validateOutputFormat(format string) (string, error) {
normalized := strings.ToLower(strings.TrimSpace(format))
switch normalized {
case "text", "json", "sarif":
return normalized, nil
default:
return "", fmt.Errorf("invalid --format value %q: must be 'text', 'json', or 'sarif'", format)
}
}
func validateReviewOptions(opts *reviewOptions) error {
if err := validateDiffMode(opts.from, opts.to, opts.commit); err != nil {
return err
}
if opts.preview && opts.resume != "" {View on GitHub (pinned to 5cf97d0d15)
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
Example fix
// before ocr review --from main --to HEAD --audience Agent // after ocr review --from main --to HEAD --audience agent
Defensive patterns
Strategy: validation
Validate before calling
case "$AUDIENCE" in human|agent) ;; *) echo "invalid audience: $AUDIENCE"; exit 2;; esac
Type guard
function isAudience(v) { return v === 'human' || v === 'agent'; } Try / catch
out=$(ocr review --audience "$AUDIENCE" 2>&1) || { echo "$out" | grep -q 'invalid --audience' && AUDIENCE=human && ocr review --audience "$AUDIENCE"; } Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- only one review mode allowed (--from/--to or --commit)
- --to is required when --from is specified
- --from is required when --to is specified
- invalid --format value %q: must be 'text', 'json', or 'sarif
- --preview and --resume cannot be used together
AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02).
Data as JSON: /api/errors/a3290e862faae885.
Report an issue: GitHub.