larksuite/cli · error
CLI.Hidden is declared twice
Error message
CLI.Hidden is declared twice
What it means
Hidden was requested twice for one flag: the cli tag already marks the field hidden and InputField.CLI.Hidden is also true. Unlike value fields there is no meaningful merge for a boolean, so the compiler rejects the redundancy.
Source
Thrown at shortcuts/common/typed_compile_args.go:256
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")
}
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")View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Remove hidden from the cli tag, or set InputField.CLI.Hidden = false / omit it.
- Keep exactly one hidden declaration per flag.
Example fix
// before
Token string `flag:"token" cli:"hidden"` + InputField{CLI: CLI{Hidden: true}}
// after
Token string `flag:"token"` + InputField{CLI: CLI{Hidden: true}} Defensive patterns
Strategy: validation
Validate before calling
for _, f := range fields {
if f.TagHidden && f.InputHidden {
return fmt.Errorf("flag %s: hidden declared twice", f.Name)
}
} Prevention
- Mark a flag hidden in exactly one place; avoid setting InputField.CLI.Hidden for fields already tagged cli:"hidden".
- Audit generated supplements so they do not restate tag booleans.
When it happens
Trigger: compileInput -> mergeInputSupplement when supplement.CLI.Hidden is true and field.cli.Hidden (from cli:"hidden") is already true.
Common situations: Setting InputField.CLI.Hidden = true on a field whose tag is cli:"hidden", e.g. when generating supplements from a spec that also round-trips tags.
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.Deprecated is declared twice
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/9b800596f578738c.
Report an issue: GitHub.