{"record":{"id":"2c8eba02e0111ea6","repo":"flipped-aurora/gin-vue-admin","slug":"component","errorCode":null,"errorMessage":"component 参数是必需的","messagePattern":"component 参数是必需的","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/mcp/menu_creator.go","lineNumber":127,"sourceCode":"\t\t\tmcp.Description(\"菜单按钮JSON字符串，格式：[{\\\"name\\\":\\\"add\\\",\\\"desc\\\":\\\"新增\\\"}]\"),\n\t\t),\n\t)\n}\n\nfunc (m *MenuCreator) Handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {\n\targs := request.GetArguments()\n\n\tpath, ok := args[\"path\"].(string)\n\tif !ok || path == \"\" {\n\t\treturn nil, errors.New(\"path 参数是必需的\")\n\t}\n\tname, ok := args[\"name\"].(string)\n\tif !ok || name == \"\" {\n\t\treturn nil, errors.New(\"name 参数是必需的\")\n\t}\n\tcomponent, ok := args[\"component\"].(string)\n\tif !ok || component == \"\" {\n\t\treturn nil, errors.New(\"component 参数是必需的\")\n\t}\n\ttitle, ok := args[\"title\"].(string)\n\tif !ok || title == \"\" {\n\t\treturn nil, errors.New(\"title 参数是必需的\")\n\t}\n\n\t// 兼容 MCP 客户端把数字发成字符串的情况(parentId 允许 0=根,故用 parseOptionalUint;\n\t// 否则字符串 \"5\" 断言 float64 失败会静默回落 0,把菜单错挂到根)\n\tparentID := parseOptionalUint(args[\"parentId\"], 0)\n\thidden := parseOptionalBool(args[\"hidden\"], false)\n\tsort := int(parseOptionalUint(args[\"sort\"], 1))\n\ticon := \"menu\"\n\tif value, ok := args[\"icon\"].(string); ok && value != \"\" {\n\t\ticon = value\n\t}\n\tkeepAlive := parseOptionalBool(args[\"keepAlive\"], false)\n\tdefaultMenu := parseOptionalBool(args[\"defaultMenu\"], false)\n\tcloseTab := parseOptionalBool(args[\"closeTab\"], false)","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/mcp/menu_creator.go#L109-L145","documentation":"MenuCreator.Handle requires a 'component' argument — the frontend component file path (relative to web/src, e.g. view/... Vue file) the menu route should lazy-load. Missing key, non-string value, or empty string triggers this error. It is the third in the chain of required-argument checks (path, name, component, title).","triggerScenarios":"Calling the menu-creation MCP tool with path and name provided but 'component' absent, non-string, or \"\".","commonSituations":"Caller does not know the project's component path convention and omits it; component file not yet generated so the caller left it blank; copying tool-call templates that only include path/title.","solutions":["Provide the component path relative to web/src, e.g. \"view/system/user/user.vue\".","Verify the component file actually exists at that path; create it if the menu points to a new page.","Supply all required arguments in one call: path, name, component, title.","Do not pass an empty string as a placeholder — the check treats \"\" as missing."],"exampleFix":"// before\n{\"path\": \"/system/user\", \"name\": \"user\", \"title\": \"用户管理\", \"component\": \"\"}\n// after\n{\"path\": \"/system/user\", \"name\": \"user\", \"title\": \"用户管理\", \"component\": \"view/system/user/user.vue\"}","handlingStrategy":"validation","validationCode":"component, _ := args[\"component\"].(string)\nif component == \"\" {\n    return errors.New(\"provide the component path relative to web/src, e.g. view/system/user/user.vue\")\n}\nif _, err := os.Stat(filepath.Join(\"web/src\", component)); err != nil {\n    return errors.New(\"component file does not exist; create it before registering the menu\")\n}","typeGuard":"func nonEmptyString(v any) bool {\n    s, ok := v.(string)\n    return ok && s != \"\"\n}","tryCatchPattern":null,"preventionTips":["Verify the component file exists under web/src before registering the menu.","Use the project's view/... path convention for component arguments.","Never pass empty-string placeholders for required menu fields."],"tags":["mcp","validation","go","missing-argument"],"backgroundTag":"missing-required-parameter","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}