{"record":{"id":"ae1e2193119d9295","repo":"larksuite/cli","slug":"deprecated-primary-flag-must-be-hidden","errorCode":null,"errorMessage":"deprecated primary flag must be hidden","messagePattern":"deprecated primary flag must be hidden","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_args.go","lineNumber":271,"sourceCode":"\t}\n\tif supplement.CLI.Hidden {\n\t\tif field.cli.Hidden {\n\t\t\treturn fmt.Errorf(\"CLI.Hidden is declared twice\")\n\t\t}\n\t\tfield.cli.Hidden = true\n\t}\n\tif supplement.CLI.Deprecated != \"\" {\n\t\tif field.cli.Deprecated != \"\" {\n\t\t\treturn fmt.Errorf(\"CLI.Deprecated is declared twice\")\n\t\t}\n\t\tfield.cli.Deprecated = supplement.CLI.Deprecated\n\t}\n\treturn nil\n}\n\nfunc validateInputCLI(field *compiledInputField) error {\n\tif field.cli.Deprecated != \"\" && !field.cli.Hidden {\n\t\treturn fmt.Errorf(\"deprecated primary flag must be hidden\")\n\t}\n\tif field.required && field.defaultValue.Set {\n\t\treturn fmt.Errorf(\"required input cannot declare a default\")\n\t}\n\tif field.defaultValue.Set {\n\t\tif err := valueAssignableTo(field.defaultValue.Value, field.valueType); err != nil {\n\t\t\treturn fmt.Errorf(\"default: %w\", err)\n\t\t}\n\t}\n\tseenSources := make(map[typedValueSource]struct{})\n\tfor _, source := range field.cli.ValueSources {\n\t\tif source != typedSourceFlag && source != typedSourceFile && source != typedSourceStdin {\n\t\t\treturn fmt.Errorf(\"unknown value source %q\", source)\n\t\t}\n\t\tif _, duplicate := seenSources[source]; duplicate {\n\t\t\treturn fmt.Errorf(\"duplicate value source %q\", source)\n\t\t}\n\t\tseenSources[source] = struct{}{}","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_args.go#L253-L289","documentation":"validateInputCLI enforces that a deprecated primary flag must also be hidden, so users are not nagged about a flag they should not adopt while it stays prominently visible. A flag with a deprecation notice but cli hidden=false fails compilation.","triggerScenarios":"compileInput -> validateInputCLI when field.cli.Deprecated != \"\" && !field.cli.Hidden — e.g. cli:\"deprecated=...\" without hidden, or InputField.CLI.Deprecated set without InputField.CLI.Hidden.","commonSituations":"Adding a deprecation notice via InputField.CLI.Deprecated and forgetting InputField.CLI.Hidden = true; declaring cli:\"deprecated=...\" alone in the tag.","solutions":["Set InputField.CLI.Hidden = true alongside InputField.CLI.Deprecated.","Or add hidden to the cli tag: cli:\"deprecated=...,hidden\"."],"exampleFix":"// before\nInputField{CLI: CLI{Deprecated: \"use --new\"}}\n// after\nInputField{CLI: CLI{Deprecated: \"use --new\", Hidden: true}}","handlingStrategy":"validation","validationCode":"for _, f := range fields {\n    if f.Deprecated != \"\" && !f.Hidden {\n        return fmt.Errorf(\"flag %s: deprecated flag must also be hidden\", f.Name)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pair Deprecated with Hidden in InputField.CLI literals (helper constructor makes this automatic).","Never write cli:\"deprecated=...\" without hidden in the same tag.","Add a compile test for every deprecated flag you introduce."],"tags":["cli","typed-input","deprecation","hidden","validation"],"backgroundTag":"deprecated-flag-not-hidden","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}