{"record":{"id":"9773d0084a10b6c8","repo":"CoplayDev/unity-mcp","slug":"openclaw-config-contains-non-json-content-and-cann","errorCode":null,"errorMessage":"OpenClaw config contains non-JSON content and cannot be safely auto-edited: {ex.Message}","messagePattern":"OpenClaw config contains non-JSON content and cannot be safely auto-edited: (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"MCPForUnity/Editor/Clients/Configurators/OpenClawConfigurator.cs","lineNumber":183,"sourceCode":"            \"OpenClaw exposes a proxy tool such as unityMCP__call for Unity MCP access\",\n            \"Restart OpenClaw if the plugin does not hot-reload the new config\"\n        };\n\n        private JObject LoadConfig(string path)\n        {\n            string text = File.ReadAllText(path);\n            if (string.IsNullOrWhiteSpace(text))\n            {\n                return new JObject();\n            }\n\n            try\n            {\n                return JsonConvert.DeserializeObject<JObject>(text) ?? new JObject();\n            }\n            catch (JsonException ex)\n            {\n                throw new InvalidOperationException(\n                    $\"OpenClaw config contains non-JSON content and cannot be safely auto-edited: {ex.Message}\");\n            }\n        }\n\n        private JObject FindUnityServer(JToken serversToken)\n        {\n            if (serversToken is JObject serverMap)\n            {\n                return serverMap[ServerName] as JObject;\n            }\n\n            if (serversToken is JArray legacyServers)\n            {\n                foreach (JToken token in legacyServers)\n                {\n                    JObject server = token as JObject;\n                    if (server == null)\n                    {","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/MCPForUnity/Editor/Clients/Configurators/OpenClawConfigurator.cs#L165-L201","documentation":"OpenClawConfigurator.LoadConfig() reads ~/.openclaw/openclaw.json and attempts JsonConvert.DeserializeObject<JObject>. If the file content fails JSON parsing (JsonException), the method throws InvalidOperationException rather than silently overwriting the user's file. This is a deliberate data-safety guard: auto-editing a corrupt or non-JSON file could destroy the user's entire OpenClaw configuration.","triggerScenarios":"CheckStatus() or Configure() is called when ~/.openclaw/openclaw.json exists but contains syntax errors, truncated content, TOML/INI/YAML instead of JSON, or text from a failed manual edit.","commonSituations":"The user hand-edited openclaw.json and left a trailing comma or missing brace. The file was partially written by a crashed process. The user pasted a snippet in the wrong format. Another tool overwrote the file with non-JSON content.","solutions":["Open ~/.openclaw/openclaw.json in a text editor and validate it with a JSON linter; fix the syntax error, then click Configure again.","If the file is unrecoverable, back it up, delete it, and let MCP for Unity create a fresh config via Configure().","Run the JSON through `python -m json.tool ~/.openclaw/openclaw.json` to locate the exact parse error position."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"string text = File.ReadAllText(path);\ntry { JToken.Parse(text); }\ncatch (JsonException) { /* do not auto-edit; prompt user to fix manually */ }","typeGuard":null,"tryCatchPattern":"try { configurator.Configure(); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"non-JSON content\"))\n{ ShowUserError(\"OpenClaw config is corrupt. Fix or delete ~/.openclaw/openclaw.json manually.\"); }","preventionTips":["Validate JSON with a linter before letting the configurator auto-edit.","Back up config files before bulk configure operations.","Avoid manual edits to openclaw.json while MCP for Unity is running."],"tags":["configuration","openclaw","json","data-integrity","file-io"],"backgroundTag":null,"analyzedSha":"c21bf496bca87d54e75bad048563c3adb1782081","analyzedAt":"2026-08-13T17:36:56.095Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}