{"record":{"id":"bd69ddb373fb536f","repo":"alibaba/open-code-review","slug":"invalid-env-entry-q-must-be-in-key-value-format","errorCode":null,"errorMessage":"invalid env entry %q: must be in KEY=VALUE format","messagePattern":"invalid env entry %q: must be in KEY=VALUE format","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/config_cmd.go","lineNumber":881,"sourceCode":"\t\tif value == \"\" {\n\t\t\treturn fmt.Errorf(\"MCP server command cannot be empty\")\n\t\t}\n\t\tentry.Command = value\n\tcase \"args\":\n\t\tvar args []string\n\t\tif err := json.Unmarshal([]byte(value), &args); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid JSON array for %s: %w\", key, err)\n\t\t}\n\t\tentry.Args = args\n\tcase \"env\":\n\t\tvar env []string\n\t\tif err := json.Unmarshal([]byte(value), &env); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid JSON array for %s: %w\", key, err)\n\t\t}\n\t\tfor _, e := range env {\n\t\t\tidx := strings.Index(e, \"=\")\n\t\t\tif idx <= 0 {\n\t\t\t\treturn fmt.Errorf(\"invalid env entry %q: must be in KEY=VALUE format\", e)\n\t\t\t}\n\t\t}\n\t\tentry.Env = env\n\tcase \"url\":\n\t\tif value == \"\" {\n\t\t\treturn fmt.Errorf(\"MCP server URL cannot be empty\")\n\t\t}\n\t\tparsed, err := url.Parse(value)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid MCP server URL %q: %w\", value, err)\n\t\t}\n\t\tif parsed.Scheme != \"http\" && parsed.Scheme != \"https\" {\n\t\t\treturn fmt.Errorf(\"MCP server URL must use http or https scheme, got %q\", parsed.Scheme)\n\t\t}\n\t\tif parsed.Host == \"\" {\n\t\t\treturn fmt.Errorf(\"MCP server URL %q must include a host\", value)\n\t\t}\n\t\tentry.URL = value","sourceCodeStart":863,"sourceCodeEnd":899,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/config_cmd.go#L863-L899","documentation":"Raised after the env JSON array parses: each element must be a KEY=VALUE string. An entry with no '=' (idx <= 0 also rejects empty key, i.e. '=VALUE') cannot be turned into an environment variable for the MCP server subprocess, so the setter fails with the offending entry quoted.","triggerScenarios":"Calling setMCPServerValue with field \"env\" where any array element lacks '=', e.g. '[\"DEBUG\"]', '[\"=1\"]', or '[\"\"]'.","commonSituations":"Listing variable names only (expecting the tool to read them from the parent environment), typos dropping the '=', or an empty string left in the array from copy-paste.","solutions":["Write each entry as KEY=VALUE, e.g. '[\"DEBUG=1\"]'","To pass through an existing variable, read it in the shell first: '[\"TOKEN='$TOKEN'\"]'","Remove empty or name-only entries from the array"],"exampleFix":"// before\nocr config set mcp_servers.fs.env '[\"DEBUG\"]'\n// after\nocr config set mcp_servers.fs.env '[\"DEBUG=1\"]'","handlingStrategy":"validation","validationCode":"for _, e := range entries {\n\tif i := strings.Index(e, \"=\"); i <= 0 {\n\t\treturn fmt.Errorf(\"entry %q must be KEY=VALUE\", e)\n\t}\n}","typeGuard":"func isValidEnvEntry(e string) bool {\n\treturn strings.Index(e, \"=\") > 0\n}","tryCatchPattern":"if err := setMCPServerValue(cfg, key, value); err != nil {\n\tfmt.Fprintf(os.Stderr, \"config set failed: %v\\n\", err)\n\tos.Exit(1)\n}","preventionTips":["Include '=' in every entry, with a non-empty key before it","Expand existing variables in the shell before building the array","Trim the array of empty strings from copy-paste"],"tags":["config","mcp","env","validation"],"backgroundTag":"invalid-env-format","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}