grafana/k6 · error
parsing urls
Error message
parsing urls: %w
What it means
Inside filterCookies, parseURLs failed to net/url.Parse one of the URL strings passed to cookies(...). The invalid URL itself is identified by the wrapped error. This is purely input validation on the user-supplied URL list.
Solutions
- Correct or remove malformed URLs from the cookies() call
- URL-encode spaces and special characters in paths
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/browser_context.go:578 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/abe71e079c8201e6.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/browser_context.go:578
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)
}
// the following algorithm is like a sorting algorithm,
// but instead of sorting, it filters the cookies slice
// in place, without allocating a new slice. this is
// done to avoid unnecessary allocations and copying
// of data.
//
// n is used to remember the last cookie that should be
// kept in the cookies slice. all cookies before n should
// be kept, all cookies after n should be removed. it
// constantly shifts cookies to be kept to the left in the
// slice, overwriting cookies that should be removed.
//
// if a cookie should not be kept, it will be overwritten
// by the next cookie that should be kept. if no cookies
// should be kept, a nil slice is returned. otherwise,
// the slice is truncated to the last cookie that shouldView on GitHub (pinned to 01ffac6f24)