larksuite/cli · error
Provided type has no Value field
Error message
Provided type has no Value field
What it means
unwrapProvided recognizes a Provided[T]-style type by its package path and `Provided[` name prefix, then requires exported `Value` and `Set` fields. This error means a type matched the Provided naming/package pattern but has no `Value` field, so the compiler cannot extract the underlying flag value.
Source
Thrown at shortcuts/common/typed_compile_args.go:194
}
func hasAnyTag(field reflect.StructField, names ...string) bool {
for _, name := range names {
if _, ok := field.Tag.Lookup(name); ok {
return true
}
}
return false
}
func unwrapProvided(t reflect.Type) (reflect.Type, []int, bool, error) {
publicProvided := t.PkgPath() == extensionCommandPkgPath && strings.HasPrefix(t.Name(), "Provided[")
if t.Kind() != reflect.Struct || !publicProvided {
return t, nil, false, nil
}
value, ok := t.FieldByName("Value")
if !ok {
return nil, nil, false, fmt.Errorf("Provided type has no Value field")
}
set, ok := t.FieldByName("Set")
if !ok || set.Type.Kind() != reflect.Bool {
return nil, nil, false, fmt.Errorf("Provided type has invalid Set field")
}
return value.Type, value.Index, true, nil
}
func mergeInputSupplement(field *compiledInputField, supplement typedInputField) error {
if supplement.Description != "" {
if field.description != "" {
return fmt.Errorf("description is declared by both doc and InputField.Description")
}
field.description = strings.TrimSpace(supplement.Description)
}
if supplement.Shape != nil {
if shapeHasConstraints(field.shape) || field.nullable != nil {
return fmt.Errorf("Shape conflicts with schema constraints or nullable declaration")View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Add an exported `Value` field of the value type to the Provided struct.
- Better: use the canonical Provided[T] from github.com/larksuite/cli/extension/command rather than a local copy.
- If this is not meant to be a Provided type, rename it so it no longer starts with `Provided[`.
Example fix
// before
type Provided[T any] struct { Data T; Present bool }
// after
type Provided[T any] struct { Value T; Set bool } Defensive patterns
Strategy: type-guard
Validate before calling
t := reflect.TypeOf(field)
if strings.HasPrefix(t.Name(), "Provided[") {
if _, ok := t.FieldByName("Value"); !ok {
return errors.New("Provided type is missing the Value field")
}
} Type guard
func hasValueField(t reflect.Type) bool {
if !strings.HasPrefix(t.Name(), "Provided[") { return true }
f, ok := t.FieldByName("Value")
return ok && f.IsExported()
} Prevention
- Use the canonical Provided[T] from extension/command instead of custom copies.
- Keep Provided wrappers as `struct{ Value T; Set bool }` exactly.
- Add a reflection test over all Args field types checking Provided shape.
When it happens
Trigger: Declaring a custom generic named `Provided[T]` inside a package that resolves to the extension/command package path without a `Value` field, e.g. `type Provided[T any] struct { Data T; Present bool }`.
Common situations: Vendoring or copying Provided[T] and renaming fields; local reimplementation for tests; code generation that dropped the Value field.
Related errors
- Provided type has invalid Set field
- invalid --param format
- unsafe --output-dir
- unknown flag: --{name}
- command set %d command %d: command path %q conflicts with %s
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/345ec0112322bd65.
Report an issue: GitHub.