larksuite/cli · error
trimmed_equal_or_error alias --%s requires string input
Error message
trimmed_equal_or_error alias --%s requires string input
What it means
Thrown by validateInputCLI when an independent-mode alias declares conflict=trimmed_equal_or_error but the field's underlying type is not string. That conflict strategy compares flag values after whitespace trimming, which only makes sense for string fields, so the compiler rejects other kinds.
Source
Thrown at shortcuts/common/typed_compile_args.go:366
}
if _, duplicate := seenAliases[alias.Name]; duplicate {
return fmt.Errorf("duplicate alias --%s", alias.Name)
}
seenAliases[alias.Name] = struct{}{}
switch alias.Mode {
case typedAliasNormalize:
if alias.Conflict != "" {
return fmt.Errorf("normalize alias --%s cannot declare Conflict", alias.Name)
}
if alias.Deprecated {
return fmt.Errorf("deprecated alias --%s must use independent mode so Cobra can emit its warning", alias.Name)
}
case typedAliasIndependent:
switch alias.Conflict {
case typedAliasCanonicalWins, typedAliasErrorIfBoth:
case typedAliasTrimmedEqualOrError:
if indirectKind(field.valueType) != reflect.String {
return fmt.Errorf("trimmed_equal_or_error alias --%s requires string input", alias.Name)
}
default:
return fmt.Errorf("independent alias --%s must declare a supported Conflict", alias.Name)
}
default:
return fmt.Errorf("alias --%s has invalid Mode %q", alias.Name, alias.Mode)
}
}
return nil
}
type schemaTag struct {
required bool
optional bool
nullable *bool
defaultValue typedInputDefault
enum []string
format stringView on GitHub (pinned to 7fd6ef3c07)
Solutions
- Change the field to a string type if trimmed comparison is required
- Switch the Conflict to canonical-wins or error-if-both, which work for any type
- Remove the alias if it is no longer needed
Example fix
// before Count int `cli:"--count,alias:--c;mode=independent;conflict=trimmed_equal_or_error"` // after Count int `cli:"--count,alias:--c;mode=independent;conflict=canonical-wins"`
Defensive patterns
Strategy: validation
Validate before calling
if a.Mode == "independent" && a.Conflict == "trimmed_equal_or_error" && indirectKind(fieldType) != reflect.String {
return fmt.Errorf("alias --%s needs a string field for trimmed_equal_or_error", a.Name)
} Type guard
func aliasSupportsTrimmedEqual(fieldType reflect.Type) bool {
k := fieldType
for k.Kind() == reflect.Ptr { k = k.Elem() }
return k.Kind() == reflect.String
} Prevention
- Only use trimmed_equal_or_error on string (or *string) fields
- Default independent aliases to conflict=canonical-wins unless trimming matters
- Review field type changes together with their CLI tags
When it happens
Trigger: A field like `Count int` tagged `alias:--num;mode=independent;conflict=trimmed_equal_or_error`; compileInput invokes validateInputCLI, indirectKind(field.valueType) != reflect.String triggers the error.
Common situations: Copying trimmed_equal_or_error onto a numeric or bool alias; changing a field's type from string to int without updating the alias conflict strategy.
Related errors
- deprecated alias --%s must use independent mode so Cobra can
- independent alias --%s must declare a supported Conflict
- alias --%s has invalid Mode %q
- %s must be a boolean
- %s must be an integer
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/d84d0166da6d11e4.
Report an issue: GitHub.