grafana/k6 · error
unable to parse "expires" date string "%s": %w
Error message
unable to parse "expires" date string "%s": %w
What it means
In the http cookiejar Set method, an expires parameter that is non-empty must parse as time.RFC1123; this error wraps time.Parse's failure for a malformed date string (e.g. "tomorrow" or missing GMT). The cookie is not set and the error propagates to the script.
Source
Thrown at js/modules/k6/http/cookiejar.go:69
}
c := http.Cookie{Name: name, Value: value}
paramsV := opts
if !common.IsNullish(paramsV) {
params := paramsV.ToObject(rt)
for _, k := range params.Keys() {
switch strings.ToLower(k) {
case "path":
c.Path = params.Get(k).String()
case "domain":
c.Domain = params.Get(k).String()
case "expires":
var t time.Time
expires := params.Get(k).String()
if expires != "" {
t, err = time.Parse(time.RFC1123, expires)
if err != nil {
return false, fmt.Errorf(`unable to parse "expires" date string "%s": %w`, expires, err)
}
}
c.Expires = t
case "max_age":
c.MaxAge = int(params.Get(k).ToInteger())
case "secure":
c.Secure = params.Get(k).ToBoolean()
case "http_only":
c.HttpOnly = params.Get(k).ToBoolean()
}
}
}
j.Jar.SetCookies(u, []*http.Cookie{&c})
return true, nil
}
// Clear all cookies for a particular URL
func (j CookieJar) Clear(url string) error {View on GitHub (pinned to 01ffac6f24)
Solutions
- Provide expires in RFC 1123 format, e.g. 'Wed, 21 Oct 2026 07:28:00 GMT'
- Or pass a Date object / omit expires for a session cookie
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at js/modules/k6/http/cookiejar.go:69 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/8990451fd0a359fb.
Report an issue: GitHub.