larksuite/cli · error
unknown value source %q
Error message
unknown value source %q
What it means
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.
Source
Thrown at shortcuts/common/typed_compile_args.go:284
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")
}
if field.defaultValue.Set {
if err := valueAssignableTo(field.defaultValue.Value, field.valueType); err != nil {
return fmt.Errorf("default: %w", err)
}
}
seenSources := make(map[typedValueSource]struct{})
for _, source := range field.cli.ValueSources {
if source != typedSourceFlag && source != typedSourceFile && source != typedSourceStdin {
return fmt.Errorf("unknown value source %q", source)
}
if _, duplicate := seenSources[source]; duplicate {
return fmt.Errorf("duplicate value source %q", source)
}
seenSources[source] = struct{}{}
}
if len(field.cli.ValueSources) > 0 {
if _, ok := seenSources[typedSourceFlag]; !ok {
return fmt.Errorf("ValueSources must include flag")
}
if (len(seenSources) > 1) && indirectKind(field.valueType) != reflect.String && field.cli.Encoding != typedEncodingJSON {
return fmt.Errorf("file/stdin sources require string input or encoding=json")
}
}
kind := indirectKind(field.valueType)
if kind == reflect.Slice || kind == reflect.Array || kind == reflect.Struct || kind == reflect.Map || kind == reflect.Interface {
if field.cli.Encoding == "" {
return fmt.Errorf("%s input must explicitly declare CLI encoding", kind)View on GitHub (pinned to 7fd6ef3c07)
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
Example fix
// before
ValueSources: []string{"flag", "env"}
// after
ValueSources: []string{"flag", "file"} Defensive patterns
Strategy: validation
Validate before calling
var validSources = map[string]bool{"flag": true, "file": true, "stdin": true}
func checkSources(srcs []string) error {
for _, s := range srcs {
if !validSources[s] {
return fmt.Errorf("bad source %q", s)
}
}
return nil
} Try / catch
if err := compileInput(...); err != nil {
var ue *fmt.wrapError
if strings.Contains(err.Error(), "unknown value source") {
// correct the cli tag before redeploying
}
return err
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- duplicate value source %q
- ValueSources must include flag
- file/stdin sources require string input or encoding=json
- please select at least one domain
- %s must contain at most %d characters
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/9bf21dbebdfe6959.
Report an issue: GitHub.