{"record":{"id":"4fb7d0f55decceb2","repo":"larksuite/cli","slug":"inputfield-shape-t-is-incompatible-with-go-type","errorCode":null,"errorMessage":"InputField.Shape %T is incompatible with Go type %s","messagePattern":"InputField\\.Shape %T is incompatible with Go type (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_args.go","lineNumber":222,"sourceCode":"\tif supplement.Description != \"\" {\n\t\tif field.description != \"\" {\n\t\t\treturn fmt.Errorf(\"description is declared by both doc and InputField.Description\")\n\t\t}\n\t\tfield.description = strings.TrimSpace(supplement.Description)\n\t}\n\tif supplement.Shape != nil {\n\t\tif shapeHasConstraints(field.shape) || field.nullable != nil {\n\t\t\treturn fmt.Errorf(\"Shape conflicts with schema constraints or nullable declaration\")\n\t\t}\n\t\tshape, err := lowerAuthoringShape(supplement.Shape)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err := validateShape(shape, \"InputField.Shape\"); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !shapeCompatibleWithType(shape, field.valueType) {\n\t\t\treturn fmt.Errorf(\"InputField.Shape %T is incompatible with Go type %s\", supplement.Shape, field.valueType)\n\t\t}\n\t\tfield.shape = shape\n\t\tfield.shapeExplicit = true\n\t}\n\tif supplement.Default.Set {\n\t\tif field.defaultValue.Set {\n\t\t\treturn fmt.Errorf(\"default is declared by both schema and InputField.Default\")\n\t\t}\n\t\tif field.required {\n\t\t\treturn fmt.Errorf(\"required input cannot declare a default\")\n\t\t}\n\t\tfield.defaultValue = supplement.Default\n\t}\n\tif len(supplement.CLI.Aliases) > 0 {\n\t\tif len(field.cli.Aliases) > 0 {\n\t\t\treturn fmt.Errorf(\"CLI.Aliases is declared by both cli tag and InputField.CLI\")\n\t\t}\n\t\tfield.cli.Aliases = append([]typedFlagAlias(nil), supplement.CLI.Aliases...)","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_args.go#L204-L240","documentation":"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.","triggerScenarios":"compileInput -> mergeInputSupplement when supplement.Shape is non-nil, passes lowerAuthoringShape and validateShape, but shapeCompatibleWithType(shape, field.valueType) returns false.","commonSituations":"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.","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)."],"exampleFix":"// before\nInputField{Name: \"count\", Shape: common.StringShape{}} with Args field Count int\n// after\nInputField{Name: \"count\", Shape: common.IntShape{}} with Args field Count int","handlingStrategy":"validation","validationCode":"for _, f := range fields {\n    switch shp := f.Shape.(type) {\n    case common.StringShape:\n        if f.GoType.Kind() != reflect.String { return fmt.Errorf(\"field %s: string shape needs string Go type\", f.Name) }\n    case common.IntShape:\n        if f.GoType.Kind() != reflect.Int { return fmt.Errorf(\"field %s: int shape needs int Go type\", f.Name) }\n    }\n}","typeGuard":"func shapeMatches[T any](f InputField, _ T) bool { var v T; return shapeCompatibleWithType(f.Shape, reflect.TypeOf(v)) }","tryCatchPattern":null,"preventionTips":["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."],"tags":["cli","typed-input","shape-mismatch","compile-time"],"backgroundTag":"shape-type-mismatch","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}