{"record":{"id":"fe915455f435368b","repo":"gocolly/colly","slug":"errnocookiejar","errorCode":"ErrNoCookieJar","errorMessage":"Cookie jar is not available","messagePattern":"Cookie jar is not available","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"colly.go","lineNumber":238,"sourceCode":"var (\n\t// ErrForbiddenDomain is the error thrown if visiting\n\t// a domain which is not allowed in AllowedDomains\n\tErrForbiddenDomain = errors.New(\"Forbidden domain\")\n\t// ErrMissingURL is the error type for missing URL errors\n\tErrMissingURL = errors.New(\"Missing URL\")\n\t// ErrMaxDepth is the error type for exceeding max depth\n\tErrMaxDepth = errors.New(\"Max depth limit reached\")\n\t// ErrForbiddenURL is the error thrown if visiting\n\t// a URL which is not allowed by URLFilters\n\tErrForbiddenURL = errors.New(\"ForbiddenURL\")\n\n\t// ErrNoURLFiltersMatch is the error thrown if visiting\n\t// a URL which is not allowed by URLFilters\n\tErrNoURLFiltersMatch = errors.New(\"No URLFilters match\")\n\t// ErrRobotsTxtBlocked is the error type for robots.txt errors\n\tErrRobotsTxtBlocked = errors.New(\"URL blocked by robots.txt\")\n\t// ErrNoCookieJar is the error type for missing cookie jar\n\tErrNoCookieJar = errors.New(\"Cookie jar is not available\")\n\t// ErrNoPattern is the error type for LimitRules without patterns\n\tErrNoPattern = errors.New(\"No pattern defined in LimitRule\")\n\t// ErrEmptyProxyURL is the error type for empty Proxy URL list\n\tErrEmptyProxyURL = errors.New(\"Proxy URL list is empty\")\n\t// ErrAbortedAfterHeaders is the error returned when OnResponseHeaders aborts the transfer.\n\tErrAbortedAfterHeaders = errors.New(\"Aborted after receiving response headers\")\n\t// ErrAbortedBeforeRequest is the error returned when OnResponseHeaders aborts the transfer.\n\tErrAbortedBeforeRequest = errors.New(\"Aborted before Do Request\")\n\t// ErrQueueFull is the error returned when the queue is full\n\tErrQueueFull = errors.New(\"Queue MaxSize reached\")\n\t// ErrMaxRequests is the error returned when exceeding max requests\n\tErrMaxRequests = errors.New(\"Max Requests limit reached\")\n\t// ErrRetryBodyUnseekable is the error when retry with not seekable body\n\tErrRetryBodyUnseekable = errors.New(\"Retry Body Unseekable\")\n)\n\nvar envMap = map[string]func(*Collector, string){\n\t\"ALLOWED_DOMAINS\": func(c *Collector, val string) {","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/gocolly/colly/blob/17d1d6ca92bd32a5651f34256bf7a2855c967f65/colly.go#L220-L256","documentation":"ErrNoCookieJar is returned when the collector is configured with cookies (e.g. c.SetCookies or cookie-dependent flows) but no cookie jar has been attached via c.SetCookieJar. Colly does not install a default jar; without one it cannot store or send cookies, so cookie operations fail with this error.","triggerScenarios":"Calling c.SetCookies(u, cookies) (or relying on automatic cookie persistence) before calling c.SetCookieJar(jar); creating a collector and doing authenticated multi-request flows without attaching a jar; copying collector config but dropping the jar assignment.","commonSituations":"Login-then-scrape flows where the session cookie must persist between requests; reusing http.Client cookie jars across collectors incorrectly; forgetting that Colly's default collector has no jar even though net/http clients often do.","solutions":["Attach a jar before any cookie-dependent call: c.SetCookieJar(jar)","Use a standard jar: jar, _ := cookiejar.New(nil); c.SetCookieJar(jar)","If cookies are unnecessary, avoid SetCookies/cookie APIs entirely","If you rely on an underlying http.Client, ensure the jar is set on that client and passed to the collector"],"exampleFix":"// before\nc := colly.NewCollector()\nc.SetCookies(u, cookies) // ErrNoCookieJar\n// after\nimport \"net/http/cookiejar\"\n\nc := colly.NewCollector()\njar, _ := cookiejar.New(nil)\nc.SetCookieJar(jar)\nc.SetCookies(u, cookies)","handlingStrategy":"validation","validationCode":"jar, err := cookiejar.New(nil)\nif err != nil {\n    return err\n}\nc.SetCookieJar(jar) // do this before any cookie-dependent call","typeGuard":null,"tryCatchPattern":"if err := c.SetCookies(u, cookies); err != nil && errors.Is(err, colly.ErrNoCookieJar) {\n    jar, _ := cookiejar.New(nil)\n    c.SetCookieJar(jar)\n    return c.SetCookies(u, cookies)\n}","preventionTips":["Always attach a cookiejar in collector bootstrap code","Set the jar before any login/cookie flows, not on demand","If using a custom http.Client, share its jar with the collector"],"tags":["colly","scraping","cookies","session","go"],"backgroundTag":"missing-cookie-jar","analyzedSha":"17d1d6ca92bd32a5651f34256bf7a2855c967f65","analyzedAt":"2026-08-30T21:32:31.579Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}