{"record":{"id":"45d45dc261151427","repo":"grafana/k6","slug":"filtering-cookies-w","errorCode":null,"errorMessage":"filtering cookies: %w","messagePattern":"filtering cookies: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/browser_context.go","lineNumber":560,"sourceCode":"\n\t// convert the received CDP cookies to the browser API format.\n\tcookies := make([]*Cookie, len(networkCookies))\n\tfor i, c := range networkCookies {\n\t\tcookies[i] = &Cookie{\n\t\t\tName:     c.Name,\n\t\t\tValue:    c.Value,\n\t\t\tDomain:   c.Domain,\n\t\t\tPath:     c.Path,\n\t\t\tExpires:  int64(c.Expires),\n\t\t\tHTTPOnly: c.HTTPOnly,\n\t\t\tSecure:   c.Secure,\n\t\t\tSameSite: CookieSameSite(c.SameSite),\n\t\t}\n\t}\n\t// filter cookies by the provided URLs.\n\tcookies, err = filterCookies(cookies, urls...)\n\tif err != nil {\n\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)","sourceCodeStart":542,"sourceCodeEnd":578,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/common/browser_context.go#L542-L578","documentation":"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(...).","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/browser_context.go:560 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"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"}