{"record":{"id":"2d280296440ac437","repo":"larksuite/cli","slug":"encoding-comma-or-repeated-only-supports-string-or","errorCode":null,"errorMessage":"encoding comma_or_repeated only supports string or integer arrays","messagePattern":"encoding comma_or_repeated only supports string or integer arrays","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_args.go","lineNumber":326,"sourceCode":"\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\")\n\t\t}\n\t\tif isNilCapable(field.valueType) && field.nullable == nil && !field.shapeExplicit && !shapeExplicitlyNullable(field.shape) {\n\t\t\treturn fmt.Errorf(\"nil-capable encoding=json input must declare nullable or nonnullable\")\n\t\t}\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown CLI encoding %q\", field.cli.Encoding)\n\t}\n\tseenAliases := make(map[string]struct{})\n\tfor i, alias := range field.cli.Aliases {\n\t\tif !aliasNamePattern.MatchString(alias.Name) {\n\t\t\treturn fmt.Errorf(\"alias[%d] name %q is invalid\", i, alias.Name)","sourceCodeStart":308,"sourceCodeEnd":344,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_args.go#L308-L344","documentation":"encoding=comma_or_repeated splits CLI input into list elements, so the slice element must be parseable from a plain token. Only string and integer element kinds are supported; other element types (bool, float, structs, pointers to them, etc.) are rejected at compile time of the input struct.","triggerScenarios":"A field like `[]bool`, `[]float64`, `[]time.Duration`, or `[]*string` declares cli:\"encoding=comma_or_repeated\"; validateInputCLI inspects indirectType(field.valueType).Elem().Kind() and it is neither reflect.String nor an integer kind.","commonSituations":"Assuming any slice type works with comma_or_repeated because []string and []int do; switching []int to []float64; using a slice of custom string-like types without a supported underlying kind.","solutions":["Change the element type to string or an integer kind (int, int8..int64, uint variants).","Use encoding=json instead, which accepts arbitrary element types via a JSON array value.","Parse exotic element types manually in the shortcut rather than via typed CLI encoding."],"exampleFix":"// before\nRatios []float64 `schema:\"optional\" cli:\"encoding=comma_or_repeated\"`\n// after\nRatios []int `schema:\"optional\" cli:\"encoding=comma_or_repeated\"`","handlingStrategy":"validation","validationCode":"func validCommaOrRepeatedElem(v any) error {\n\tt := reflect.TypeOf(v)\n\tfor t != nil && t.Kind() == reflect.Ptr { t = t.Elem() }\n\tif t == nil || (t.Kind() != reflect.Slice && t.Kind() != reflect.Array) {\n\t\treturn fmt.Errorf(\"needs slice/array\")\n\t}\n\tk := t.Elem().Kind()\n\tintKinds := map[reflect.Kind]bool{reflect.Int: true, reflect.Int8: true, reflect.Int16: true, reflect.Int32: true, reflect.Int64: true, reflect.Uint: true, reflect.Uint8: true, reflect.Uint16: true, reflect.Uint32: true, reflect.Uint64: true}\n\tif k != reflect.String && !intKinds[k] {\n\t\treturn fmt.Errorf(\"comma_or_repeated element must be string or integer, got %v\", k)\n\t}\n\treturn nil\n}","typeGuard":"func isStringOrIntSlice(t reflect.Type) bool {\n\tfor t != nil && t.Kind() == reflect.Ptr { t = t.Elem() }\n\tif t == nil || (t.Kind() != reflect.Slice && t.Kind() != reflect.Array) { return false }\n\tk := t.Elem().Kind()\n\treturn k == reflect.String || strings.HasPrefix(k.String(), \"int\") || strings.HasPrefix(k.String(), \"uint\")\n}","tryCatchPattern":null,"preventionTips":["Restrict comma_or_repeated to []string and integer slices; use encoding=json for anything else.","Never assume float/bool slices are token-parseable.","Run the input-struct compile test suite before merging tag changes."],"tags":["cli","schema","unsupported-type","authoring-time"],"backgroundTag":"invalid-cli-tag-encoding","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"}