{"record":{"id":"69094c97b7579a99","repo":"multica-ai/multica","slug":"runtime-config-must-be-valid-json-w","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.go","lineNumber":660,"sourceCode":"\tif runtimeID == \"\" {\n\t\treturn fmt.Errorf(\"--runtime-id is required\")\n\t}\n\n\tbody := map[string]any{\n\t\t\"name\":       name,\n\t\t\"runtime_id\": runtimeID,\n\t}\n\tif v, _ := cmd.Flags().GetString(\"description\"); v != \"\" {\n\t\tbody[\"description\"] = v\n\t}\n\tif v, _ := cmd.Flags().GetString(\"instructions\"); v != \"\" {\n\t\tbody[\"instructions\"] = v\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\tif cmd.Flags().Changed(\"custom-args\") {\n\t\tv, _ := cmd.Flags().GetString(\"custom-args\")\n\t\tca, err := parseCustomArgs(v)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tbody[\"custom_args\"] = ca\n\t}\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","sourceCodeStart":642,"sourceCodeEnd":678,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_agent.go#L642-L678","documentation":"runAgentCreate parses the --runtime-config flag with json.Unmarshal into an `any` before embedding it in the request body; invalid JSON fails with the parse error wrapped. Only strings that decode as valid JSON are accepted (objects, arrays, or scalars all pass the type check).","triggerScenarios":"Passing --runtime-config with single-quoted keys, trailing commas, smart quotes from a pasted doc, or unquoted keys — any string Go's encoding/json rejects.","commonSituations":"Pasting config from JavaScript/Python examples that use single quotes; shell quoting that strips inner double quotes; hand-editing JSON in a YAML-accustomed editor allowing trailing commas.","solutions":["Validate the JSON before running: echo '<config>' | jq . — jq pinpoints the syntax error.","Use double quotes for keys and strings, remove trailing commas.","Fix shell quoting: pass the JSON in single quotes at the shell level so inner double quotes survive.","Store the config in a file and use a tool that expands it, or paste from `jq -c` output."],"exampleFix":"# before\nmultica agent create --name bot --runtime-id rt_cli \\\n  --runtime-config \"{model: 'gpt',}\"\n\n# after\nmultica agent create --name bot --runtime-id rt_cli \\\n  --runtime-config '{\"model\":\"gpt\"}'","handlingStrategy":"validation","validationCode":"var rc any\nif err := json.Unmarshal([]byte(runtimeConfigFlag), &rc); err != nil {\n    return fmt.Errorf(\"--runtime-config must be valid JSON: %w\", err)\n}","typeGuard":"func isValidJSON(s string) bool {\n    var v any\n    return json.Unmarshal([]byte(s), &v) == nil\n}","tryCatchPattern":"if cmd.Flags().Changed(\"runtime-config\") {\n    v, _ := cmd.Flags().GetString(\"runtime-config\")\n    if !isValidJSON(v) {\n        return fmt.Errorf(\"--runtime-config must be valid JSON (check quoting/commas): %s\", v)\n    }\n}","preventionTips":["Pipe configs through `jq -c .` to both validate and canonicalize before passing.","Wrap the JSON in single quotes at the shell level so inner double quotes survive.","Watch for trailing commas and single-quoted keys when pasting from Python/JS docs."],"tags":["go","cli","json","validation","agents"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}