{"record":{"id":"abe71e079c8201e6","repo":"grafana/k6","slug":"parsing-urls-w","errorCode":null,"errorMessage":"parsing urls: %w","messagePattern":"parsing urls: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/browser_context.go","lineNumber":578,"sourceCode":"\t\treturn nil, fmt.Errorf(\"filtering cookies: %w\", err)\n\t}\n\tif len(cookies) == 0 {\n\t\treturn nil, nil\n\t}\n\n\treturn cookies, nil\n}\n\n// filterCookies filters the given cookies based on URLs.\n// If an error occurs while parsing the cookie URLs, the error is returned.\nfunc filterCookies(cookies []*Cookie, urls ...string) ([]*Cookie, error) {\n\tif len(urls) == 0 || len(cookies) == 0 {\n\t\treturn cookies, nil\n\t}\n\n\tpurls, err := parseURLs(urls...)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"parsing urls: %w\", err)\n\t}\n\n\t// the following algorithm is like a sorting algorithm,\n\t// but instead of sorting, it filters the cookies slice\n\t// in place, without allocating a new slice. this is\n\t// done to avoid unnecessary allocations and copying\n\t// of data.\n\t//\n\t// n is used to remember the last cookie that should be\n\t// kept in the cookies slice. all cookies before n should\n\t// be kept, all cookies after n should be removed. it\n\t// constantly shifts cookies to be kept to the left in the\n\t// slice, overwriting cookies that should be removed.\n\t//\n\t// if a cookie should not be kept, it will be overwritten\n\t// by the next cookie that should be kept. if no cookies\n\t// should be kept, a nil slice is returned. otherwise,\n\t// the slice is truncated to the last cookie that should","sourceCodeStart":560,"sourceCodeEnd":596,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/common/browser_context.go#L560-L596","documentation":"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.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/browser_context.go:578 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Correct or remove malformed URLs from the cookies() call","URL-encode spaces and special characters in paths"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}