larksuite/cli · error
CLI.Deprecated is declared twice
Error message
CLI.Deprecated is declared twice
What it means
Guard in mergeInputSupplement: CLI.Deprecated is set by both the cli struct tag and the InputField.CLI supplement. Deprecated status may be declared in only one place.
Source
Thrown at shortcuts/common/typed_compile_args.go:262
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")
}
field.cli.Hidden = true
}
if supplement.CLI.Deprecated != "" {
if field.cli.Deprecated != "" {
return fmt.Errorf("CLI.Deprecated is declared twice")
}
field.cli.Deprecated = supplement.CLI.Deprecated
}
return nil
}
func validateInputCLI(field *compiledInputField) error {
if field.cli.Deprecated != "" && !field.cli.Hidden {
return fmt.Errorf("deprecated primary flag must be hidden")
}
if field.required && field.defaultValue.Set {
return fmt.Errorf("required input cannot declare a default")
}
if field.defaultValue.Set {
if err := valueAssignableTo(field.defaultValue.Value, field.valueType); err != nil {
return fmt.Errorf("default: %w", err)
}
}View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Remove deprecated= from the cli tag and declare it only via InputField.CLI.Deprecated.
- Or delete InputField.CLI.Deprecated if the tag message is the one to keep.
Example fix
// before
Old string `flag:"old" cli:"deprecated=use --new"` + InputField{CLI: CLI{Deprecated: "use --new"}}
// after
Old string `flag:"old"` + InputField{CLI: CLI{Deprecated: "use --new"}} Defensive patterns
Strategy: validation
Validate before calling
for _, f := range fields {
if f.TagDeprecated != "" && f.InputDeprecated != "" {
return fmt.Errorf("flag %s: deprecation declared twice", f.Name)
}
} Prevention
- Update deprecation messages in one channel only; prefer InputField.CLI.Deprecated for centralized wording.
- Remove stale cli:"deprecated=..." tags when introducing programmatic deprecations.
When it happens
Trigger: compileInput -> mergeInputSupplement when supplement.CLI.Deprecated != "" and field.cli.Deprecated (parsed from the cli tag) is already non-empty.
Common situations: Updating deprecation wording programmatically while the old cli:"deprecated=..." tag remains on the struct field.
Related errors
- default is declared by both schema and InputField.Default
- CLI.Aliases is declared by both cli tag and InputField.CLI
- 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
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/640eed5077bace18.
Report an issue: GitHub.