flipped-aurora/gin-vue-admin · error
参数是必需的,且至少包含一个ID
Error message
参数是必需的,且至少包含一个ID
What it means
requireNonEmptyList in server/mcp/org_common.go is the shared semantic validation for required ID-list parameters in the org toolset. It returns this error whenever the parsed []uint slice is empty, i.e. the list parameter was omitted, was not a valid array, or contained no usable IDs. The message interpolates the parameter name, so the actual text reads e.g. 'userIds 参数是必需的,且至少包含一个ID'.
Source
Thrown at server/mcp/org_common.go:262
}
// hint 仅是加速命中的优化;username 为 LIKE 模糊匹配且只查首页,未命中(名不匹配或
// 命中过多致目标不在首页)时不误报,回退全量翻页扫描兜底
}
found, _, err := scanUsersByIDs(ctx, []uint{userID})
if err != nil {
return nil, err
}
if user, ok := found[userID]; ok {
return &user, nil
}
return nil, fmt.Errorf("未找到 ID 为 %d 的用户(已扫描前 %d 条,大用户量场景请传 username 参数精确定位)", userID, orgUserScanMaxPages*orgUserScanPageSize)
}
// requireNonEmptyList 语义化的必填列表校验
func requireNonEmptyList(ids []uint, name string) error {
if len(ids) == 0 {
return errors.New(name + " 参数是必需的,且至少包含一个ID")
}
return nil
}
// parseOptionalPositiveInt 解析可选的正整数分页参数,兼容数字与字符串两种形式
// (与本工具集"数字参数兼容字符串"的既定设计一致);缺省或非法时返回 def
func parseOptionalPositiveInt(v any, def int) int {
switch value := v.(type) {
case float64:
if value >= 1 {
return int(value)
}
case string:
if n, err := strconv.Atoi(strings.TrimSpace(value)); err == nil && n >= 1 {
return n
}
}
return defView on GitHub (pinned to 3136500ef3)
Solutions
- Populate the list parameter with at least one positive integer ID
- Send the IDs as a JSON array of numbers (or numeric strings accepted by parseUintList), not a CSV string
- Verify upstream data actually contains the IDs you intend to pass (an empty source list means there is nothing to operate on)
- Read the parameter name embedded in the error message to confirm which list was empty
Example fix
// before
args := map[string]interface{}{ "userIds": []uint{} }
// after
args := map[string]interface{}{ "userIds": []uint{7, 9} } Defensive patterns
Strategy: validation
Validate before calling
func validIDList(args map[string]interface{}, key string) ([]uint, error) {
raw, ok := args[key].([]interface{})
if !ok || len(raw) == 0 {
return nil, fmt.Errorf("%s must be a non-empty array of IDs", key)
}
ids := make([]uint, 0, len(raw))
for _, v := range raw {
n, ok := toUint(v)
if !ok || n == 0 {
return nil, fmt.Errorf("%s contains an invalid ID: %v", key, v)
}
ids = append(ids, n)
}
return ids, nil
} Type guard
func nonEmptyUintList(v interface{}) bool {
l, ok := v.([]interface{})
return ok && len(l) > 0
} Try / catch
if err := requireNonEmptyList(ids, "userIds"); err != nil {
return fmt.Errorf("nothing to operate on: %w", err)
} Prevention
- Check that the source query actually produced IDs before building the call
- Always pass JSON arrays, never CSV strings or single numbers
- Log the payload when a list is empty to catch upstream filter bugs
- Keep the required-list rule in the tool's input schema so clients validate early
When it happens
Trigger: Calling any org MCP tool that takes a required ID list (e.g. userIds, deptIds for delete/batch operations) with an empty array []; omitting the list key entirely; passing a value that parseUintList failed to accept so the resulting slice is empty.
Common situations: Batch scripts that collected zero IDs due to an upstream filter returning nothing; clients sending {} or a comma-separated string instead of a JSON array of IDs; template-generated calls where the list placeholder was left empty.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- title 参数是必需的
- deptIds 与 positionIds 至少需要传一个
- primaryDeptId 需与 deptIds 一起传入(主部门必须属于本次追加或已有的部门集合);仅调整主部门请到前
- dimension 仅支持 department|position|authority
- 未找到 MCP 独立配置文件,请在当前目录、cmd/mcp 目录或通过 -config / GVA_MCP_CONFIG
AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31).
Data as JSON: /api/errors/4d419e44b77695c0.
Report an issue: GitHub.