{"record":{"id":"5c53c6eb18ea5b99","repo":"flipped-aurora/gin-vue-admin","slug":"s-id","errorCode":null,"errorMessage":"%s 需为ID数组或逗号分隔字符串","messagePattern":"(.+?) 需为ID数组或逗号分隔字符串","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/mcp/org_common.go","lineNumber":79,"sourceCode":"\t\treturn nil, nil\n\t}\n\tvar raw []any\n\tswitch value := v.(type) {\n\tcase []any:\n\t\traw = value\n\tcase string:\n\t\ttrimmed := strings.TrimSpace(value)\n\t\tif trimmed == \"\" {\n\t\t\treturn nil, nil\n\t\t}\n\t\tfor part := range strings.SplitSeq(trimmed, \",\") {\n\t\t\tif strings.TrimSpace(part) == \"\" {\n\t\t\t\tcontinue // 容忍尾随/多余逗号(如 \"1,2,\"),不因空段整体报错\n\t\t\t}\n\t\t\traw = append(raw, part)\n\t\t}\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"%s 需为ID数组或逗号分隔字符串\", name)\n\t}\n\n\tseen := make(map[uint]struct{}, len(raw))\n\tids := make([]uint, 0, len(raw))\n\tfor _, item := range raw {\n\t\tid, err := parseUintParam(item, name)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif _, ok := seen[id]; ok {\n\t\t\tcontinue\n\t\t}\n\t\tseen[id] = struct{}{}\n\t\tids = append(ids, id)\n\t}\n\treturn ids, nil\n}\n","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/mcp/org_common.go#L61-L97","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n{\"deptIds\": 3}\n// after\n{\"deptIds\": [3, 5]}  // or {\"deptIds\": \"3,5\"}","handlingStrategy":"validation","validationCode":"function isValidIdList(v) {\n  return v == null || Array.isArray(v) || typeof v === 'string'\n}\n// call: if (!isValidIdList(args.deptIds)) { /* normalize to [ids] */ }","typeGuard":"function asIdList(v) {\n  if (v == null) return []\n  if (Array.isArray(v)) return v.map(Number)\n  if (typeof v === 'string') return v.split(',').map(s => s.trim()).filter(Boolean).map(Number)\n  return null\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["mcp","parameter-validation","input-format"],"backgroundTag":"invalid-parameter-type","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}