kooky icon indicating copy to clipboard operation
kooky copied to clipboard

TraverseCookies on Firefox yielding nil, nil

Open jf-uu opened this issue 6 months ago • 1 comments

Checklist

  • [x] I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • [x] This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

TraverseCookies is yielding nil, nil.

How to reproduce

Run the below example code.

Example code

package main

import (
	"context"
	"errors"
	"io/fs"

	"github.com/browserutils/kooky"
	_ "github.com/browserutils/kooky/browser/firefox"
)

func main() {
	for _, store := range kooky.FindAllCookieStores(context.Background()) {
		if store.Browser() == "firefox" {
			for cookie, err := range store.TraverseCookies(kooky.Valid, kooky.DomainHasSuffix(".bandcamp.com")) {
				if errors.Is(err, fs.ErrNotExist) {
					break
				} else if err != nil {
					panic(err)
				}
				if cookie == nil {
					panic("nil cookie")
				}
			}
		}
	}
}

Kooky version

v0.2.4

Go compiler version

1.24.5

Browser

Firefox 141.0

Operating system and version

macOS Sequoia 15.5

jf-uu avatar Aug 08 '25 12:08 jf-uu

From what I can tell, a missing nil check on err here is the cause: https://github.com/browserutils/kooky/blob/aa53ea57e56c5b6e6b400f0a0b4039a47411d901/internal/firefox/firefox.go#L119-L122

Changing this to if err != nil && !errors.Is(err, iterx.ErrYieldEnd) appears to fix the issue.

jf-uu avatar Aug 08 '25 12:08 jf-uu