cecobask / imdb-trakt-sync

Automatic sync from IMDb to Trakt (watchlist, lists, ratings and history) using GitHub actions.
MIT License
91 stars 216 forks source link

Lists parser crushes when loading people lists #56

Closed keystroke3 closed 2 months ago

keystroke3 commented 2 months ago

I was performing a dry-run sync my account, which happens to have a list of people in it, and I got this stack trace:

...
panic: runtime error: index out of range [8] with length 8
goroutine 1 [running]:
github.com/cecobask/imdb-trakt-sync/pkg/client.transformListData({0xc00020e200, 0x12d, 0x200})
    /home/salvaje/dev/imdb-trakt-sync/pkg/client/imdb.go:569 +0x471
github.com/cecobask/imdb-trakt-sync/pkg/client.(*IMDbClient).listDownload(0xc000012438, 0xc000576840)
    /home/salvaje/dev/imdb-trakt-sync/pkg/client/imdb.go:326 +0x305
github.com/cecobask/imdb-trakt-sync/pkg/client.(*IMDbClient).ListsGet(0xc000012438, {0xc0000240c0, 0x2, 0x2})
    /home/salvaje/dev/imdb-trakt-sync/pkg/client/imdb.go:250 +0x2a7
github.com/cecobask/imdb-trakt-sync/internal/syncer.(*Syncer).hydrate(0xc00009cb40)
    /home/salvaje/dev/imdb-trakt-sync/internal/syncer/syncer.go:103 +0x2b9
github.com/cecobask/imdb-trakt-sync/internal/syncer.(*Syncer).Sync(0xc00009cb40)
    /home/salvaje/dev/imdb-trakt-sync/internal/syncer/syncer.go:63 +0x65
github.com/cecobask/imdb-trakt-sync/cmd/sync.NewCommand.func2(0xc00029e100?, {0xb4ee86?, 0x4?, 0xb4ee8a?})
    /home/salvaje/dev/imdb-trakt-sync/cmd/sync/sync.go:39 +0xc8
github.com/spf13/cobra.(*Command).execute(0xc00028e908, {0x13d7fc0, 0x0, 0x0})
    /home/salvaje/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:985 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0xc00028e008)
    /home/salvaje/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1117 +0x3ff
github.com/spf13/cobra.(*Command).Execute(0xede0b0?)
    /home/salvaje/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1041 +0x13
main.main()
    /home/salvaje/dev/imdb-trakt-sync/main.go:15 +0x85
make: *** [Makefile:10: sync] Error 2

Some quick debugging revealed the csv that trasformListData is trying to process looks like this:

Position,Const,Created,Modified,Description,Name,Known For,Birth Date
1,nm2948025,2019-02-05,2019-02-05,,"Aimee Carrero","The Menu","July 15, 1988"

The csv only has 8 items, hence the index out of range panic.

A temporary solution is to identify a People List and skip it. Since Trakt supports People lists, we should probably add an option to sync people as a permanent solution down the line

Here is the trace

cecobask commented 2 months ago

Hi @keystroke3, thanks a lot for your contribution! I hadn't considered that use case before. A more permanent solution is on the way!