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 err

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Ensure the struct has `Set bool` alongside `Value T`.
  2. Switch to the canonical Provided[T] from extension/command.
  3. 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

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


AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04). Data as JSON: /api/errors/d4e40a2f5eaeecf5. Report an issue: GitHub.