{"record":{"id":"bc8d0b8df2aad3cd","repo":"JeffreySu/WeiXinMPSDK","slug":"invokeweixinapihelper-bc8d0b","errorCode":null,"errorMessage":"无效的方法路径格式","messagePattern":"无效的方法路径格式","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Senparc.Weixin.MCP.Server/InvokeWeixinApiHelper.cs","lineNumber":57,"sourceCode":"    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>\n    public object InvokeStaticMethod(string typeName, string methodName, object[] parameters)\n    {\n        try\n        {","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/JeffreySu/WeiXinMPSDK/blob/be573f6f94bdbf718dd5f6cdecb137fbc7ff651e/src/Senparc.Weixin.MCP.Server/InvokeWeixinApiHelper.cs#L39-L75","documentation":"ParseFullMethodPath requires the method path to contain at least one dot separating type name from method name. If fullMethodPath has no '.', it throws ArgumentException with this message. This enforces the \"Namespace.Type.Method\" format expected by the reflection-based invoker.","triggerScenarios":"Passing a path without a dot, e.g. \"GetToken\" or \"CommonApi\" instead of \"Senparc.Weixin.MP.CommonApi.GetToken\" to InvokeFullMethod/InvokeFullMethodAsync.","commonSituations":"Clients sending only the method name, confusion about the required fully-qualified format, building the path dynamically and dropping the namespace portion.","solutions":["Supply the fully-qualified path including namespace, type and method separated by dots","Inspect the incoming value and log it to confirm it contains a dot","On the caller side, compose the path from typeFullName + \".\" + methodName"],"exampleFix":"// before\nInvokeWeixinApiHelper.InvokeFullMethod(\"GetToken\", args);\n// after\nInvokeWeixinApiHelper.InvokeFullMethod(\"Senparc.Weixin.MP.CommonApi.GetToken\", args);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(methodPath) || !methodPath.Contains('.')) throw new ArgumentException(\"methodPath must be 'Namespace.Type.Method'\");","typeGuard":null,"tryCatchPattern":"try { var result = InvokeWeixinApiHelper.InvokeFullMethodAsync(methodPath, args); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"无效的方法路径格式\")) { log.Error($\"Invalid method path '{methodPath}', expected Namespace.Type.Method\"); }","preventionTips":["Compose paths as typeFullName + \".\" + methodName","Document the fully-qualified format in MCP tool definitions","Add a format check at the API boundary"],"tags":["reflection","argument-format","mcp","validation"],"backgroundTag":"invalid-argument-format","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"}