{"record":{"id":"c81997662a4fcc2f","repo":"multica-ai/multica","slug":"runtime-config-must-be-valid-json-w-c81997","errorCode":null,"errorMessage":"--runtime-config must be valid JSON: %w","messagePattern":"--runtime-config must be valid JSON: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_agent_copy.go","lineNumber":273,"sourceCode":"\n\t// Secret / machine-local fields are never copied from the source (they are\n\t// redacted or masked on GET). Set them only when supplied explicitly, via\n\t// the same secret-safe channels as 'agent create'.\n\tif ce, ok, err := resolveCustomEnv(cmd); err != nil {\n\t\treturn err\n\t} else if ok {\n\t\tbody[\"custom_env\"] = ce\n\t}\n\tif mc, ok, err := resolveMcpConfig(cmd); err != nil {\n\t\treturn err\n\t} else if ok {\n\t\tbody[\"mcp_config\"] = mc\n\t}\n\tif cmd.Flags().Changed(\"runtime-config\") {\n\t\tv, _ := cmd.Flags().GetString(\"runtime-config\")\n\t\tvar rc any\n\t\tif err := json.Unmarshal([]byte(v), &rc); err != nil {\n\t\t\treturn fmt.Errorf(\"--runtime-config must be valid JSON: %w\", err)\n\t\t}\n\t\tbody[\"runtime_config\"] = rc\n\t}\n\n\tvar result map[string]any\n\tif err := client.PostJSON(ctx, \"/api/agents\", body, &result); err != nil {\n\t\treturn fmt.Errorf(\"copy agent: %w\", err)\n\t}\n\n\toutput, _ := cmd.Flags().GetString(\"output\")\n\tif output == \"json\" {\n\t\treturn cli.PrintJSON(os.Stdout, result)\n\t}\n\n\tfmt.Printf(\"Agent copied: %s (%s)\\n\", strVal(result, \"name\"), strVal(result, \"id\"))\n\treturn nil\n}\n","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_agent_copy.go#L255-L291","documentation":"Thrown by `multica agent copy` when --runtime-config is supplied but its string value fails json.Unmarshal. Unlike --mcp-config, this flag takes inline JSON only and accepts any JSON type, so the failure is always a syntax error (truncated payload, stray quotes, trailing commas), not a shape error.","triggerScenarios":"`multica agent copy <id> --runtime-config '{temperature: 0.7}'` (unquoted key); shell mangling that strips or adds quotes; a value truncated by terminal copy-paste; trailing comma JSON.","commonSituations":"Single-vs-double quoting mistakes when embedding JSON in shell commands; values built by string concatenation that drop a brace; pasting from rendered docs where smart quotes replaced ASCII quotes.","solutions":["Validate the JSON before running: echo '<value>' | jq . must parse","Quote the whole payload in single quotes and use only double quotes inside","For large configs, write them to a file and paste its contents, or check for truncation"],"exampleFix":"# before\nmultica agent copy <id> --runtime-config '{temperature: 0.7}'\n# after\nmultica agent copy <id> --runtime-config '{\"temperature\": 0.7}'","handlingStrategy":"validation","validationCode":"echo \"$RUNTIME_CONFIG\" | jq -e . >/dev/null || { echo \"runtime-config is not valid JSON\" >&2; exit 1; }\nmultica agent copy \"$AGENT_ID\" --runtime-config \"$RUNTIME_CONFIG\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Single-quote the outer shell string, double-quote JSON keys inside","Always round-trip JSON through jq before handing it to a CLI","Build nested values with jq -n instead of string concatenation"],"tags":["cli","json","validation","shell","go"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}