{"record":{"id":"83abafaa473fb0f4","repo":"larksuite/cli","slug":"encoding-comma-or-repeated-does-not-allow-nullable","errorCode":null,"errorMessage":"encoding comma_or_repeated does not allow nullable/nonnullable","messagePattern":"encoding comma_or_repeated does not allow nullable/nonnullable","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_args.go","lineNumber":329,"sourceCode":"\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)\n\t\t}\n\t\tif alias.Name == field.name {\n\t\t\treturn fmt.Errorf(\"alias[%d] duplicates canonical flag --%s\", i, field.name)","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_args.go#L311-L347","documentation":"The comma_or_repeated encoding does not support nullable/nonnullable declarations. Because the value is always a concrete list of tokens, a null representation is meaningless, so declaring `nullable` or `nonnullable` in the schema tag alongside this encoding is treated as an authoring contradiction and rejected.","triggerScenarios":"A []string or []int field with cli:\"encoding=comma_or_repeated\" also carries a schema tag token `nullable` or `nonnullable` (field.nullable != nil); validateInputCLI fails during compileInput.","commonSituations":"Adding nullable to every optional field by habit; copying a schema tag from a JSON-encoded field where nullability is allowed.","solutions":["Remove the `nullable`/`nonnullable` token from the schema tag on that field.","Model optionality with `optional` instead; an absent list is already the empty/no-value case.","If null semantics are really needed, switch to encoding=json, which supports nullable declarations."],"exampleFix":"// before\nTags []string `schema:\"optional;nullable\" cli:\"encoding=comma_or_repeated\"`\n// after\nTags []string `schema:\"optional\" cli:\"encoding=comma_or_repeated\"`","handlingStrategy":"validation","validationCode":"// before building the input struct\ntags := fieldTag.Get(\"schema\")\nif strings.Contains(tags, \"comma_or_repeated\") && (strings.Contains(tags, \"nullable\") || strings.Contains(tags, \"nonnullable\")) {\n\treturn fmt.Errorf(\"drop nullable/nonnullable for comma_or_repeated fields\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat `optional` as the only optionality marker for list encodings.","Do not blanket-add nullable tokens to every field.","Review schema tags whenever copying them between fields with different encodings."],"tags":["cli","schema","nullable","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"}