larksuite/cli · error
encoding comma_or_repeated does not allow nullable/nonnullab
Error message
encoding comma_or_repeated does not allow nullable/nonnullable
What it means
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.
Source
Thrown at shortcuts/common/typed_compile_args.go:329
if kind != reflect.Slice && kind != reflect.Array {
return fmt.Errorf("encoding repeated requires an array or slice")
}
if indirectType(field.valueType).Elem().Kind() != reflect.String {
return fmt.Errorf("encoding repeated only supports string arrays")
}
if field.nullable != nil {
return fmt.Errorf("encoding repeated does not allow nullable/nonnullable")
}
case typedEncodingCommaOrRepeated:
if kind != reflect.Slice && kind != reflect.Array {
return fmt.Errorf("encoding comma_or_repeated requires an array or slice")
}
elementKind := indirectType(field.valueType).Elem().Kind()
if elementKind != reflect.String && !isIntegerKind(elementKind) {
return fmt.Errorf("encoding comma_or_repeated only supports string or integer arrays")
}
if field.nullable != nil {
return fmt.Errorf("encoding comma_or_repeated does not allow nullable/nonnullable")
}
case typedEncodingJSON:
if kind != reflect.Slice && kind != reflect.Array && kind != reflect.Struct && kind != reflect.Map && kind != reflect.Interface {
return fmt.Errorf("encoding json requires array, object, oneOf, or custom JSON input")
}
if isNilCapable(field.valueType) && field.nullable == nil && !field.shapeExplicit && !shapeExplicitlyNullable(field.shape) {
return fmt.Errorf("nil-capable encoding=json input must declare nullable or nonnullable")
}
default:
return fmt.Errorf("unknown CLI encoding %q", field.cli.Encoding)
}
seenAliases := make(map[string]struct{})
for i, alias := range field.cli.Aliases {
if !aliasNamePattern.MatchString(alias.Name) {
return fmt.Errorf("alias[%d] name %q is invalid", i, alias.Name)
}
if alias.Name == field.name {
return fmt.Errorf("alias[%d] duplicates canonical flag --%s", i, field.name)View on GitHub (pinned to 7fd6ef3c07)
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.
Example fix
// before Tags []string `schema:"optional;nullable" cli:"encoding=comma_or_repeated"` // after Tags []string `schema:"optional" cli:"encoding=comma_or_repeated"`
Defensive patterns
Strategy: validation
Validate before calling
// before building the input struct
tags := fieldTag.Get("schema")
if strings.Contains(tags, "comma_or_repeated") && (strings.Contains(tags, "nullable") || strings.Contains(tags, "nonnullable")) {
return fmt.Errorf("drop nullable/nonnullable for comma_or_repeated fields")
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Adding nullable to every optional field by habit; copying a schema tag from a JSON-encoded field where nullability is allowed.
Related errors
- nil-capable encoding=json input must declare nullable or non
- encoding comma_or_repeated requires an array or slice
- encoding comma_or_repeated only supports string or integer a
- encoding json requires array, object, oneOf, or custom JSON
- unknown CLI encoding %q
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/83abafaa473fb0f4.
Report an issue: GitHub.