{"record":{"id":"640eed5077bace18","repo":"larksuite/cli","slug":"cli-deprecated-is-declared-twice","errorCode":null,"errorMessage":"CLI.Deprecated is declared twice","messagePattern":"CLI\\.Deprecated is declared twice","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_args.go","lineNumber":262,"sourceCode":"\t\t\treturn fmt.Errorf(\"CLI.ValueSources is declared by both cli tag and InputField.CLI\")\n\t\t}\n\t\tfield.cli.ValueSources = append([]typedValueSource(nil), supplement.CLI.ValueSources...)\n\t}\n\tif supplement.CLI.Encoding != \"\" {\n\t\tif field.cli.Encoding != \"\" {\n\t\t\treturn fmt.Errorf(\"CLI.Encoding is declared by both cli tag and InputField.CLI\")\n\t\t}\n\t\tfield.cli.Encoding = supplement.CLI.Encoding\n\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}","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_args.go#L244-L280","documentation":"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.","triggerScenarios":"compileInput -> mergeInputSupplement when supplement.CLI.Deprecated != \"\" and field.cli.Deprecated (parsed from the cli tag) is already non-empty.","commonSituations":"Updating deprecation wording programmatically while the old cli:\"deprecated=...\" tag remains on the struct field.","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."],"exampleFix":"// before\nOld string `flag:\"old\" cli:\"deprecated=use --new\"` + InputField{CLI: CLI{Deprecated: \"use --new\"}}\n// after\nOld string `flag:\"old\"` + InputField{CLI: CLI{Deprecated: \"use --new\"}}","handlingStrategy":"validation","validationCode":"for _, f := range fields {\n    if f.TagDeprecated != \"\" && f.InputDeprecated != \"\" {\n        return fmt.Errorf(\"flag %s: deprecation declared twice\", f.Name)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Update deprecation messages in one channel only; prefer InputField.CLI.Deprecated for centralized wording.","Remove stale cli:\"deprecated=...\" tags when introducing programmatic deprecations."],"tags":["cli","typed-input","duplicate-declaration","deprecation"],"backgroundTag":"conflicting-declaration","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"}