cooperspencer / gickup

https://cooperspencer.github.io/gickup-documentation/
Apache License 2.0
972 stars 35 forks source link

invalid memory address or nil pointer #222

Closed Aetherinox closed 5 months ago

Aetherinox commented 6 months ago

Just wanted to give you a heads up and maybe see if there's a way to solve this issue.

I updated gickup today, and it immediately failed to start. It has been running for six months without fail.

2024-04-03T04:03:30Z INF Reading /gickup/conf.yml file=/gickup/conf.yml
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xd8 pc=0xc22e84]

goroutine 1 [running]:
main.readConfigFile({0xc0002189f0, 0x10})

    /go/src/github.com/cooperspencer/gickup/main.go:86 +0x564

main.main()

    /go/src/github.com/cooperspencer/gickup/main.go:629 +0xaa5

2024-04-03T04:04:14Z INF Reading /gickup/conf.yml file=/gickup/conf.yml
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xd8 pc=0xc22e84]

So I went searching, and luckily, I ran across this post

which recommended removing the dashes at the bottom:

---

# you can define separate source and destination pairs,
# like "mirror all repos from github to gitea but keep gitlab repos up-to-date in ~/backup"
# if cron is defined in the first config, this cron interval will be used for all the other confgurations, except it has one of its own.
# if cron is not enabled for the first config, cron will not run for any other configuration

And now it works fine. Had it not been for that posted issue, would never have found that; and I think that is included in the config by default. Definitely not something I've added.

cooperspencer commented 6 months ago

Thanks a lot for this issue. I'll look into this because there must be something I can do about this.

Aetherinox commented 6 months ago

Appreciate it. Honestly it could probably be removed and just make sure it's in the repo readme / your docs subdomain. People shouldn't be just ignoring the readme when they're trying to configure things.

Then again, I'm also a developer; and I know that people absolutely hate reading, and they'll open an issue even with the answer in front of their face.

cooperspencer commented 6 months ago

I think I found a fairly easy fix for that. https://github.com/cooperspencer/gickup/pull/223

I just check if the config is nil and ignore it if it's the case.

This was my test configuration:

---

source:
  github:
    - user: cooperspencer

destination:
  local:
    - path: ~/backup/
      lfs: True
      structured: True

---

---

source:
  github:
    - user: kubernetes

destination:
  local:
    - path: ~/backup
      structured: True

---
Aetherinox commented 6 months ago

Nice, that'll work great. Straight forward.

It's weird, not sure what has changed, but I've used that same config for a long time now. Gickup is pretty much a "set it and forget it" app which is nice, but after yesterday's update, that's the first time I've ever had the issue.

And I'm using docker if that makes any difference.

Appreciate you looking into it.

cooperspencer commented 6 months ago

I implemented the option to add multiple configs in the same yaml file at some point. That's what caused this issue for you. Sorry for that.

Aetherinox commented 6 months ago

No need to be sorry, stuff happens.

Do appreciate you looking into it.

cooperspencer commented 5 months ago

I pushed a new release withe the fix