{"record":{"id":"52b10efce157f985","repo":"kataras/iris","slug":"kitchentime-unknown-type-of-t","errorCode":null,"errorMessage":"KitchenTime: unknown type of: %T","messagePattern":"KitchenTime: unknown type of: %T","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"x/jsonx/kitchen_time.go","lineNumber":139,"sourceCode":"\t\t\treturn fmt.Errorf(\"kitchen time: convert to time notation first: %w\", err)\n\t\t}\n\n\t\ts := kitchenTimeStringFromDuration(d.ToDuration())\n\t\t*t, err = ParseKitchenTime(s)\n\t\treturn err\n\tcase int64: // timestamp with integer.\n\t\tu := time.Unix(v/1000, v%1000)\n\t\ts := kitchenTimeStringFromHourAndMinute(u.Hour(), u.Minute())\n\n\t\ttt, err := ParseKitchenTime(s)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t*t = tt\n\tcase nil:\n\t\t*t = KitchenTime(time.Time{})\n\tdefault:\n\t\treturn fmt.Errorf(\"KitchenTime: unknown type of: %T\", v)\n\t}\n\n\treturn nil\n}\n\nfunc kitchenTimeStringFromDuration(dt time.Duration) string {\n\thour := int(dt.Hours())\n\tminute := 0\n\tif totalMins := dt.Minutes(); totalMins > 0 {\n\t\tminute := int(totalMins / 60)\n\t\tif minute < 0 {\n\t\t\tminute = 0\n\t\t}\n\t}\n\n\treturn kitchenTimeStringFromHourAndMinute(hour, minute)\n}\n","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/x/jsonx/kitchen_time.go#L121-L157","documentation":"KitchenTime.Scan only supports src values of type time.Time, string, int64 (millisecond timestamp) and nil. When the driver returns any other Go type (e.g. []byte, float64) it cannot map it to a kitchen time and reports \"KitchenTime: unknown type of: %T\" naming the offending Go type.","triggerScenarios":"Scanning into *jsonx.KitchenTime from a driver that returns []byte for text/time columns, or any non-string non-time value (e.g. NUMERIC returned as float64/[]byte).","commonSituations":"Postgres TIME/TEXT columns scanned through drivers configured to return []byte; mixing a numeric column with a KitchenTime destination struct field.","solutions":["Change the DB column to TIME/TIMESTAMP so the driver yields time.Time.","Check the type named in the message; if it is []byte, scan into a *string first and then use jsonx.ParseKitchenTime on it.","If the value is a millisecond int64 elsewhere, convert to time.Time before scanning."],"exampleFix":"// before\nvar kt jsonx.KitchenTime\nrows.Scan(&kt) // driver returns []byte -> error\n// after\nvar raw string\nrows.Scan(&raw)\nkt, _ = jsonx.ParseKitchenTime(raw)","handlingStrategy":"type-guard","validationCode":"func canScanKitchenTime(src any) bool {\n\tswitch src.(type) {\n\tcase nil, time.Time, string, int64:\n\t\treturn true\n\t}\n\treturn false\n}","typeGuard":"func knownKitchenTimeSrc(src any) bool {\n\tswitch src.(type) {\n\tcase time.Time, string, int64, nil:\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}","tryCatchPattern":"var kt jsonx.KitchenTime\nif err := rows.Scan(&kt); err != nil {\n\tif strings.HasPrefix(err.Error(), \"KitchenTime: unknown type of:\") {\n\t\tvar raw string\n\t\tif e2 := rows.Scan(&raw); e2 == nil {\n\t\t\tkt, err = jsonx.ParseKitchenTime(raw)\n\t\t}\n\t}\n\treturn err\n}","preventionTips":["Match the Go struct field type to the SQL column type","Avoid []byte-returning driver modes for text columns","Test Scan paths against your actual driver's returned types"],"tags":["go","json","scan","type-mismatch","postgres"],"backgroundTag":"unsupported-scan-type","analyzedSha":"7bedaf55a0b64bbb2248a5845a2c60d81a30996a","analyzedAt":"2026-08-30T20:38:16.250Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}