{"record":{"id":"78b69bad710b96cf","repo":"CoplayDev/unity-mcp","slug":"failed-to-unregister-ex-message","errorCode":null,"errorMessage":"Failed to unregister: {ex.Message}","messagePattern":"Failed to unregister: (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs","lineNumber":413,"sourceCode":"                }\n                else\n                {\n                    string containerKey = string.IsNullOrEmpty(client.ServerContainerKey)\n                        ? \"mcpServers\" : client.ServerContainerKey;\n                    if ((root[containerKey] as JObject)?.Remove(\"unityMCP\") == true) removed = true;\n                }\n\n                if (removed)\n                {\n                    File.WriteAllText(path, root.ToString(Formatting.Indented));\n                }\n\n                client.SetStatus(McpStatus.NotConfigured);\n                client.configuredTransport = Models.ConfiguredTransport.Unknown;\n            }\n            catch (Exception ex)\n            {\n                throw new InvalidOperationException($\"Failed to unregister: {ex.Message}\", ex);\n            }\n        }\n\n        public override string GetManualSnippet()\n        {\n            try\n            {\n                string uvx = GetUvxPathOrError();\n                return ConfigJsonBuilder.BuildManualConfigJson(uvx, client);\n            }\n            catch (Exception ex)\n            {\n                var errorObj = new { error = ex.Message };\n                return JsonConvert.SerializeObject(errorObj);\n            }\n        }\n\n        public override IList<string> GetInstallationSteps() => new List<string> { \"Configuration steps not available for this client.\" };","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs#L395-L431","documentation":"JsonFileMcpConfigurator.Unregister() parses the client config file, removes the unityMCP key from its container (mcpServers/servers/mcp), and writes it back. Any exception during this read-parse-remove-write cycle is caught and re-thrown as InvalidOperationException with a 'Failed to unregister:' prefix. The original exception is preserved as InnerException.","triggerScenarios":"File IO errors (permissions, disk full, file locked by another process), JSON parse errors on a corrupt config file, or an unexpected null during JObject traversal.","commonSituations":"The config file is open in another editor that locks it. The user has a malformed config file from a manual edit. Antivirus or sync software (Dropbox, OneDrive) is temporarily locking the file. Disk full or read-only filesystem.","solutions":["Read the InnerException.Message for the underlying cause (IO, parse, or null-ref).","Close any editor that has the config file open, then retry Unregister.","Validate the config file JSON with a linter and fix syntax errors.","Check filesystem permissions on the config directory and file.","If the file is corrupt beyond repair, back it up, delete it, and re-Configure."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"string path = GetConfigPath();\nif (!File.Exists(path)) { /* nothing to unregister */ return; }\nstring text = File.ReadAllText(path);\nJToken.Parse(text); // validate parse before Unregister","typeGuard":null,"tryCatchPattern":"try { configurator.Unregister(); }\ncatch (InvalidOperationException ex)\n{ Debug.LogError($\"Unregister failed: {ex.Message}. Inner: {ex.InnerException?.Message}\"); }","preventionTips":["Close config files in other editors before unregistering.","Validate JSON before triggering unregister operations.","Check the InnerException for the root cause of IO or parse failures."],"tags":["configuration","json-config","unregister","file-io","shared"],"backgroundTag":null,"analyzedSha":"c21bf496bca87d54e75bad048563c3adb1782081","analyzedAt":"2026-08-13T17:36:56.095Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}