larksuite/cli · error
CLI.Aliases is declared by both cli tag and InputField.CLI
Error message
CLI.Aliases is declared by both cli tag and InputField.CLI
What it means
Flag aliases were declared both in the struct field's cli tag (cli:"aliases=...") and in InputField.CLI.Aliases. The merge step forbids double declaration to keep a single source of truth for the alias list.
Source
Thrown at shortcuts/common/typed_compile_args.go:238
}
if !shapeCompatibleWithType(shape, field.valueType) {
return fmt.Errorf("InputField.Shape %T is incompatible with Go type %s", supplement.Shape, field.valueType)
}
field.shape = shape
field.shapeExplicit = true
}
if supplement.Default.Set {
if field.defaultValue.Set {
return fmt.Errorf("default is declared by both schema and InputField.Default")
}
if field.required {
return fmt.Errorf("required input cannot declare a default")
}
field.defaultValue = supplement.Default
}
if len(supplement.CLI.Aliases) > 0 {
if len(field.cli.Aliases) > 0 {
return fmt.Errorf("CLI.Aliases is declared by both cli tag and InputField.CLI")
}
field.cli.Aliases = append([]typedFlagAlias(nil), supplement.CLI.Aliases...)
}
if len(supplement.CLI.ValueSources) > 0 {
if len(field.cli.ValueSources) > 0 {
return fmt.Errorf("CLI.ValueSources is declared by both cli tag and InputField.CLI")
}
field.cli.ValueSources = append([]typedValueSource(nil), supplement.CLI.ValueSources...)
}
if supplement.CLI.Encoding != "" {
if field.cli.Encoding != "" {
return fmt.Errorf("CLI.Encoding is declared by both cli tag and InputField.CLI")
}
field.cli.Encoding = supplement.CLI.Encoding
}
if supplement.CLI.Hidden {
if field.cli.Hidden {
return fmt.Errorf("CLI.Hidden is declared twice")View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Remove the aliases= entry from the cli tag, keeping only InputField.CLI.Aliases.
- Or delete InputField.CLI.Aliases if the tag is the canonical declaration.
Example fix
// before
Name string `flag:"name" cli:"aliases=n"` + InputField{CLI: CLI{Aliases: [...]}}
// after
Name string `flag:"name"` + InputField{CLI: CLI{Aliases: [...]}} Defensive patterns
Strategy: validation
Validate before calling
for _, f := range fields {
if len(f.TagAliases) > 0 && len(f.InputAliases) > 0 {
return fmt.Errorf("flag %s: aliases declared twice", f.Name)
}
} Prevention
- Complete tag-to-InputField migrations in one pass; delete old tag entries immediately.
- Keep a checklist mapping each cli tag option to its InputField.CLI counterpart.
- Cover each flag with a compile smoke test in unit tests.
When it happens
Trigger: compileInput -> mergeInputSupplement when len(supplement.CLI.Aliases) > 0 and len(field.cli.Aliases) > 0 (aliases parsed from the cli tag).
Common situations: Migrating tag-based configuration to programmatic InputField supplements while leaving the old cli tag aliases in place.
Related errors
- default is declared by both schema and InputField.Default
- CLI.ValueSources is declared by both cli tag and InputField.
- CLI.Encoding is declared by both cli tag and InputField.CLI
- CLI.Hidden is declared twice
- CLI.Deprecated is declared twice
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/e52c04ecfd6d2c0d.
Report an issue: GitHub.