kataras/iris · error
kitchen time: convert to time notation first: %w
Error message
kitchen time: convert to time notation first: %w
What it means
KitchenTime.Scan wraps any failure from ParseTimeNotationDuration when the database returns a string value for a KitchenTime column. Scan expects string values to be PostgreSQL TIME notation like "10:00:00.000000" (hours:minutes:seconds, optional fractional suffix); anything else fails parsing and is wrapped as "kitchen time: convert to time notation first: %w".
Source
Thrown at x/jsonx/kitchen_time.go:121
return ""
}
return tt.Format(KitchenTimeLayout)
}
// Scan completes the pg and native sql driver.Scanner interface
// reading functionality of a custom type.
func (t *KitchenTime) Scan(src any) error {
switch v := src.(type) {
case time.Time: // type was set to timestamp.
if v.IsZero() {
return nil // don't set zero, ignore it.
}
*t = KitchenTime(v)
case string: // type was set to time, input example: 10:00:00.000000
d, err := ParseTimeNotationDuration(v)
if err != nil {
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)View on GitHub (pinned to 7bedaf55a0)
Solutions
- Fix the stored value so it matches h:mm:ss, e.g. "10:00:00.000000" or "10:00:00".
- Change the column type to TIME (or TIMESTAMP) so the driver returns time.Time instead of a string, which Scan handles natively.
- Parse/normalize the string yourself with jsonx.ParseTimeNotationDuration before storing, or scan into a plain string and convert manually.
Example fix
// before: stored value "10:00" in a text column scanned into jsonx.KitchenTime -> error // after // stored value: "10:00:00.000000" var kt jsonx.KitchenTime rows.Scan(&kt) // works
Defensive patterns
Strategy: validation
Validate before calling
func isTimeNotation(s string) bool {
parts := strings.SplitN(s, ":", 3)
return len(parts) == 3
}
// check before scanning a string-typed column into jsonx.KitchenTime Type guard
func kitchenTimeFrom(src any) (jsonx.KitchenTime, bool) {
switch v := src.(type) {
case time.Time:
return jsonx.KitchenTime(v), true
case string:
if _, err := jsonx.ParseTimeNotationDuration(v); err == nil {
var kt jsonx.KitchenTime
kt.Scan(v)
return kt, true
}
}
return jsonx.KitchenTime{}, false
} Try / catch
var kt jsonx.KitchenTime
if err := rows.Scan(&kt); err != nil {
var perr error
if errors.As(err, &perr) && strings.Contains(err.Error(), "convert to time notation") {
// fall back to manual parse of alternate format
}
return err
} Prevention
- Use TIME/TIMESTAMP column types so Scan receives time.Time, not strings
- Keep stored text values in strict HH:MM:SS(.ffffff) form
- Validate seed/fixture data formats in CI
When it happens
Trigger: Calling rows.Scan into *jsonx.KitchenTime when src is a string that is not h:mm:ss notation — e.g. "10:00" (only two parts), "3:04 PM" (already kitchen format), an empty string, or an arbitrary text column value.
Common situations: Storing kitchen time as VARCHAR in Postgres and writing short "10:00" values; the DB driver returning the raw string because the column type is TEXT; hand-edited seed data in the wrong format.
Related errors
- KitchenTime: unknown type of: %T
- SimpleDate: unknown type of: %T
- simple dates: scan: invalid type of: %T
- %s: %w
- invalid duration format: expected hours:minutes:seconds (e.g
AI-assisted analysis of kataras/iris@7bedaf55a0 (2026-08-30).
Data as JSON: /api/errors/2b6927a236b09bfd.
Report an issue: GitHub.