flipped-aurora/gin-vue-admin · error
%s 需为ID数组或逗号分隔字符串
Error message
%s 需为ID数组或逗号分隔字符串
What it means
parseUintList accepts an ID list only as a JSON array ([]any) or a comma-separated string; any other JSON value type (number, bool, object, single number) falls into the default branch and returns this error. It exists because different MCP clients serialize list arguments inconsistently, and the tool wants a clear message instead of a panic.
Source
Thrown at server/mcp/org_common.go:79
return nil, nil
}
var raw []any
switch value := v.(type) {
case []any:
raw = value
case string:
trimmed := strings.TrimSpace(value)
if trimmed == "" {
return nil, nil
}
for part := range strings.SplitSeq(trimmed, ",") {
if strings.TrimSpace(part) == "" {
continue // 容忍尾随/多余逗号(如 "1,2,"),不因空段整体报错
}
raw = append(raw, part)
}
default:
return nil, fmt.Errorf("%s 需为ID数组或逗号分隔字符串", name)
}
seen := make(map[uint]struct{}, len(raw))
ids := make([]uint, 0, len(raw))
for _, item := range raw {
id, err := parseUintParam(item, name)
if err != nil {
return nil, err
}
if _, ok := seen[id]; ok {
continue
}
seen[id] = struct{}{}
ids = append(ids, id)
}
return ids, nil
}
View on GitHub (pinned to 3136500ef3)
Solutions
- Wrap the IDs in a JSON array: [3,5]
- Or send a comma-separated string: "3,5"
- Check the tool schema and ensure the client does not coerce the list into a scalar or object
- Remove duplicate/conflicting definitions of the argument in the calling code
Example fix
// before
{"deptIds": 3}
// after
{"deptIds": [3, 5]} // or {"deptIds": "3,5"} Defensive patterns
Strategy: validation
Validate before calling
function isValidIdList(v) {
return v == null || Array.isArray(v) || typeof v === 'string'
}
// call: if (!isValidIdList(args.deptIds)) { /* normalize to [ids] */ } Type guard
function asIdList(v) {
if (v == null) return []
if (Array.isArray(v)) return v.map(Number)
if (typeof v === 'string') return v.split(',').map(s => s.trim()).filter(Boolean).map(Number)
return null
} Prevention
- Always send list params as JSON arrays
- Normalize scalar IDs into arrays in your client wrapper before calling MCP tools
- Pin and read the tool schema (WithNumber/WithString declarations) before integrating
When it happens
Trigger: Calling an MCP org tool (e.g. assign_user_org) with deptIds or positionIds set to a non-list value: a bare number (deptIds=3), a boolean, a nested object, or an array-of-objects; also when a client sends the argument under a different shape than expected.
Common situations: LLM/client sends a single ID without wrapping it in an array; a client passes the parameter as an object like {"ids":[1,2]} instead of [1,2]; tool schema drift after upgrading where the arg is now a number.
Related errors
- title 参数是必需的
- 参数是必需的,且至少包含一个ID
- deptIds 与 positionIds 至少需要传一个
- primaryDeptId 需与 deptIds 一起传入(主部门必须属于本次追加或已有的部门集合);仅调整主部门请到前
- dimension 仅支持 department|position|authority
AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31).
Data as JSON: /api/errors/5c53c6eb18ea5b99.
Report an issue: GitHub.