In playwright.go:138-153, updateCookies() calls page.Context().Cookies(page.URL()) and assigns both cookies and err, but err is not checked before iterating cookies:
func(bplayWrightBrowser)updateCookies(_context.Context,pageplaywright.Page)error{ifb.cookieJar!=nil{cookies,err:=page.Context().Cookies(page.URL())// BUG: err is not checked here — if Cookies() fails, cookies may be nil/empty// and err is only used in the loop below for Set()for_,cookie:=rangecookies{err=b.cookieJar.Set(playwrightCookieToCookie(cookie))iferr!=nil{returnfmt.Errorf("error setting cookie in cookie jar: %w",err)}}}returnnil}
If Cookies() returns an error, it's silently swallowed and the cookie jar won't be updated.
Fix
Add if err != nil { return fmt.Errorf("error getting cookies: %w", err) } after the Cookies() call.
**Parent:** #1
## Description
In `playwright.go:138-153`, `updateCookies()` calls `page.Context().Cookies(page.URL())` and assigns both `cookies` and `err`, but `err` is not checked before iterating `cookies`:
```go
func (b playWrightBrowser) updateCookies(_ context.Context, page playwright.Page) error {
if b.cookieJar != nil {
cookies, err := page.Context().Cookies(page.URL())
// BUG: err is not checked here — if Cookies() fails, cookies may be nil/empty
// and err is only used in the loop below for Set()
for _, cookie := range cookies {
err = b.cookieJar.Set(playwrightCookieToCookie(cookie))
if err != nil {
return fmt.Errorf("error setting cookie in cookie jar: %w", err)
}
}
}
return nil
}
```
If `Cookies()` returns an error, it's silently swallowed and the cookie jar won't be updated.
## Fix
Add `if err != nil { return fmt.Errorf("error getting cookies: %w", err) }` after the `Cookies()` call.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Parent: #1
Description
In
playwright.go:138-153,updateCookies()callspage.Context().Cookies(page.URL())and assigns bothcookiesanderr, buterris not checked before iteratingcookies:If
Cookies()returns an error, it's silently swallowed and the cookie jar won't be updated.Fix
Add
if err != nil { return fmt.Errorf("error getting cookies: %w", err) }after theCookies()call.Starting work on this as part of PR 6 (also includes #18). Will add error check for
page.Context().Cookies()inplaywright.go:140.Work finished. PR: #37 (merged)
Added error check for
page.Context().Cookies()before iterating.