flipped-aurora/gin-vue-admin · error
单次分配的部门/岗位数量各不能超过 %d 个
Error message
单次分配的部门/岗位数量各不能超过 %d 个
What it means
assign_user_org enforces orgBatchLimit (50) per call for department and position ID lists to bound blast radius of mistaken writes. Exceeding 50 in either list returns this error before any validation or upstream write.
Source
Thrown at server/mcp/org_member_assigner.go:93
userID, err := parseUintParam(args["userId"], "userId")
if err != nil {
return nil, err
}
usernameHint, _ := args["username"].(string)
deptIDs, err := parseUintList(args["deptIds"], "deptIds")
if err != nil {
return nil, err
}
positionIDs, err := parseUintList(args["positionIds"], "positionIds")
if err != nil {
return nil, err
}
if len(deptIDs) == 0 && len(positionIDs) == 0 {
return nil, errors.New("deptIds 与 positionIds 至少需要传一个")
}
if len(deptIDs) > orgBatchLimit || len(positionIDs) > orgBatchLimit {
return nil, fmt.Errorf("单次分配的部门/岗位数量各不能超过 %d 个", orgBatchLimit)
}
// primaryDeptId 只在设置部门(deptIds)时生效;仅传 primaryDeptId 不传 deptIds 会被静默丢弃,
// 显式挡回避免调用方误以为主部门已变更
if value, ok := args["primaryDeptId"]; ok && value != nil && len(deptIDs) == 0 {
return nil, errors.New("primaryDeptId 需与 deptIds 一起传入(主部门必须属于本次追加或已有的部门集合);仅调整主部门请到前端组织管理页操作")
}
// 校验目标部门/岗位真实存在,把无效ID挡在写入之前
if len(deptIDs) > 0 {
deptIndex, err := fetchDeptIndex(ctx)
if err != nil {
return nil, err
}
for _, id := range deptIDs {
if _, ok := deptIndex[id]; !ok {
return nil, fmt.Errorf("部门 %d 不存在,可先用 query_org_structure 查询部门树", id)
}
}View on GitHub (pinned to 3136500ef3)
Solutions
- Split the assignment into multiple calls of at most 50 IDs each
- Pre-deduplicate the ID list to reduce count under the limit
- For true bulk migrations, use the admin UI or a dedicated batch API instead of the MCP tool
- Ensure each call is idempotent-safe (the tool only appends, so chunking is safe)
Example fix
// before
{"deptIds": [1,2,...,60]}
// after
// call 1
{"deptIds": [1,2,...,50]}
// call 2
{"deptIds": [51,...,60]} // tool is append-only and idempotent, safe to chunk Defensive patterns
Strategy: validation
Validate before calling
if (deptIds.length > 50 || positionIds.length > 50) {
// chunk into batches of <= 50 before calling
}
const chunks = (arr, n) => arr.length ? [arr.slice(0, n), ...chunks(arr.slice(n), n)] : [] Prevention
- Chunk any bulk list into groups of 50 before calling
- Deduplicate IDs first — the limit applies to unique parsed IDs
- Remember the tool is append-only/idempotent, so multi-call chunking is safe
When it happens
Trigger: Calling assign_user_org with deptIds or positionIds containing more than 50 IDs after parsing (duplicates already removed, so 50 unique IDs is the ceiling).
Common situations: Bulk onboarding scripts assigning a whole org's departments in one call; importing data from another system with large membership lists.
Related errors
- apis 需为JSON数组或逗号分隔字符串
- 无法解析API项 %q,期望 "/path" 或 "METHOD /path"
- 单次授权菜单数量不能超过 %d 个
- 未找到 MCP 独立配置文件,请在当前目录、cmd/mcp 目录或通过 -config / GVA_MCP_CONFIG
- 未能自动识别项目根目录,请在 MCP 配置中设置 autocode.root
AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31).
Data as JSON: /api/errors/65822df9eba1024e.
Report an issue: GitHub.