{"record":{"id":"e54462d0be3a5192","repo":"JeffreySu/WeiXinMPSDK","slug":"invokeweixinapihelper","errorCode":null,"errorMessage":"方法路径不能为空","messagePattern":"方法路径不能为空","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Senparc.Weixin.MCP.Server/InvokeWeixinApiHelper.cs","lineNumber":53,"sourceCode":"    /// </summary>\n    /// <param name=\"fullMethodPath\">完整方法路径，如 \"Senparc.Weixin.MP.AdvancedAPIs.CustomApi.SendTextAsync\"</param>\n    /// <param name=\"parameters\">方法参数</param>\n    /// <returns>方法执行结果</returns>\n    public async Task<object> InvokeFullMethodAsync(string fullMethodPath, object[] parameters)\n    {\n        var (typeName, methodName) = ParseFullMethodPath(fullMethodPath);\n        return await InvokeStaticMethodAsync(typeName, methodName, parameters);\n    }\n\n    /// <summary>\n    /// 解析完整方法路径，分离类型名和方法名\n    /// </summary>\n    /// <param name=\"fullMethodPath\">完整方法路径</param>\n    /// <returns>类型名和方法名的元组</returns>\n    private (string typeName, string methodName) ParseFullMethodPath(string fullMethodPath)\n    {\n        if (string.IsNullOrEmpty(fullMethodPath))\n            throw new ArgumentException(\"方法路径不能为空\", nameof(fullMethodPath));\n\n        var lastDotIndex = fullMethodPath.LastIndexOf('.');\n        if (lastDotIndex == -1)\n            throw new ArgumentException(\"无效的方法路径格式\", nameof(fullMethodPath));\n\n        var typeName = fullMethodPath.Substring(0, lastDotIndex);\n        var methodName = fullMethodPath.Substring(lastDotIndex + 1);\n\n        return (typeName, methodName);\n    }\n\n    /// <summary>\n    /// 调用静态方法\n    /// </summary>\n    /// <param name=\"typeName\">类型名称</param>\n    /// <param name=\"methodName\">方法名称</param>\n    /// <param name=\"parameters\">参数</param>\n    /// <returns>方法执行结果</returns>","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/JeffreySu/WeiXinMPSDK/blob/be573f6f94bdbf718dd5f6cdecb137fbc7ff651e/src/Senparc.Weixin.MCP.Server/InvokeWeixinApiHelper.cs#L35-L71","documentation":"ParseFullMethodPath splits a full method path like \"Namespace.Type.Method\" into a type name and method name. If the supplied fullMethodPath is null or an empty string it throws ArgumentException. It is the first validation step used by InvokeFullMethod/InvokeFullMethodAsync in the MCP server.","triggerScenarios":"Calling InvokeFullMethod or InvokeFullMethodAsync with a null, empty, or whitespace-only fullMethodPath string — e.g. an MCP tool request whose method-path field is missing.","commonSituations":"Malformed MCP client request payloads where the method path parameter is absent, deserialization producing null for an omitted field, copy-paste mistakes leaving the argument empty.","solutions":["Pass a complete method path such as \"Senparc.Weixin.MP.CommonApi.GetToken\"","Validate the methodPath from the incoming request before invoking (string.IsNullOrWhiteSpace check)","Fix the MCP client/tool registration so the method path parameter is always supplied"],"exampleFix":"// before\nvar result = InvokeWeixinApiHelper.InvokeFullMethod(null, \"GetToken\");\n// after\nstring methodPath = \"Senparc.Weixin.MP.CommonApi.GetToken\";\nif (string.IsNullOrWhiteSpace(methodPath)) throw new ArgumentException(\"methodPath required\");\nvar result = InvokeWeixinApiHelper.InvokeFullMethod(methodPath, new object[0]);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(fullMethodPath)) throw new ArgumentException(\"fullMethodPath is required\");","typeGuard":null,"tryCatchPattern":"try { var result = InvokeWeixinApiHelper.InvokeFullMethod(fullMethodPath, args); }\ncatch (ArgumentException ex) when (ex.ParamName == \"fullMethodPath\") { log.Error(\"MCP request missing method path\"); }","preventionTips":["Validate required MCP request fields before dispatch","Never pass request-model properties straight into reflection helpers without null checks","Log incoming payloads when the method path is unexpectedly empty"],"tags":["reflection","argument","mcp","validation"],"backgroundTag":"empty-required-field","analyzedSha":"be573f6f94bdbf718dd5f6cdecb137fbc7ff651e","analyzedAt":"2026-09-12T10:01:50.733Z","contentChangedAt":"2026-09-12T10:01:50.733Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}