{"record":{"id":"63ea4d2d67b38aaa","repo":"larksuite/cli","slug":"expected-list-got-t","errorCode":null,"errorMessage":"expected list, got %T","messagePattern":"expected list, got %T","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_binder.go","lineNumber":215,"sourceCode":"\tif target == jsonRawMessageType {\n\t\tencoded, err := json.Marshal(raw)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn json.RawMessage(encoded), nil\n\t}\n\tif target.Kind() == reflect.Pointer {\n\t\tvalue, err := convertReflectValue(raw, target.Elem())\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tpointer := reflect.New(target.Elem())\n\t\tpointer.Elem().Set(reflect.ValueOf(value))\n\t\treturn pointer.Interface(), nil\n\t}\n\tif target.Kind() == reflect.Array || target.Kind() == reflect.Slice {\n\t\tif rawValue.Kind() != reflect.Array && rawValue.Kind() != reflect.Slice {\n\t\t\treturn nil, fmt.Errorf(\"expected list, got %T\", raw)\n\t\t}\n\t\tif target.Kind() == reflect.Array && rawValue.Len() != target.Len() {\n\t\t\treturn nil, fmt.Errorf(\"expected exactly %d items for %s, got %d\", target.Len(), target, rawValue.Len())\n\t\t}\n\t\tresult := reflect.MakeSlice(reflect.SliceOf(target.Elem()), rawValue.Len(), rawValue.Len())\n\t\tfor i := 0; i < rawValue.Len(); i++ {\n\t\t\tvalue, err := convertReflectValue(rawValue.Index(i).Interface(), target.Elem())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tresult.Index(i).Set(reflect.ValueOf(value))\n\t\t}\n\t\tif target.Kind() == reflect.Array {\n\t\t\tarray := reflect.New(target).Elem()\n\t\t\treflect.Copy(array, result)\n\t\t\treturn array.Interface(), nil\n\t\t}\n\t\treturn result.Convert(target).Interface(), nil","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_binder.go#L197-L233","documentation":"convertReflectValue, when the target type is a slice or array, requires the raw compiled value to itself be an array/slice (as produced by JSON decoding or repeated flags). Any other Go kind (string, map, number) yields 'expected list, got %T'.","triggerScenarios":"Passing a scalar to a list-typed input, e.g. --ids '1,2,3' as a plain string where the field expects a JSON array '[\"1\",\"2\"]', or a single object where a list of objects is required.","commonSituations":"Confusing comma-separated string flags with array-typed JSON inputs; schema change turned a field into a list; copying an example that omitted the brackets.","solutions":["Pass a JSON array: --ids '[\"a\",\"b\"]'","Use the repeated-flag encoding if the field declares it: --ids a --ids b","Inspect schema output for the field's declared type to confirm it is a list"],"exampleFix":"// before\n--members \"alice,bob\"\n// after\n--members '[\"alice\",\"bob\"]'","handlingStrategy":"type-guard","validationCode":"const v = JSON.parse(raw); if (!Array.isArray(v)) throw new Error('list required for --ids')","typeGuard":"func isJSONList(s string) (list bool) { var v any; if json.Unmarshal([]byte(s), &v) != nil { return false }; _, ok := v.([]any); return ok }","tryCatchPattern":"if strings.HasPrefix(err.Error(), \"expected list\") { /* wrap the scalar into [value] or switch to the repeated-flag form */ }","preventionTips":["Check schema for list-typed fields and always pass JSON arrays","Use repeated flags (--ids a --ids b) when the field encoding allows","Never pass bare comma-separated strings to list fields"],"tags":["type-conversion","list","input-binding"],"backgroundTag":"input-type-mismatch","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}