grafana/k6 · error
filtering cookies
Error message
filtering cookies: %w
What it means
After cookies were successfully fetched, filterCookies could not match them against the provided URL arguments — specifically because one or more URLs failed to parse. The faulting input is the URLs passed to browserContext.cookies(...).
Solutions
- Pass fully-qualified URLs: cookies('https://example.com/path')
- Include the scheme; bare hostnames or malformed URLs fail parsing
- Call cookies() with no arguments to skip filtering
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/browser_context.go:560 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/45d45dc261151427.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/browser_context.go:560
// convert the received CDP cookies to the browser API format.
cookies := make([]*Cookie, len(networkCookies))
for i, c := range networkCookies {
cookies[i] = &Cookie{
Name: c.Name,
Value: c.Value,
Domain: c.Domain,
Path: c.Path,
Expires: int64(c.Expires),
HTTPOnly: c.HTTPOnly,
Secure: c.Secure,
SameSite: CookieSameSite(c.SameSite),
}
}
// filter cookies by the provided URLs.
cookies, err = filterCookies(cookies, urls...)
if err != nil {
return nil, fmt.Errorf("filtering cookies: %w", err)
}
if len(cookies) == 0 {
return nil, nil
}
return cookies, nil
}
// filterCookies filters the given cookies based on URLs.
// If an error occurs while parsing the cookie URLs, the error is returned.
func filterCookies(cookies []*Cookie, urls ...string) ([]*Cookie, error) {
if len(urls) == 0 || len(cookies) == 0 {
return cookies, nil
}
purls, err := parseURLs(urls...)
if err != nil {
return nil, fmt.Errorf("parsing urls: %w", err)View on GitHub (pinned to 01ffac6f24)