{"record":{"id":"52106aef461396ba","repo":"flipped-aurora/gin-vue-admin","slug":"path-52106a","errorCode":null,"errorMessage":"path 参数是必需的","messagePattern":"path 参数是必需的","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/mcp/role_api_assigner.go","lineNumber":67,"sourceCode":"\t\t),\n\t\tmcp.WithString(\"method\",\n\t\t\tmcp.Description(\"HTTP方法，默认POST\"),\n\t\t\tmcp.DefaultString(\"POST\"),\n\t\t),\n\t)\n}\n\nfunc (a *RoleAPIAssigner) Handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {\n\targs := request.GetArguments()\n\n\tauthorityID, err := parseAuthorityID(args[\"authorityId\"])\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tpath, ok := args[\"path\"].(string)\n\tif !ok || strings.TrimSpace(path) == \"\" {\n\t\treturn nil, errors.New(\"path 参数是必需的\")\n\t}\n\tmethod := \"POST\"\n\tif value, ok := args[\"method\"].(string); ok && strings.TrimSpace(value) != \"\" {\n\t\tmethod = value\n\t}\n\n\tpath, method = normalizePolicy(path, method)\n\tcurrentResp, err := postUpstream[map[string][]systemReq.CasbinInfo](ctx, \"/casbin/getPolicyPathByAuthorityId\", map[string]any{\n\t\t\"authorityId\": authorityID,\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"获取角色当前API权限失败: %w\", err)\n\t}\n\n\tcurrent := currentResp.Data[\"paths\"]\n\tupdated, added := appendPolicyIfMissing(current, path, method)\n\tif added {\n\t\tif _, err = postUpstream[map[string]any](ctx, \"/casbin/updateCasbin\", map[string]any{","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/mcp/role_api_assigner.go#L49-L85","documentation":"RoleAPIAssigner.Handle requires a non-empty 'path' argument identifying the API route to assign. The error is thrown when it is absent, not a string, or whitespace-only. It is the path validation guard; 'method' defaults to \"POST\" and is optional.","triggerScenarios":"Calling the tool with no 'path' argument, path set to \"\" or \"   \", or path as a non-string (number/object/null).","commonSituations":"Agent-built payload with wrong field name (e.g. 'route' or 'url'); template leaving path empty; upstream JSON payload serializing path as null.","solutions":["Pass a non-empty 'path' string such as \"/api/user/list\"","Verify the argument key is spelled exactly 'path'","Trim and validate the path on the client before invoking"],"exampleFix":"// before\nargs[\"path\"] = \"\"\n// after\nargs[\"path\"] = \"/api/user/list\"","handlingStrategy":"type-guard","validationCode":"const p = args[\"path\"]\nif (typeof p !== \"string\" || p.trim() === \"\") {\n  throw new Error(\"path 参数是必需的\")\n}","typeGuard":"function isNonEmptyString(v: unknown): v is string {\n  return typeof v === \"string\" && v.trim().length > 0\n}","tryCatchPattern":"try {\n  await callTool(\"role_api_assigner\", { path, method })\n} catch (e) {\n  if (String(e.message).includes(\"path 参数\")) {\n    // 提示用户输入路由路径\n  }\n  throw e\n}","preventionTips":["Build payloads from typed defaults, e.g. path: route.path","Validate the field name 'path' matches exactly before sending","Generate call code from a schema instead of hand-writing keys"],"tags":["mcp","validation","missing-parameter"],"backgroundTag":"missing-required-parameter","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}