{"record":{"id":"af8f0a0818bc52a4","repo":"larksuite/cli","slug":"encoding-repeated-only-supports-string-arrays","errorCode":null,"errorMessage":"encoding repeated only supports string arrays","messagePattern":"encoding repeated only supports string arrays","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_args.go","lineNumber":315,"sourceCode":"\t\t}\n\t}\n\tkind := indirectKind(field.valueType)\n\tif kind == reflect.Slice || kind == reflect.Array || kind == reflect.Struct || kind == reflect.Map || kind == reflect.Interface {\n\t\tif field.cli.Encoding == \"\" {\n\t\t\treturn fmt.Errorf(\"%s input must explicitly declare CLI encoding\", kind)\n\t\t}\n\t}\n\tswitch field.cli.Encoding {\n\tcase \"\":\n\t\tif kind == reflect.Slice || kind == reflect.Array || kind == reflect.Struct || kind == reflect.Map || kind == reflect.Interface {\n\t\t\treturn fmt.Errorf(\"complex input requires encoding\")\n\t\t}\n\tcase typedEncodingRepeated:\n\t\tif kind != reflect.Slice && kind != reflect.Array {\n\t\t\treturn fmt.Errorf(\"encoding repeated requires an array or slice\")\n\t\t}\n\t\tif indirectType(field.valueType).Elem().Kind() != reflect.String {\n\t\t\treturn fmt.Errorf(\"encoding repeated only supports string arrays\")\n\t\t}\n\t\tif field.nullable != nil {\n\t\t\treturn fmt.Errorf(\"encoding repeated does not allow nullable/nonnullable\")\n\t\t}\n\tcase typedEncodingCommaOrRepeated:\n\t\tif kind != reflect.Slice && kind != reflect.Array {\n\t\t\treturn fmt.Errorf(\"encoding comma_or_repeated requires an array or slice\")\n\t\t}\n\t\telementKind := indirectType(field.valueType).Elem().Kind()\n\t\tif elementKind != reflect.String && !isIntegerKind(elementKind) {\n\t\t\treturn fmt.Errorf(\"encoding comma_or_repeated only supports string or integer arrays\")\n\t\t}\n\t\tif field.nullable != nil {\n\t\t\treturn fmt.Errorf(\"encoding comma_or_repeated does not allow nullable/nonnullable\")\n\t\t}\n\tcase typedEncodingJSON:\n\t\tif kind != reflect.Slice && kind != reflect.Array && kind != reflect.Struct && kind != reflect.Map && kind != reflect.Interface {\n\t\t\treturn fmt.Errorf(\"encoding json requires array, object, oneOf, or custom JSON input\")","sourceCodeStart":297,"sourceCodeEnd":333,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_args.go#L297-L333","documentation":"encoding=repeated additionally requires the slice/array element to be a string: repeated flag occurrences always yield strings, and the library does not coerce them to other element types. validateInputCLI inspects indirectType(field.valueType).Elem().Kind() and rejects non-string elements.","triggerScenarios":"Declaring encoding=repeated on a field like []int, []bool, or []*string - the kind is a slice/array but the element is not reflect.String. Raised by compileInput during shortcut compilation.","commonSituations":"Repeating flags for integer lists (use comma_or_repeated instead); having changed the element type from string to int without changing the encoding; assuming repeated performs numeric parsing.","solutions":["Use encoding=comma_or_repeated, which supports string or integer arrays","Change the element type to string and parse integers in the shortcut code","Remove the encoding if the field is not a string array"],"exampleFix":"// before\ncli:\"--ids,encoding=repeated\" // []int64 field\n// after\ncli:\"--ids,encoding=comma_or_repeated\"","handlingStrategy":"validation","validationCode":"func repeatedStringElem(t reflect.Type) bool {\n\tfor t.Kind() == reflect.Ptr {\n\t\tt = t.Elem()\n\t}\n\treturn (t.Kind() == reflect.Slice || t.Kind() == reflect.Array) && t.Elem().Kind() == reflect.String\n}","typeGuard":null,"tryCatchPattern":"if err := compileInput(...); err != nil {\n\tif strings.Contains(err.Error(), \"encoding repeated only supports string arrays\") {\n\t\t// switch to comma_or_repeated for integer arrays, or make elements string\n\t}\n\treturn err\n}","preventionTips":["Remember repeated yields strings only; pick comma_or_repeated for int arrays","Keep element types and encodings in sync during refactors","Add a compile test for every typed array input"],"tags":["cli","shortcut-input","encoding","repeated","element-type"],"backgroundTag":"cli-encoding-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"}