{"record":{"id":"2b6927a236b09bfd","repo":"kataras/iris","slug":"kitchen-time-convert-to-time-notation-first-w","errorCode":null,"errorMessage":"kitchen time: convert to time notation first: %w","messagePattern":"kitchen time: convert to time notation first: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"x/jsonx/kitchen_time.go","lineNumber":121,"sourceCode":"\t\treturn \"\"\n\t}\n\n\treturn tt.Format(KitchenTimeLayout)\n}\n\n// Scan completes the pg and native sql driver.Scanner interface\n// reading functionality of a custom type.\nfunc (t *KitchenTime) Scan(src any) error {\n\tswitch v := src.(type) {\n\tcase time.Time: // type was set to timestamp.\n\t\tif v.IsZero() {\n\t\t\treturn nil // don't set zero, ignore it.\n\t\t}\n\t\t*t = KitchenTime(v)\n\tcase string: // type was set to time, input example: 10:00:00.000000\n\t\td, err := ParseTimeNotationDuration(v)\n\t\tif err != nil {\n\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)","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/x/jsonx/kitchen_time.go#L103-L139","documentation":"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\".","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: stored value \"10:00\" in a text column scanned into jsonx.KitchenTime -> error\n// after\n// stored value: \"10:00:00.000000\"\nvar kt jsonx.KitchenTime\nrows.Scan(&kt) // works","handlingStrategy":"validation","validationCode":"func isTimeNotation(s string) bool {\n\tparts := strings.SplitN(s, \":\", 3)\n\treturn len(parts) == 3\n}\n// check before scanning a string-typed column into jsonx.KitchenTime","typeGuard":"func kitchenTimeFrom(src any) (jsonx.KitchenTime, bool) {\n\tswitch v := src.(type) {\n\tcase time.Time:\n\t\treturn jsonx.KitchenTime(v), true\n\tcase string:\n\t\tif _, err := jsonx.ParseTimeNotationDuration(v); err == nil {\n\t\t\tvar kt jsonx.KitchenTime\n\t\t\tkt.Scan(v)\n\t\t\treturn kt, true\n\t\t}\n\t}\n\treturn jsonx.KitchenTime{}, false\n}","tryCatchPattern":"var kt jsonx.KitchenTime\nif err := rows.Scan(&kt); err != nil {\n\tvar perr error\n\tif errors.As(err, &perr) && strings.Contains(err.Error(), \"convert to time notation\") {\n\t\t// fall back to manual parse of alternate format\n\t}\n\treturn err\n}","preventionTips":["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"],"tags":["go","json","scan","time-parsing","postgres"],"backgroundTag":"invalid-duration-format","analyzedSha":"7bedaf55a0b64bbb2248a5845a2c60d81a30996a","analyzedAt":"2026-08-30T20:38:16.250Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}