pete911 / hcr

helm chart releaser
MIT License
6 stars 2 forks source link

invalid memory address or nil pointer dereference #26

Closed maximemoreillon closed 1 year ago

maximemoreillon commented 1 year ago

Hello,

Thank you so much for creating this action! I tried it using the sample code provided in the README and unfortunately got the following error:

Run ./hcr -token "***"
2023-02-12T02:0[4](https://github.com/maximemoreillon/food-manager-helm-chart/actions/runs/4154171177/jobs/7186379011#step:5:5):4[5](https://github.com/maximemoreillon/food-manager-helm-chart/actions/runs/4154171177/jobs/7186379011#step:5:6).478826594Z    info    hcr/main.go:32  pages-branch: "gh-pages", charts-dir: "charts", pre-release: false, tag: "", remote: "origin", token: *****, dry-run: false, helm-config: sign: false, key: <empty>, keyring: <empty>, passphrase-file: <empty>
2023-02-12T02:04:45.479314992Z  info    git/client.go:120   /usr/bin/git ls-remote --heads origin
2023-02-12T02:04:45.[6](https://github.com/maximemoreillon/food-manager-helm-chart/actions/runs/4154171177/jobs/7186379011#step:5:7)43583[7](https://github.com/maximemoreillon/food-manager-helm-chart/actions/runs/4154171177/jobs/7186379011#step:5:8)57Z    info    hcr/releaser.go:172 found gh-pages github pages remote branch
2023-02-12T02:04:45.643612857Z  info    hcr/releaser.go:46  github pages remote branch exists
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x1e52ed[8](https://github.com/maximemoreillon/food-manager-helm-chart/actions/runs/4154171177/jobs/7186379011#step:5:9)]

goroutine 1 [running]:
github.com/pete[9](https://github.com/maximemoreillon/food-manager-helm-chart/actions/runs/4154171177/jobs/7186379011#step:5:10)11/hcr/internal/helm.Client.getChartsPaths.func1({0x227c391, 0x6}, {0x0, 0x0}, {0x0, 0x28ed60d})
    /home/runner/work/hcr/hcr/internal/helm/client.go:148 +0x38
path/filepath.WalkDir({0x227c391, 0x6}, 0xc00078f628)
    /opt/hostedtoolcache/go/1.17.[10](https://github.com/maximemoreillon/food-manager-helm-chart/actions/runs/4154171177/jobs/7186379011#step:5:11)/x64/src/path/filepath/path.go:467 +0x50
github.com/pete9[11](https://github.com/maximemoreillon/food-manager-helm-chart/actions/runs/4154171177/jobs/7186379011#step:5:12)/hcr/internal/helm.Client.getChartsPaths({0xb364281, 0x33836c0}, {0x227c391, 0x0})
    /home/runner/work/hcr/hcr/internal/helm/client.go:[14](https://github.com/maximemoreillon/food-manager-helm-chart/actions/runs/4154171177/jobs/7186379011#step:5:15)7 +0x58
github.com/pete911/hcr/internal/helm.Client.PackageCharts({0xc0002d4990, 0xc00030c180}, {0x227c391, 0x0})
    /home/runner/work/hcr/hcr/internal/helm/client.go:50 +0x53
github.com/pete911/hcr/internal/hcr.Releaser.Release({{0xc00030c180}, {0xc0003c9a20, 0xc00030c180}, {0xc0002d4990, 0xc00030c180}, {0xc0004cc6a8, 0x[17](https://github.com/maximemoreillon/food-manager-helm-chart/actions/runs/4154171177/jobs/7186379011#step:5:18)}, {0xc0002ceb70, 0x22}, {{0x227e78d, ...}, ...}, ...}, ...)
    /home/runner/work/hcr/hcr/internal/hcr/releaser.go:49 +0xce
main.main()
    /home/runner/work/hcr/hcr/main.go:38 +0x39f
Error: Process completed with exit code 2.

Am I doing something wrong?

pete911 commented 1 year ago

Hi @maximemoreillon, default charts dir flag is set to "charts", but your charts are located in "food-manager". I have added check if the the directory exists, so it should be much clearer what the error message is (just update to v0.0.7). You can either set charts-dir flag, or rename the directory where you keep charts.

Thanks for raising the issue (I have improved the checks), feel free to close this issue if it fixed your problem.

maximemoreillon commented 1 year ago

Hello @pete911, thanks so much for your quick answer and for the update! The new error message is now much easier to understand.

I reorganized my repo so that my chart is in the charts folder and this step is now working as expected so I will mark this issue as closed.

However, I am now getting a new error during the release step (still using the action from the readme):

2023-02-12T09:49:55.499687539Z  info    hcr/main.go:32  pages-branch: "gh-pages", charts-dir: "charts", pre-release: false, tag: "", remote: "origin", token: *****, dry-run: false, helm-config: sign: false, key: <empty>, keyring: <empty>, passphrase-file: <empty>
2023-02-12T09:49:55.49980423[7](https://github.com/maximemoreillon/food-manager-helm-chart/actions/runs/4155742356/jobs/7189052794#step:4:8)Z   info    git/client.go:120   /usr/bin/git ls-remote --heads origin
2023-02-12T09:49:55.[8](https://github.com/maximemoreillon/food-manager-helm-chart/actions/runs/4155742356/jobs/7189052794#step:4:9)63120208Z   info    hcr/releaser.go:172 found gh-pages github pages remote branch
2023-02-12T0[9](https://github.com/maximemoreillon/food-manager-helm-chart/actions/runs/4155742356/jobs/7189052794#step:4:10):49:55.863156208Z  info    hcr/releaser.go:46  github pages remote branch exists
2023-02-12T09:49:55.863245807Z  info    helm/client.go:84   start package charts/food-manager chart
2023-02-12T09:49:55.86457689Z   info    helm/client.go:89   chart charts/food-manager packaged as food-manager-0.1.4.tgz
2023-02-12T09:49:55.864823387Z  info    helm/client.go:94   chart food-manager loaded
2023-02-12T09:49:55.864832987Z  info    hcr/releaser.go:54  charts packaged
2023-02-12T09:49:55.864872187Z  info    git/client.go:120   /usr/bin/git remote update origin --prune
2023-02-12T09:49:56.216265806Z  info    git/client.go:120   /usr/bin/git worktree add /tmp/gh-pages30[10](https://github.com/maximemoreillon/food-manager-helm-chart/actions/runs/4155742356/jobs/7189052794#step:4:11)386328 origin/gh-pages
2023-02-[12](https://github.com/maximemoreillon/food-manager-helm-chart/actions/runs/4155742356/jobs/7189052794#step:4:13)T09:49:56.222497329Z  info    hcr/releaser.go:[15](https://github.com/maximemoreillon/food-manager-helm-chart/actions/runs/4155742356/jobs/7189052794#step:4:16)2 added github pages gh-pages worktree to /tmp/gh-pages3010386328
2023-02-12T09:49:56.222560928Z  info    git/client.go:120   /usr/bin/git remote get-url --push origin
2023-02-12T09:49:56.757042488Z  info    git/client.go:120   /usr/bin/git worktree remove /tmp/gh-pages3010386328 --force
2023-02-12T09:49:56.759040599Z  info    hcr/releaser.go:159 removed github pages gh-pages worktree /tmp/gh-pages3010386328
2023-02-12T09:49:56.759076899Z  info    helm/client.go:75   removed generated chart food-manager-0.1.4.tgz
2023-02-12T09:49:56.759086[19](https://github.com/maximemoreillon/food-manager-helm-chart/actions/runs/4155742356/jobs/7189052794#step:4:20)9Z  fatal   hcr/main.go:40  release: food-manager-0.1.4 create release 0.1.4: POST https://api.github.com/repos/maximemoreillon/food-manager-helm-chart/releases: 403 Resource not accessible by integration []
Error: Process completed with exit code 1.

Am I missing something else? Should I open a new issue about it?

pete911 commented 1 year ago

Hi @maximemoreillon, this is coming from github client, did you create and set github token - -token "${{ secrets.GITHUB_TOKEN }}"

maximemoreillon commented 1 year ago

@pete911 thanks so much for your reply!

I am using the .yml configuration from the readme so the token (if it exists) should be set.

- name: Package and release chart
  run: |
    git config user.email "gh-action@users.noreply.github.com"
    git config user.name "gh-action"
    ./hcr -token "${{ secrets.GITHUB_TOKEN }}"

I might have omitted to create it though. If so, I apologize.

However, I am puzzled as to why the original helm-releaser-action works without me having to do anything particular about it:

- name: Run chart-releaser
  uses: helm/chart-releaser-action@v1.5.0
  env:
    CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
pete911 commented 1 year ago

Hi @maximemoreillon, not sure why it is failing tbh, because the token is set (log returns ****, if it wasn't set it would log for the token). Plus the error is coming from github itself. Are you still facing the problem, or was it just one off error?

maximemoreillon commented 1 year ago

Hello @pete911 thanks a lot for your reply and sorry for getting back to you late.

The error was recurring so I switched to original helm-releaser-action for my workflows, sorry.