larksuite/cli · error
declares flag aliases for -- more than once after…
Error message
%s declares flag aliases for --%s more than once after normalization
What it means
Validation in Bind: two specs declare aliases for the same canonical flag (identical after normalization). Each canonical flag may receive aliases from only one spec, otherwise alias bookkeeping would be ambiguous.
Solutions
- Merge the aliases into a single Spec for that canonical flag
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/flagalias/flagalias.go:87 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/c0b5708876f02bb5.
Report an issue: GitHub.
Appendix: source
Thrown at internal/flagalias/flagalias.go:87
acceptedAliases := make(map[string]string)
collectAnnotatedAliases(acceptedAliases, flagSet, normalize)
collectAnnotatedAliases(acceptedAliases, cmd.InheritedFlags(), normalize)
aliases := make(map[string]string)
metadata := make(map[*pflag.Flag][]string)
canonicalFlags := make(map[string]*pflag.Flag)
seenCanonical := make(map[string]struct{})
for _, spec := range specs {
if len(spec.Aliases) == 0 {
continue
}
canonicalFlag := flagSet.Lookup(spec.Canonical)
if canonicalFlag == nil {
return fmt.Errorf("%s declares aliases for unregistered flag --%s", cmd.CommandPath(), spec.Canonical)
}
canonical := canonicalFlag.Name
if _, exists := seenCanonical[canonical]; exists {
return fmt.Errorf("%s declares flag aliases for --%s more than once after normalization", cmd.CommandPath(), canonical)
}
seenCanonical[canonical] = struct{}{}
canonicalFlags[canonical] = canonicalFlag
for _, alias := range spec.Aliases {
if err := validateAliasName(alias); err != nil {
return fmt.Errorf("%s alias for --%s: %w", cmd.CommandPath(), canonical, err)
}
normalized := normalize(alias)
if normalized == "" {
return fmt.Errorf("%s alias --%s for --%s normalizes to an empty name", cmd.CommandPath(), alias, canonical)
}
if normalized == canonical {
return fmt.Errorf("%s declares --%s as an alias of itself (--%s after normalization)", cmd.CommandPath(), alias, canonical)
}
if existing, ok := registered[normalized]; ok {
return fmt.Errorf("%s alias --%s for --%s conflicts with registered flag --%s after normalization", cmd.CommandPath(), alias, canonical, existing)
}
if existing, ok := acceptedAliases[normalized]; ok {View on GitHub (pinned to 7fd6ef3c07)