{"record":{"id":"f1c07e7c10d4e7cc","repo":"larksuite/cli","slug":"t-is-not-assignable-to-s","errorCode":null,"errorMessage":"%T is not assignable to %s","messagePattern":"%T is not assignable to (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_binder.go","lineNumber":292,"sourceCode":"\tif err != nil {\n\t\treturn err\n\t}\n\ttarget.Set(converted)\n\treturn nil\n}\n\nfunc reflectValue(value any, target reflect.Type) (reflect.Value, error) {\n\tif value == nil {\n\t\treturn reflect.Zero(target), nil\n\t}\n\tv := reflect.ValueOf(value)\n\tif v.Type().AssignableTo(target) {\n\t\treturn v, nil\n\t}\n\tif v.Type().ConvertibleTo(target) {\n\t\treturn v.Convert(target), nil\n\t}\n\treturn reflect.Value{}, fmt.Errorf(\"%T is not assignable to %s\", value, target)\n}\n\nfunc validateCompiledValue(value any, field compiledInputField) error {\n\tif value == nil {\n\t\tif err := validateJSONValueAgainstShape(nil, field.shape, \"value\"); err != nil {\n\t\t\treturn typedFieldValidation(field, \"%v\", err).WithCause(err)\n\t\t}\n\t\treturn nil\n\t}\n\tshape := field.shape\n\tif one, ok := shape.(typedOneOfShape); ok {\n\t\tfor _, variant := range one.Variants {\n\t\t\tif _, null := variant.(typedNullShape); !null {\n\t\t\t\tshape = variant\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_binder.go#L274-L310","documentation":"This error fires in reflectValue when a caller-supplied value's Go type can neither be assigned to nor converted to the target field type (e.g. a string where an int is required). The binder only auto-converts between compatible kinds; anything else is rejected with this message naming the actual %T and target type. It protects the compiled typed-field pipeline from silently mis-typed inputs.","triggerScenarios":"Passing a value of an incompatible Go kind to a typed field — e.g. a string \"123\" for an int field, a map for a string field, a struct where a scalar is declared, or a bool where a number is expected via assignCompiledField.","commonSituations":"Config parsed from YAML/JSON keeps numbers as float64 or strings; developers hand those directly to the binder instead of casting. Also happens when a shortcut option is wired to the wrong typed field, or after a field type change upstream.","solutions":["Cast the value to the declared field type before passing it (strconv.Atoi for numeric strings).","Check the target field's declared type in the compiled schema and supply a value of that Go type.","If the value arrives as JSON, decode with the target type (json.Unmarshal into the typed variable) instead of reusing a generic interface{}."],"exampleFix":"// before\nbinder.Set(\"timeout\", \"30\") // string into int field\n\n// after\nn, err := strconv.Atoi(\"30\")\nif err != nil { return err }\nbinder.Set(\"timeout\", n)","handlingStrategy":"type-guard","validationCode":"func checkFieldKind(v any, want reflect.Kind) bool { return reflect.ValueOf(v).Kind() == want }","typeGuard":null,"tryCatchPattern":"if err := binder.Set(\"timeout\", raw); err != nil {\n    if strings.Contains(err.Error(), \"is not assignable to\") {\n        return fmt.Errorf(\"field %q needs a matching Go type, got %T\", \"timeout\", raw)\n    }\n    return err\n}","preventionTips":["Decode JSON directly into typed variables instead of reusing interface{} maps.","Consult `schema` output for each field's declared type before binding.","Normalize config values (strings to numbers) in one boundary function."],"tags":["go","type-binding","type-mismatch","reflection"],"backgroundTag":"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"}