todoist: Cannot sync: runtime error - invalid memory address or nil pointer dereference

My OS: Ubuntu 22.04.2 LTS

When running the most recent binary, I cannot sync. I had the same problem on the previous 2 binaries. Am I doing something wrong? If not: I have a large amount of projects and tasks in my todoist. Could this be a problem?

I ran the following commands:

$ wget https://github.com/sachaos/todoist/releases/download/v0.19.0/todoist_linux_amd64
$ mv todoist_linux_amd64 todoist
$ chmod +x todoist 
$ ./todoist sync

Resulted in:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x60 pc=0x6b6211]

goroutine 1 [running]:
github.com/sachaos/todoist/lib.addToChildItem(...)
	/Users/tsakao/dev/src/github.com/sachaos/todoist/lib/sync.go:99
github.com/sachaos/todoist/lib.(*Store).ConstructItemTree(0xc000129c00)
	/Users/tsakao/dev/src/github.com/sachaos/todoist/lib/sync.go:176 +0x2f1
github.com/sachaos/todoist/lib.(*Client).Sync(0xc00013af00, {0x930d28, 0xc000126000})
	/Users/tsakao/dev/src/github.com/sachaos/todoist/lib/todoist.go:116 +0x1df
main.Sync(0xc0001731e0?)
	/Users/tsakao/dev/src/github.com/sachaos/todoist/sync.go:12 +0x6a
github.com/urfave/cli/v2.(*Command).Run(0xc0001731e0, 0xc00013af40, {0xc0001972c0, 0x1, 0x1})
	/Users/tsakao/go/pkg/mod/github.com/urfave/cli/v2@v2.25.1/command.go:274 +0xa42
github.com/urfave/cli/v2.(*Command).Run(0xc000173600, 0xc00013a880, {0xc00013c000, 0x2, 0x2})
	/Users/tsakao/go/pkg/mod/github.com/urfave/cli/v2@v2.25.1/command.go:267 +0xc8a
github.com/urfave/cli/v2.(*App).RunContext(0xc0001fe000, {0x930d28?, 0xc000126000}, {0xc00013c000, 0x2, 0x2})
	/Users/tsakao/go/pkg/mod/github.com/urfave/cli/v2@v2.25.1/app.go:332 +0x605
github.com/urfave/cli/v2.(*App).Run(...)
	/Users/tsakao/go/pkg/mod/github.com/urfave/cli/v2@v2.25.1/app.go:309
main.main()
	/Users/tsakao/dev/src/github.com/sachaos/todoist/main.go:345 +0x1f0d

I get the same error when cloning the repository and building it myself:

todoist sync
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x60 pc=0x6ba5d1]

goroutine 1 [running]:
github.com/sachaos/todoist/lib.addToChildItem(...)
	/home/user/go/src/github.com/sachaos/todoist/lib/sync.go:99
github.com/sachaos/todoist/lib.(*Store).ConstructItemTree(0xc0000d5c00)
	/home/user/go/src/github.com/sachaos/todoist/lib/sync.go:176 +0x2f1
github.com/sachaos/todoist/lib.(*Client).Sync(0xc0000baf00, {0x936440, 0xc0000240c0})
	/home/user/go/src/github.com/sachaos/todoist/lib/todoist.go:116 +0x1df
main.Sync(0xc000193340?)
	/home/user/go/src/github.com/sachaos/todoist/sync.go:12 +0x6a
github.com/urfave/cli/v2.(*Command).Run(0xc000193340, 0xc0000baf40, {0xc00021f2f0, 0x1, 0x1})
	/home/user/go/pkg/mod/github.com/urfave/cli/v2@v2.25.1/command.go:274 +0xa42
github.com/urfave/cli/v2.(*Command).Run(0xc000193760, 0xc0000ba880, {0xc000020040, 0x2, 0x2})
	/home/user/go/pkg/mod/github.com/urfave/cli/v2@v2.25.1/command.go:267 +0xc8a
github.com/urfave/cli/v2.(*App).RunContext(0xc0000001e0, {0x936440?, 0xc0000240c0}, {0xc000020040, 0x2, 0x2})
	/home/user/go/pkg/mod/github.com/urfave/cli/v2@v2.25.1/app.go:332 +0x605
github.com/urfave/cli/v2.(*App).Run(...)
	/home/user/go/pkg/mod/github.com/urfave/cli/v2@v2.25.1/app.go:309
main.main()

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 18 (6 by maintainers)

Most upvoted comments

My guess is that this is due to some behavior that was there in the past (back in 2021) that was since fixed by Todoist. It probably wouldn’t hurt for us to add some assertions in the code to check for this so that if it does happen to other users they know what to do – there are a couple of other bug reports here in GitHub where people reported sync issues, and I wonder if they have the same cause.

Some extra information, in case this might be useful: I have only used the API/CLI for adding tasks, never for completing. So this completion was done via either the official web-client or the (iphone) app. Also: this list is shared with several other todoist accounts. This particular item was added on ‘1 Dec 2021 · 10:09 AM’ and probably completed a few days later (most likely by some other todoist-account with whom this project was shared, I can check, but the ‘load more history’ button goes back 1 week at a time, so I would rather not since that is going to take some time😁).

I can say for pretty much certain you cannot reproduce this exact scenario with the web or desktop client (under normal network conditions). One thing I missed at an initial glance was the 7/7 completed subtasks, but there is the obvious 8th item that is not marked complete. I will say that it’s possible to have a parent task complete with subtasks not complete and that’s handled fine. The main distinction here is the count displayed.

I’ll play around with the API directly to see if can reproduce the task that way.

Good point, I forgot it dumps the API calls, which include your sync key. My mistake there. That should probably be fixed, haha!

I’ll see if I can reproduce your data set here to see if I can at least reproduce the crash. I don’t think that’s an impossible scenario.

Unrelated, I’m really curious what you were making with spinach and smoked chicken, haha!