bytebase/bytebase · error
failed to parse time %v, error: %v
Error message
failed to parse time %v, error: %v
What it means
After confirming the >=/<= filter targets create_time and its value is a string, the code parses it with time.Parse(time.RFC3339, ...). A string that is not a valid RFC3339 timestamp makes time.Parse fail and this wrapped error reports both the offending value and the underlying parse error.
Source
Thrown at backend/store/audit_log.go:233
}
return qb.Q().Space("(?)", q), nil
case celoperators.Equals:
variable, rawValue := getVariableAndValueFromExpr(expr)
return auditLogEqualsFilter(variable, rawValue)
case celoperators.GreaterEquals, celoperators.LessEquals:
variable, rawValue := getVariableAndValueFromExpr(expr)
value, ok := rawValue.(string)
if !ok {
return nil, errors.Errorf("expect string, got %T, hint: filter literals should be string", rawValue)
}
if variable != "create_time" {
return nil, errors.Errorf(`">=" and "<=" are only supported for "create_time"`)
}
t, err := time.Parse(time.RFC3339, value)
if err != nil {
return nil, errors.Errorf("failed to parse time %v, error: %v", value, err)
}
if functionName == celoperators.GreaterEquals {
return qb.Q().Space("created_at >= ?", t), nil
}
return qb.Q().Space("created_at <= ?", t), nil
default:
return nil, errors.Errorf("unexpected function %v", functionName)
}
default:
return nil, errors.Errorf("unexpected expr kind %v", expr.Kind())
}
}
q, err := getFilter(ast.NativeRep().Expr())
if err != nil {
return nil, errView on GitHub (pinned to 1870550677)
Solutions
- Send a full RFC3339 timestamp: 2024-01-01T00:00:00Z.
- Ensure the timezone offset is present (Z or ±hh:mm).
- In Go, format with time.RFC3339 or time.RFC3339Nano before embedding in the filter.
- In JS, use date.toISOString() which is RFC3339-compliant.
Example fix
// before filter := "create_time >= \"2024-01-01\"" // date only, parse fails // after filter := "create_time >= \"2024-01-01T00:00:00Z\"" // RFC3339
Defensive patterns
Strategy: validation
Validate before calling
const RFC3339 = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/;
if (!RFC3339.test(ts)) throw new Error(`create_time must be RFC3339, got ${ts}`); Try / catch
try { return await searchAuditLogs({ filter }); } catch (e) { if (String(e).includes("failed to parse time")) { throw new Error(`Format timestamps with toISOString()/RFC3339: ${ts}`); } throw e; } Prevention
- Validate timestamps with an RFC3339 regex before embedding
- Use date.toISOString() (JS) or t.Format(time.RFC3339) (Go)
- Never send date-only strings or epoch values
When it happens
Trigger: create_time values like "2024-01-01" (date only), "2024/01/01 00:00:00", epoch "1700000000", or timestamps missing timezone offset.
Common situations: Clients sending local date formats; JavaScript Date.toString() output; epoch milliseconds; forgetting the Z or +00:00 offset.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- expect string, got %T, hint: filter literals should be strin
- failed to parse time %v, error: %v
- invalid empty creator identifier
- CodeInvalidArgument
- invalid filter %q
AI-assisted analysis of bytebase/bytebase@1870550677 (2026-09-06).
Data as JSON: /api/errors/82fbc33df0ac7926.
Report an issue: GitHub.