{"record":{"id":"28cc7a4966704cbb","repo":"flipped-aurora/gin-vue-admin","slug":"dimension-department-position-authority","errorCode":null,"errorMessage":"dimension 仅支持 department|position|authority","messagePattern":"dimension 仅支持 department\\|position\\|authority","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/mcp/org_member_query.go","lineNumber":96,"sourceCode":"\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\twithUserInfo := true\n\tif value, ok := args[\"withUserInfo\"].(bool); ok {\n\t\twithUserInfo = value\n\t}\n\n\tvar endpoint, idParam string\n\tswitch dimension {\n\tcase \"department\":\n\t\tendpoint, idParam = \"/department/getDepartmentUsers\", \"deptId\"\n\tcase \"position\":\n\t\tendpoint, idParam = \"/position/getPositionUsers\", \"positionId\"\n\tcase \"authority\":\n\t\tendpoint, idParam = \"/authority/getUsersByAuthority\", \"authorityId\"\n\tdefault:\n\t\treturn nil, errors.New(\"dimension 仅支持 department|position|authority\")\n\t}\n\n\tquery := url.Values{}\n\tquery.Set(idParam, strconv.FormatUint(uint64(targetID), 10))\n\tidsResp, err := getUpstream[[]uint](ctx, endpoint, query)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"获取成员ID列表失败: %w\", err)\n\t}\n\tmemberIDs := idsResp.Data\n\n\tresult := orgMemberResponse{\n\t\tSuccess:     true,\n\t\tMessage:     fmt.Sprintf(\"共 %d 名成员\", len(memberIDs)),\n\t\tDimension:   dimension,\n\t\tTargetID:    targetID,\n\t\tMemberCount: len(memberIDs),\n\t\tMemberIDs:   memberIDs,\n\t}","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/mcp/org_member_query.go#L78-L114","documentation":"The org_member_query MCP tool resolves members of a department, position, or authority (role) via a 'dimension' argument that must be one of department|position|authority. An unknown value hits the switch's default branch, which returns this error listing the three supported values. Each valid dimension maps to a different upstream endpoint and ID parameter (deptId / positionId / authorityId).","triggerScenarios":"Calling org_member_query with dimension set to anything other than department, position, or authority — e.g. 'role', 'dept', 'Department' (case-sensitive), 'user', or a translated label; dimension sent as a non-string type that fails the earlier string assertion differently.","commonSituations":"Callers guessing the enum from domain vocabulary ('role' instead of 'authority'); case mismatches like 'Position'; older scripts written against a different tool naming scheme; i18n clients sending localized dimension names.","solutions":["Set dimension to exactly one of: \"department\", \"position\", or \"authority\" (lowercase)","Replace \"role\" with \"authority\" — gin-vue-admin roles are called authorities","Match the accompanying ID parameter to the dimension: deptId, positionId, or authorityId","Trim/case-normalize the dimension value before calling"],"exampleFix":"// before\nargs := map[string]interface{}{ \"dimension\": \"role\", \"authorityId\": 888 }\n// after\nargs := map[string]interface{}{ \"dimension\": \"authority\", \"authorityId\": 888 }","handlingStrategy":"validation","validationCode":"var validDimensions = map[string]bool{\"department\": true, \"position\": true, \"authority\": true}\n\nfunc validQueryArgs(args map[string]interface{}) error {\n  dim, ok := args[\"dimension\"].(string)\n  if !ok || !validDimensions[dim] {\n    return fmt.Errorf(\"dimension must be department|position|authority, got %v\", args[\"dimension\"])\n  }\n  return nil\n}","typeGuard":"func isKnownDimension(v string) bool {\n  return v == \"department\" || v == \"position\" || v == \"authority\"\n}","tryCatchPattern":"res, err := callTool(ctx, \"org_member_query\", args)\nif err != nil && strings.Contains(err.Error(), \"dimension 仅支持\") {\n  return fmt.Errorf(\"unknown dimension %q: use department|position|authority\", args[\"dimension\"])\n}","preventionTips":["Use the exact lowercase enum literals; map 'role' to 'authority'","Validate dimension against the tool's declared enum in the MCP schema","Pair each dimension with its matching ID param (deptId/positionId/authorityId)","Normalize case/whitespace before dispatching the call"],"tags":["mcp","parameter-validation","go","invalid-enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}