larksuite/cli · error
InputField.Shape %T is incompatible with Go type %s
Error message
InputField.Shape %T is incompatible with Go type %s
What it means
During typed Args compilation, an InputField.Shape supplement was provided for a flag, but the declared shape cannot be reconciled with the field's Go value type (e.g. an object shape over an int field). The library refuses to compile because flag parsing and validation semantics derive from this combination.
Source
Thrown at shortcuts/common/typed_compile_args.go:222
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
}
if err := validateShape(shape, "InputField.Shape"); err != nil {
return err
}
if !shapeCompatibleWithType(shape, field.valueType) {
return fmt.Errorf("InputField.Shape %T is incompatible with Go type %s", supplement.Shape, field.valueType)
}
field.shape = shape
field.shapeExplicit = true
}
if supplement.Default.Set {
if field.defaultValue.Set {
return fmt.Errorf("default is declared by both schema and InputField.Default")
}
if field.required {
return fmt.Errorf("required input cannot declare a default")
}
field.defaultValue = supplement.Default
}
if len(supplement.CLI.Aliases) > 0 {
if len(field.cli.Aliases) > 0 {
return fmt.Errorf("CLI.Aliases is declared by both cli tag and InputField.CLI")
}
field.cli.Aliases = append([]typedFlagAlias(nil), supplement.CLI.Aliases...)View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Change the Args struct field type to match the InputField.Shape (or vice versa).
- Remove the InputField.Shape supplement and let the shape be derived from the Go type via shapeForType.
- Verify with a matching shape constructor (e.g. use IntShape for an int field).
Example fix
// before
InputField{Name: "count", Shape: common.StringShape{}} with Args field Count int
// after
InputField{Name: "count", Shape: common.IntShape{}} with Args field Count int Defensive patterns
Strategy: validation
Validate before calling
for _, f := range fields {
switch shp := f.Shape.(type) {
case common.StringShape:
if f.GoType.Kind() != reflect.String { return fmt.Errorf("field %s: string shape needs string Go type", f.Name) }
case common.IntShape:
if f.GoType.Kind() != reflect.Int { return fmt.Errorf("field %s: int shape needs int Go type", f.Name) }
}
} Type guard
func shapeMatches[T any](f InputField, _ T) bool { var v T; return shapeCompatibleWithType(f.Shape, reflect.TypeOf(v)) } Prevention
- Derive shapes from the Go type instead of hand-authoring InputField.Shape when possible.
- Update InputField supplements in the same commit as Args struct type changes.
- Run command-set compile in unit tests so mismatches surface at build/test time.
When it happens
Trigger: compileInput -> mergeInputSupplement when supplement.Shape is non-nil, passes lowerAuthoringShape and validateShape, but shapeCompatibleWithType(shape, field.valueType) returns false.
Common situations: Authoring InputField.Shape programmatically (e.g. StringShape over a bool Go field, or ObjectShape over a string field) after refactoring the Args struct type without updating the supplement.
Related errors
- default is declared by both schema and InputField.Default
- required input cannot declare a default
- CLI.Aliases is declared by both cli tag and InputField.CLI
- CLI.ValueSources is declared by both cli tag and InputField.
- CLI.Encoding is declared by both cli tag and InputField.CLI
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/4fb7d0f55decceb2.
Report an issue: GitHub.