{"record":{"id":"e25d51a30620da2d","repo":"alibaba/open-code-review","slug":"invalid-json-for-s-w","errorCode":null,"errorMessage":"invalid JSON for %s: %w","messagePattern":"invalid JSON for (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/config_cmd.go","lineNumber":656,"sourceCode":"\t\t}\n\tcase \"model\":\n\t\tentry.Model = value\n\tcase \"models\":\n\t\tmodels, err := parseModelListValue(value)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid model list for %s: %w\", key, err)\n\t\t}\n\t\tentry.Models = models\n\tcase \"auth_header\":\n\t\tnormalized, err := llm.NormalizeAuthHeader(value)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tentry.AuthHeader = normalized\n\tcase \"extra_body\":\n\t\tvar m map[string]any\n\t\tif err := json.Unmarshal([]byte(value), &m); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid JSON for %s: %w\", key, err)\n\t\t}\n\t\tentry.ExtraBody = m\n\tcase \"extra_headers\":\n\t\tparsed, err := llm.ParseExtraHeaders(value)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid extra headers for %s: %w\", key, err)\n\t\t}\n\t\tentry.ExtraHeaders = parsed\n\tcase \"retry_codes\":\n\t\tcodes, warnings, err := llm.ParseRetryCodes(value)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid retry codes for %s: %w\", key, err)\n\t\t}\n\t\tfor _, w := range warnings {\n\t\t\tfmt.Fprintf(os.Stderr, \"[ocr] WARNING: %s\\n\", w)\n\t\t}\n\t\tentry.RetryCodes = codes\n\tcase \"aws_region\", \"aws_profile\":","sourceCodeStart":638,"sourceCodeEnd":674,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/config_cmd.go#L638-L674","documentation":"This error is returned by applyProviderField when the value supplied for a provider's 'extra_body' field is not valid JSON. The tool attempts json.Unmarshal on the raw string and, on failure, wraps the underlying parse error so the developer sees both which field failed and why. It is a validation guard that keeps malformed JSON out of the stored ProviderEntry.ExtraBody.","triggerScenarios":"Running `ocr config set custom_providers.<name>.extra_body <value>` (or providers.<name>.extra_body) where <value> is not parseable JSON, e.g. unquoted keys, trailing commas, or a value with shell-mangled quotes like {\"temperature\":0.5 without closing braces.","commonSituations":"Pasting an extra-body JSON snippet into a shell without single-quoting it so the shell strips double quotes; hand-editing config and forgetting a comma; copy-pasting JSON5/YAML instead of strict JSON.","solutions":["Validate the JSON with `echo '<value>' | jq .` (or python -m json.tool) before setting it","Single-quote the value in the shell so inner double quotes survive: ocr config set custom_providers.myprovider.extra_body '{\"temperature\":0.5}'","Re-run the config set command with corrected JSON"],"exampleFix":"// before\nocr config set custom_providers.foo.extra_body {\"temperature\":0.5,}\n// after\nocr config set custom_providers.foo.extra_body '{\"temperature\":0.5}'","handlingStrategy":"validation","validationCode":"value='{\"temperature\":0.5}'\necho \"$value\" | jq -e . >/dev/null && ocr config set custom_providers.foo.extra_body \"$value\" || echo \"invalid JSON\"","typeGuard":null,"tryCatchPattern":"if err := json.Unmarshal([]byte(value), &m); err != nil {\n    return fmt.Errorf(\"invalid JSON for extra_body: %w\", err)\n}","preventionTips":["Single-quote JSON values in the shell to protect double quotes","Validate with jq/python before running the config set command","Never paste JSON5 or YAML into extra_body — strict JSON only"],"tags":["cli","config","json-validation"],"backgroundTag":"invalid-json-config","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}