{"record":{"id":"87e8ca51aa42eb69","repo":"JeffreySu/WeiXinMPSDK","slug":"rootbutton-type","errorCode":null,"errorMessage":"菜单类型无法处理：{rootButton.type}","messagePattern":"菜单类型无法处理：(.+?)","errorType":"exception","errorClass":"WeixinMenuException","httpStatus":null,"severity":"error","filePath":"src/Senparc.Weixin.MP/Senparc.Weixin.MP/CommonAPIs/Menu/CommonApi.Menu.Common.cs","lineNumber":246,"sourceCode":"                        {\n                            name = rootButton.name,\n                            article_id = rootButton.article_id,\n                            type = rootButton.type\n                        });\n                    }\n                    else if (rootButton.type.Equals(\"ARTICLE_VIEW_LIMITED\", StringComparison.OrdinalIgnoreCase))\n                    {\n                        //article_view_limited 按钮\n                        buttonGroup.button.Add(new SingleArticleViewLimitedButton()\n                        {\n                            name = rootButton.name,\n                            article_id = rootButton.article_id,\n                            type = rootButton.type\n                        });\n                    }\n                    else\n                    {\n                        throw new WeixinMenuException(\"菜单类型无法处理：\" + rootButton.type);\n                    }\n                }\n                //else if (availableSubButton < 2)\n                //{\n                //    throw new WeixinMenuException(\"子菜单至少需要填写2个！\");\n                //}\n                else\n                {\n                    //底部二级菜单\n                    var subButton = new SubButton(rootButton.name);\n                    buttonGroup.button.Add(subButton);\n\n                    foreach (var subSubButton in rootButton.sub_button)\n                    {\n                        if (subSubButton == null || string.IsNullOrEmpty(subSubButton.name))\n                        {\n                            continue; //没有设置菜单\n                        }","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/JeffreySu/WeiXinMPSDK/blob/be573f6f94bdbf718dd5f6cdecb137fbc7ff651e/src/Senparc.Weixin.MP/Senparc.Weixin.MP/CommonAPIs/Menu/CommonApi.Menu.Common.cs#L228-L264","documentation":"GetButtonGroup switches on the button's type string; when a bottom-level button has a type the library does not recognize (or an unsupported new Weixin type), it throws WeixinMenuException '菜单类型无法处理：{type}'.","triggerScenarios":"A menu contains a button whose type value is not handled by the installed library version (e.g. newer Weixin types added after this library version was released) or an unexpected/garbage type value.","commonSituations":"Weixin introduces a new menu type while the project pins an old Senparc.Weixin SDK version; manually edited menu JSON with a typo in type.","solutions":["Upgrade Senparc.Weixin.MP to the latest version so new menu types are supported","Inspect the message for the unrecognized type and remove or fix that button in the menu","Catch WeixinMenuException and log the offending type for diagnosis"],"exampleFix":"// package reference\n// before: Senparc.Weixin.MP 6.x (no miniprogram type support)\n// after:  dotnet add package Senparc.Weixin.MP --version latest","handlingStrategy":"validation","validationCode":"var supported = new[]{\"click\",\"view\",\"scancode_push\",\"scancode_waitmsg\",\"pic_sysphoto\",\"pic_photo_or_album\",\"pic_weixin\",\"location_select\",\"view_limited\",\"miniprogram\"};\nif (!supported.Contains(menuJson.button.First().type?.ToLower()))\n    throw new NotSupportedException($\"Unsupported menu type: {menuJson.button.First().type}\");","typeGuard":null,"tryCatchPattern":"try\n{\n    var menu = CommonApi.GetMenu(appId);\n}\ncatch (WeixinMenuException ex) when (ex.Message.StartsWith(\"菜单类型无法处理\"))\n{\n    logger.LogWarning(ex, \"Unhandled menu type encountered; upgrade SDK or fix menu\");\n}","preventionTips":["Keep Senparc.Weixin.MP upgraded to the latest release","Check Weixin release notes for new menu types before adopting them","Validate button types against the SDK version you run","Log the offending type from the exception message"],"tags":["weixin","menu","unsupported-type"],"backgroundTag":"unsupported-enum-value","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"}