{"record":{"id":"999f03ddaca29def","repo":"ent/ent","slug":"gotype-must-be-a-q-type-valuescanner-or-provide","errorCode":null,"errorMessage":"GoType must be a %q type, ValueScanner or provide an external ValueScanner","messagePattern":"GoType must be a %q type, ValueScanner or provide an external ValueScanner","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"schema/field/field.go","lineNumber":1497,"sourceCode":"\t\tm1, ok1 := vs.MethodByName(\"Value\")\n\t\tm2, ok2 := vs.MethodByName(\"ScanValue\")\n\t\tm3, ok3 := vs.MethodByName(\"FromValue\")\n\t\tswitch {\n\t\tcase !ok1, m1.Type.NumIn() != 2, m1.Type.In(1) != t,\n\t\t\tm1.Type.NumOut() != 2, m1.Type.Out(0) != valueType, m1.Type.Out(1) != errorType:\n\t\t\td.Err = fmt.Errorf(\"ValueScanner must implement the Value method: func Value(%s) (driver.Valuer, error)\", t)\n\t\tcase !ok2, m2.Type.NumIn() != 1, m2.Type.NumOut() != 1, m2.Type.Out(0) != valueScannerType:\n\t\t\td.Err = errors.New(\"ValueScanner must implement the ScanValue method: func ScanValue() field.ValueScanner\")\n\t\tcase !ok3, m3.Type.NumIn() != 2, m3.Type.In(1) != valueType, m3.Type.NumOut() != 2, m3.Type.Out(0) != t, m3.Type.Out(1) != errorType:\n\t\t\td.Err = fmt.Errorf(\"ValueScanner must implement the FromValue method: func FromValue(driver.Valuer) (%s, error)\", t)\n\t\t}\n\t// No GoType was provided.\n\tcase d.Info.RType == nil:\n\t// A GoType without an external ValueScanner.\n\tcase pt.Implements(valueScannerType), t.Implements(valueScannerType), t.Kind() == expectType.Kind() && t.ConvertibleTo(expectType):\n\t// There is a GoType, but it's not a ValueScanner.\n\tdefault:\n\t\td.Err = fmt.Errorf(\"GoType must be a %q type, ValueScanner or provide an external ValueScanner\", expectType)\n\t}\n}\n\n// pkgName returns the package name from a Go\n// identifier with a package qualifier.\nfunc pkgName(ident string) string {\n\ti := strings.LastIndexByte(ident, '.')\n\tif i == -1 {\n\t\treturn \"\"\n\t}\n\ts := ident[:i]\n\tif i := strings.LastIndexAny(s, \"]*\"); i != -1 {\n\t\ts = s[i+1:]\n\t}\n\treturn s\n}\n\nfunc methods(t reflect.Type, rtype *RType) {","sourceCodeStart":1479,"sourceCodeEnd":1515,"githubUrl":"https://github.com/ent/ent/blob/69d5d4deb19599f129166634e09d33addcf3f2cc/schema/field/field.go#L1479-L1515","documentation":"Schema-definition error from Descriptor.checkGoType in the default branch: the field's Go type is neither the expected built-in type nor a ValueScanner implementation, and no external ValueScanner was provided on the descriptor. The message names the expected type — the field's GoType must be that type, implement ValueScanner itself, or be paired with an external ValueScanner via the schema API.","triggerScenarios":"Thrown at schema/field/field.go:1497 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the field's GoType to the expected concrete type, or make it implement Value/Scan (driver.Valuer/sql.Scanner)","Provide an external implementation via the ValueScanner option so checkGoType can validate its methods","For custom types over built-ins, use the generic field.ValueScanner[T] helpers in schema/field"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"69d5d4deb19599f129166634e09d33addcf3f2cc","analyzedAt":"2026-09-03T16:51:39.799Z","contentChangedAt":"2026-09-03T16:51:39.799Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}