{"record":{"id":"a9138033a5ae1716","repo":"alibaba/open-code-review","slug":"invalid-format-value-q-must-be-text-or-json","errorCode":null,"errorMessage":"invalid --format value %q: must be 'text' or 'json'","messagePattern":"invalid --format value %q: must be 'text' or 'json'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/shared_flags.go","lineNumber":196,"sourceCode":"\t}\n\tif opts.maxTokens < 0 {\n\t\treturn fmt.Errorf(\"--max-tokens must be a non-negative integer (0 means use configured or template default)\")\n\t}\n\tif opts.preview && opts.resume != \"\" {\n\t\treturn fmt.Errorf(\"--preview and --resume cannot be used together\")\n\t}\n\tif opts.maxTokensBudget < 0 {\n\t\treturn fmt.Errorf(\"--max-tokens-budget must be a non-negative integer (0 means unlimited)\")\n\t}\n\treturn nil\n}\n\nfunc validateDelegateOptions(opts *delegateOptions) error {\n\tif err := validateDiffMode(opts.from, opts.to, opts.commit); err != nil {\n\t\treturn err\n\t}\n\tif opts.format != \"text\" && opts.format != \"json\" {\n\t\treturn fmt.Errorf(\"invalid --format value %q: must be 'text' or 'json'\", opts.format)\n\t}\n\treturn nil\n}\n\n// registerReviewFlags registers all review command flags on cmd, binding to opts.\nfunc registerReviewFlags(cmd *cobra.Command, opts *reviewOptions) {\n\taddToolsFlag(cmd, &opts.toolConfigPath)\n\taddRuleFlag(cmd, &opts.rulePath)\n\taddRepoFlag(cmd, &opts.repoDir)\n\taddDiffFlags(cmd, &opts.from, &opts.to, &opts.commit)\n\tcmd.Flags().StringVar(&opts.resume, \"resume\", \"\", \"resume from a previous review session id\")\n\tcmd.RegisterFlagCompletionFunc(\"resume\", completeSessionIDs)\n\taddExcludeFlag(cmd, &opts.excludes)\n\taddOutputFlags(cmd, &opts.outputFormat, &opts.audience)\n\taddOutputPathFlag(cmd, &opts.outputPath)\n\taddConcurrencyFlags(cmd, &opts.concurrency, &opts.perFileTimeout, &opts.maxTools, &opts.maxGitProcs, &opts.maxTokens, &opts.maxTokensBudget)\n\taddBackgroundFlags(cmd, &opts.background, &opts.backgroundFile)\n\taddProviderFlag(cmd, &opts.provider)","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/shared_flags.go#L178-L214","documentation":"validateDelegateOptions in cmd/opencodereview/shared_flags.go validates the --format flag for the delegate command. Only 'text' and 'json' are accepted; any other value produces this error with the offending value quoted via %q. Validation happens after the diff-mode check and before any delegation work starts.","triggerScenarios":"Running `ocr delegate --format yaml`, `--format markdown`, `--format JSON` (case-sensitive, so uppercase fails), or an empty --format value.","commonSituations":"Copying format names from other CLIs that accept yaml/markdown; shell variables defaulting to something other than text/json; assuming case-insensitive parsing.","solutions":["Use --format text or --format json exactly (lowercase)","Omit --format if the default already suits you","Fix the variable in your wrapper script to be one of the two accepted values"],"exampleFix":"// before\nocr delegate --format JSON\n// after\nocr delegate --format json","handlingStrategy":"validation","validationCode":"case \"$FORMAT\" in text|json) ;; *) echo \"invalid --format: $FORMAT\" >&2; exit 2;; esac\nocr delegate --format \"$FORMAT\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Restrict variables holding --format to the literal set text|json","Remember values are case-sensitive lowercase","Whitelist formats in wrapper scripts instead of passing user input through"],"tags":["cli","flag-validation","format","enum"],"backgroundTag":"invalid-cli-flag-value","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}