{"record":{"id":"b141151325a545fe","repo":"CoplayDev/unity-mcp","slug":"failed-to-parse-properties-json-string-raw-valu","errorCode":null,"errorMessage":"Failed to parse 'properties' JSON string. Raw value: {token}","messagePattern":"Failed to parse 'properties' JSON string\\. Raw value: (.+?)","errorType":"validation","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"MCPForUnity/Editor/Tools/Animation/ManageAnimation.cs","lineNumber":101,"sourceCode":"            if (token == null || token.Type == JTokenType.Null)\n            {\n                return null;\n            }\n\n            if (token is JObject obj)\n            {\n                return obj;\n            }\n\n            if (token.Type == JTokenType.String)\n            {\n                try\n                {\n                    return JToken.Parse(token.ToString()) as JObject;\n                }\n                catch (JsonException ex)\n                {\n                    throw new JsonException(\n                        $\"Failed to parse 'properties' JSON string. Raw value: {token}\",\n                        ex);\n                }\n            }\n\n            return null;\n        }\n\n        private static string NormalizeKey(string key, bool allowAliases)\n        {\n            if (string.IsNullOrEmpty(key))\n            {\n                return key;\n            }\n            if (string.Equals(key, \"action\", StringComparison.OrdinalIgnoreCase))\n            {\n                return \"action\";\n            }","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/MCPForUnity/Editor/Tools/Animation/ManageAnimation.cs#L83-L119","documentation":"ExtractProperties accepts the 'properties' field either as a JSON object or as a JSON-encoded string. When it is a string, JToken.Parse is attempted; if the string is not valid JSON a JsonException is thrown embedding the raw value.","triggerScenarios":"An AI assistant or caller sends 'properties' as a plain delimited string ('scale,rotation'), malformed JSON ('{scale: 1}' in some strict parsers), or a truncated JSON fragment; double-encoding produced a non-JSON string.","commonSituations":"LLM formats the field as CSV instead of JSON; a serialization layer double-encoded the object; manual payload construction with a syntax error.","solutions":["Pass 'properties' as a JSON object directly, not as a string.","If it must be a string, ensure it is valid JSON (quoted keys, proper braces).","Validate the payload with a JSON parser before sending."],"exampleFix":"// before\n{ \"action\": \"set\", \"properties\": \"scale,rotation\" }\n// after\n{ \"action\": \"set\", \"properties\": { \"scale\": 1.0, \"rotation\": 0 } }","handlingStrategy":"type-guard","validationCode":"if (payload.TryGetValue(\"properties\", out var t) && t.Type == JTokenType.String)\n{\n    if (!IsValidJson(t.ToString()))\n        throw new ArgumentException(\"'properties' string must be valid JSON.\");\n}\n// bool IsValidJson(string s) => try { JToken.Parse(s); return true; } catch { return false; }","typeGuard":"// Pass properties as a JSON object, not a string:\n// valid:  { \"properties\": { \"scale\": 1.0 } }\n// valid:  { \"properties\": \"{ \\\"scale\\\": 1.0 }\" }  (JSON-encoded string)\n// invalid:{ \"properties\": \"scale,rotation\" }","tryCatchPattern":null,"preventionTips":["Send 'properties' as a JSON object whenever possible.","If sending a string, validate it parses as JSON before dispatch.","Document the accepted shapes in the tool's schema for LLM callers."],"tags":["json","animation","validation"],"backgroundTag":null,"analyzedSha":"c21bf496bca87d54e75bad048563c3adb1782081","analyzedAt":"2026-08-13T17:36:56.095Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}