{"record":{"id":"d90e3d343388bf88","repo":"larksuite/cli","slug":"encoding-repeated-does-not-allow-nullable-nonnulla","errorCode":null,"errorMessage":"encoding repeated does not allow nullable/nonnullable","messagePattern":"encoding repeated does not allow nullable/nonnullable","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_args.go","lineNumber":318,"sourceCode":"\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\")\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\")","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_args.go#L300-L336","documentation":"Fields with repeated encoding cannot also declare nullable/nonnullable behavior (field.nullable set). Repeated occurrence counting already defines presence semantics (zero occurrences means empty/absent), so an explicit nullability declaration is redundant and disallowed.","triggerScenarios":"Combining encoding=repeated with a nullable or nonnullable declaration in the cli tag or InputField (field.nullable != nil). Raised by compileInput during shortcut compilation.","commonSituations":"Copy-pasting a nullable=json field definition and changing the encoding to repeated without removing nullable/nonnullable; trying to distinguish 'flag absent' from 'explicitly null' on a repeated field; template-generated fields that always emit nullable.","solutions":["Remove the nullable/nonnullable declaration from the repeated field - an empty list already represents absence","If you need an explicit null sentinel, switch the field to encoding=json where nullability is supported","Keep repeated encoding only on plain []string fields with no nullability clause"],"exampleFix":"// before\ncli:\"--tags,encoding=repeated,nullable\"\n// after\ncli:\"--tags,encoding=repeated\"","handlingStrategy":"validation","validationCode":"func repeatedNoNullable(cliEncoding, nullableDecl string) error {\n\tif cliEncoding == \"repeated\" && nullableDecl != \"\" {\n\t\treturn errors.New(\"repeated fields cannot declare nullable\")\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"if err := compileInput(...); err != nil {\n\tif strings.Contains(err.Error(), \"encoding repeated does not allow nullable\") {\n\t\t// drop nullable/nonnullable from the repeated field\n\t}\n\treturn err\n}","preventionTips":["Do not copy nullable clauses onto repeated fields","Treat repeated fields as naturally absent-or-list semantics","Reserve nullable/nonnullable for encoding=json fields"],"tags":["cli","shortcut-input","encoding","repeated","nullable"],"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"}