{"record":{"id":"9bf21dbebdfe6959","repo":"larksuite/cli","slug":"unknown-value-source-q","errorCode":null,"errorMessage":"unknown value source %q","messagePattern":"unknown value source %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_args.go","lineNumber":284,"sourceCode":"\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{}{}\n\t}\n\tif len(field.cli.ValueSources) > 0 {\n\t\tif _, ok := seenSources[typedSourceFlag]; !ok {\n\t\t\treturn fmt.Errorf(\"ValueSources must include flag\")\n\t\t}\n\t\tif (len(seenSources) > 1) && indirectKind(field.valueType) != reflect.String && field.cli.Encoding != typedEncodingJSON {\n\t\t\treturn fmt.Errorf(\"file/stdin sources require string input or encoding=json\")\n\t\t}\n\t}\n\tkind := indirectKind(field.valueType)\n\tif kind == reflect.Slice || kind == reflect.Array || kind == reflect.Struct || kind == reflect.Map || kind == reflect.Interface {\n\t\tif field.cli.Encoding == \"\" {\n\t\t\treturn fmt.Errorf(\"%s input must explicitly declare CLI encoding\", kind)","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_args.go#L266-L302","documentation":"validateInputCLI validates each entry of field.cli.ValueSources against the known sources (flag, file, stdin). Any string that is not one of these three is rejected with the offending value quoted via %q. This keeps the multi-source input machinery finite and explicit: the field can only draw its value from a flag, a file path, or stdin.","triggerScenarios":"Setting ValueSources in the cli tag or InputField.CLI to a misspelled or invented source, e.g. \"env\", \"Flags\", \"files\", or a stale source name removed from the library. Raised by compileInput during shortcut compilation.","commonSituations":"Typo when hand-writing the cli tag (e.g. \"flg\" instead of \"flag\"); guessing source names instead of consulting the documented set; migrating code from an older API where a different source name existed.","solutions":["Replace the unknown entry with one of: flag, file, or stdin","Check the cli tag spelling and case against the documented typedValueSource constants","If you need another source, it is not supported - feed the value via flag or file instead"],"exampleFix":"// before\nValueSources: []string{\"flag\", \"env\"}\n// after\nValueSources: []string{\"flag\", \"file\"}","handlingStrategy":"validation","validationCode":"var validSources = map[string]bool{\"flag\": true, \"file\": true, \"stdin\": true}\nfunc checkSources(srcs []string) error {\n\tfor _, s := range srcs {\n\t\tif !validSources[s] {\n\t\t\treturn fmt.Errorf(\"bad source %q\", s)\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"if err := compileInput(...); err != nil {\n\tvar ue *fmt.wrapError\n\tif strings.Contains(err.Error(), \"unknown value source\") {\n\t\t// correct the cli tag before redeploying\n\t}\n\treturn err\n}","preventionTips":["Only use the documented constants flag/file/stdin, never hand-typed strings","Keep ValueSources literals next to the typedValueSource definitions in reviews","Lint cli tags in unit tests that compile all shortcuts"],"tags":["cli","shortcut-input","value-sources","validation"],"backgroundTag":"cli-invalid-value-source","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"}