kataras/iris · error

KitchenTime: unknown type of: %T

Error message

KitchenTime: unknown type of: %T

What it means

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.

Source

Thrown at x/jsonx/kitchen_time.go:139

			return fmt.Errorf("kitchen time: convert to time notation first: %w", err)
		}

		s := kitchenTimeStringFromDuration(d.ToDuration())
		*t, err = ParseKitchenTime(s)
		return err
	case int64: // timestamp with integer.
		u := time.Unix(v/1000, v%1000)
		s := kitchenTimeStringFromHourAndMinute(u.Hour(), u.Minute())

		tt, err := ParseKitchenTime(s)
		if err != nil {
			return err
		}
		*t = tt
	case nil:
		*t = KitchenTime(time.Time{})
	default:
		return fmt.Errorf("KitchenTime: unknown type of: %T", v)
	}

	return nil
}

func kitchenTimeStringFromDuration(dt time.Duration) string {
	hour := int(dt.Hours())
	minute := 0
	if totalMins := dt.Minutes(); totalMins > 0 {
		minute := int(totalMins / 60)
		if minute < 0 {
			minute = 0
		}
	}

	return kitchenTimeStringFromHourAndMinute(hour, minute)
}

View on GitHub (pinned to 7bedaf55a0)

Solutions

  1. Change the DB column to TIME/TIMESTAMP so the driver yields time.Time.
  2. Check the type named in the message; if it is []byte, scan into a *string first and then use jsonx.ParseKitchenTime on it.
  3. If the value is a millisecond int64 elsewhere, convert to time.Time before scanning.

Example fix

// before
var kt jsonx.KitchenTime
rows.Scan(&kt) // driver returns []byte -> error
// after
var raw string
rows.Scan(&raw)
kt, _ = jsonx.ParseKitchenTime(raw)
Defensive patterns

Strategy: type-guard

Validate before calling

func canScanKitchenTime(src any) bool {
	switch src.(type) {
	case nil, time.Time, string, int64:
		return true
	}
	return false
}

Type guard

func knownKitchenTimeSrc(src any) bool {
	switch src.(type) {
	case time.Time, string, int64, nil:
		return true
	default:
		return false
	}
}

Try / catch

var kt jsonx.KitchenTime
if err := rows.Scan(&kt); err != nil {
	if strings.HasPrefix(err.Error(), "KitchenTime: unknown type of:") {
		var raw string
		if e2 := rows.Scan(&raw); e2 == nil {
			kt, err = jsonx.ParseKitchenTime(raw)
		}
	}
	return err
}

Prevention

When it happens

Trigger: 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).

Common situations: Postgres TIME/TEXT columns scanned through drivers configured to return []byte; mixing a numeric column with a KitchenTime destination struct field.

Related errors


AI-assisted analysis of kataras/iris@7bedaf55a0 (2026-08-30). Data as JSON: /api/errors/52b10efce157f985. Report an issue: GitHub.