{"record":{"id":"aa9166df03e93a79","repo":"larksuite/cli","slug":"cli-valuesources-is-declared-by-both-cli-tag-and-i","errorCode":null,"errorMessage":"CLI.ValueSources is declared by both cli tag and InputField.CLI","messagePattern":"CLI\\.ValueSources is declared by both cli tag and InputField\\.CLI","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_args.go","lineNumber":244,"sourceCode":"\t}\n\tif supplement.Default.Set {\n\t\tif field.defaultValue.Set {\n\t\t\treturn fmt.Errorf(\"default is declared by both schema and InputField.Default\")\n\t\t}\n\t\tif field.required {\n\t\t\treturn fmt.Errorf(\"required input cannot declare a default\")\n\t\t}\n\t\tfield.defaultValue = supplement.Default\n\t}\n\tif len(supplement.CLI.Aliases) > 0 {\n\t\tif len(field.cli.Aliases) > 0 {\n\t\t\treturn fmt.Errorf(\"CLI.Aliases is declared by both cli tag and InputField.CLI\")\n\t\t}\n\t\tfield.cli.Aliases = append([]typedFlagAlias(nil), supplement.CLI.Aliases...)\n\t}\n\tif len(supplement.CLI.ValueSources) > 0 {\n\t\tif len(field.cli.ValueSources) > 0 {\n\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\")","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_args.go#L226-L262","documentation":"Value sources (flag/file/stdin) were declared both in the cli tag and in InputField.CLI.ValueSources. The compiler rejects the double declaration because sources determine accepted input channels and must be unambiguous.","triggerScenarios":"compileInput -> mergeInputSupplement when len(supplement.CLI.ValueSources) > 0 and len(field.cli.ValueSources) > 0 (parsed from cli tag, e.g. cli:\"sources=flag,file\").","commonSituations":"Adding programmatic ValueSources to a field whose cli tag already lists sources, typically during incremental migration from tags to InputField definitions.","solutions":["Remove the sources= entry from the cli tag and keep InputField.CLI.ValueSources.","Or drop InputField.CLI.ValueSources if the tag already declares the sources."],"exampleFix":"// before\nData string `flag:\"data\" cli:\"sources=flag,file\"` + InputField{CLI: CLI{ValueSources: [...]}}\n// after\nData string `flag:\"data\"` + InputField{CLI: CLI{ValueSources: [...]}}","handlingStrategy":"validation","validationCode":"for _, f := range fields {\n    if len(f.TagSources) > 0 && len(f.InputSources) > 0 {\n        return fmt.Errorf(\"flag %s: value sources declared twice\", f.Name)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare value sources in only one channel; prefer InputField.CLI.ValueSources for programmatic control.","Search for sources= in struct tags before adding ValueSources supplements."],"tags":["cli","typed-input","duplicate-declaration","value-sources"],"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"}