larksuite/cli · error
Provided type has invalid Set field
Error message
Provided type has invalid Set field
What it means
Companion to the Value-field check: a type matched the Provided[T] pattern (package path + name prefix) but its `Set` field is missing or is not a plain bool. The Set bool is how the runtime records whether the user supplied the flag, so it is mandatory.
Source
Thrown at shortcuts/common/typed_compile_args.go:198
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")
}
shape, err := lowerAuthoringShape(supplement.Shape)
if err != nil {
return errView on GitHub (pinned to 7fd6ef3c07)
Solutions
- Ensure the struct has `Set bool` alongside `Value T`.
- Switch to the canonical Provided[T] from extension/command.
- If the type is not intended as a Provided wrapper, rename it away from the `Provided[` prefix.
Example fix
// before
type Provided[T any] struct { Value T; Set *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[") {
set, ok := t.FieldByName("Set")
if !ok || set.Type.Kind() != reflect.Bool {
return errors.New("Provided type requires an exported Set bool field")
}
} Type guard
func hasBoolSetField(t reflect.Type) bool {
if !strings.HasPrefix(t.Name(), "Provided[") { return true }
f, ok := t.FieldByName("Set")
return ok && f.Type.Kind() == reflect.Bool
} Prevention
- Never remove or retype the Set bool when customizing Provided structs.
- Prefer the stock Provided[T]; treat its field layout as a contract.
- Run startup compilation of shortcuts in CI to catch layout drift.
When it happens
Trigger: Declaring `type Provided[T any] struct { Value T }` (no Set) or `type Provided[T any] struct { Value T; Set string }` in the extension/command package path and using it as an Args field type.
Common situations: Trimming a vendored Provided type; changing Set to a custom type during refactoring; generated code emitting the wrong Set type.
Related errors
- Provided type has no Value 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/d4e40a2f5eaeecf5.
Report an issue: GitHub.