Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ BUG ] panic: runtime error: index out of range [1] with length 1 #124

Open
sOblivionsCall opened this issue May 18, 2021 · 8 comments
Open

Comments

@sOblivionsCall
Copy link

I have a CircleCi pipeline that triggers on commit to the main branch. CR is ran using docker with the latest tag:

version: 2
jobs:
  package-upload-index:
    docker:
      - image: quay.io/helmpack/chart-releaser
    steps:
      - checkout
      - run:
          name: package
          command: |
            charts=$(find . -maxdepth 1 -type d \( ! -name .git ! -name .deploy ! -name .circleci ! -name . \) -print)
            for chart in $charts
            do
              cr package $chart
            done
      - run:
          name: upload
          command: cr upload -o soblivionscall -r charts
      - run:
          name: index
          command: |
            apk add git
            cr index -i ./index.yaml -o soblivionscall -c https://soblivionscall.github.io/charts/ -r charts --push

workflows:
  version: 2
  release:
    jobs:
      - package-upload-index:
          filters:
            tags:
              ignore: /.*/
            branches:
              only: main

On the index step i am seeing:

#!/bin/sh -eo pipefail
apk add git
cr index -i ./index.yaml -o soblivionscall -c https://soblivionscall.github.io/charts/ -r charts --push

fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/community/x86_64/APKINDEX.tar.gz
  0%                                             OK: 19 MiB in 21 packages
Using existing index at ./index.yaml
Found speedtest-tracker-3.0.0.tgz
Extracting chart metadata from .cr-release-packages/speedtest-tracker-3.0.0.tgz
Calculating Hash for .cr-release-packages/speedtest-tracker-3.0.0.tgz
Updating index ./index.yaml
Preparing worktree (detached HEAD dcc0111)
HEAD is now at dcc0111 Update index.yaml
[detached HEAD 18158f7] Update index.yaml
 Author: root <***********************>
 1 file changed, 11 insertions(+), 1 deletion(-)
panic: runtime error: index out of range [1] with length 1

goroutine 1 [running]:
github.com/helm/chart-releaser/pkg/git.(*Git).GetPushURL(0x27634b0, 0x1a14a7f, 0x6, 0xc000046189, 0x28, 0x0, 0x0, 0x0, 0x0)
	/home/runner/work/chart-releaser/chart-releaser/pkg/git/git.go:80 +0x2dd
github.com/helm/chart-releaser/pkg/releaser.(*Releaser).UpdateIndexFile(0xc000e7dd50, 0x0, 0x0, 0x0)
	/home/runner/work/chart-releaser/chart-releaser/pkg/releaser/releaser.go:223 +0xf78
github.com/helm/chart-releaser/cr/cmd.glob..func1(0x27069a0, 0xc0003f5b90, 0x0, 0x9, 0x0, 0x0)
	/home/runner/work/chart-releaser/chart-releaser/cr/cmd/index.go:40 +0x217
github.com/spf13/cobra.(*Command).execute(0x27069a0, 0xc0003f5b00, 0x9, 0x9, 0x27069a0, 0xc0003f5b00)
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:852 +0x47c
github.com/spf13/cobra.(*Command).ExecuteC(0x2706ea0, 0x0, 0x0, 0x0)
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:960 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:897
github.com/helm/chart-releaser/cr/cmd.Execute()
	/home/runner/work/chart-releaser/chart-releaser/cr/cmd/root.go:35 +0x2d
main.main()
	/home/runner/work/chart-releaser/chart-releaser/cr/main.go:20 +0x25

Exited with code exit status 2

CircleCI received exit code 2

Obviously it's an issue with an out of bounds index but i don't know what index it is referring to. This pipeline has ran flawlessly for months without any changes so i'm fairly certain it's not something i did. Can anyone provide some insight as to what might be going on?

@sOblivionsCall
Copy link
Author

Can confirm this is a bug in the latest tag of the docker container and most likely the v1.2.1 tag as they appear to have been uploaded at the same time.

https://quay.io/repository/helmpack/chart-releaser?tab=tags

My issue was resolved by using the 1.2.0 tag. Will leave this issue open for tracking and debugging by the devs but i am no longer blocked.

@cpanato
Copy link
Member

cpanato commented May 19, 2021

thanks, @sOblivionsCall for the report, I don't have time this week to look over this, but I can try in my weekend, I need to set up an env for that.
meanwhile if you want to submit a PR we thank you in advance

@cpanato
Copy link
Member

cpanato commented May 29, 2021

hello @sOblivionsCall sorry for the delay

I was able to reproduce this issue only when my remote was configured as ssh like (git@github.com:cpanato/charts.git) then I got the exact error, when I convert that to be https (https://github.com/cpanato/charts.git) it worked

can you check how your remote looks like? for ssh it will not work, the chart-releaser expect a HTTPS remote + token

@pratikbin
Copy link

pratikbin commented Jun 2, 2021

Ran into same issue in my CI so add little workaround which will set https for only cr index step if repo remote is SSH and then undo it

    [[ $(git config --get remote.origin.url) == *"git@github.com"* ]] && \
    SSH_REPO=true && \
    PROJECT_USERNAME=$(git config --get remote.origin.url | sed 's/git\@github\.com\:\|\.git\|https\:\/\/github\.com\///g' | awk -F\/ '{printf $1}') && \
    PROJECT_REPONAME=$(git config --get remote.origin.url | sed 's/git\@github\.com\:\|\.git\|https\:\/\/github\.com\///g' | awk -F\/ '{printf $2}')

    [[ ${SSH_REPO} == *"true"* ]] && \
      git remote set-url origin https://github.com/${PROJECT_USERNAME}/${PROJECT_REPONAME}
    cr index --push
    [[ ${SSH_REPO} == *"true"* ]] && \
      git remote set-url origin git@github.com:${PROJECT_USERNAME}/${PROJECT_REPONAME}.git

@cpanato
Copy link
Member

cpanato commented Jun 2, 2021

the chart release expect the remote to be HTTPS and not SSH

@pratikbin
Copy link

pratikbin commented Jun 2, 2021

This will set https for only cr index step if repo remote is SSH and then won't do it

@RobbieMcKinstry
Copy link

Experiencing the same bug.
The problem seems to be these lines here assume the origin uses https:// and not git://. To reproduce, set the origin to use something like git@github.com:MyOrganization/MyRepository and run cr index with the other parameters set as usual.
Possible Workaround (not confirmed): Edit your remote to use HTTPS instead.

TylerHelmuth added a commit to honeycombio/helm-charts that referenced this issue May 23, 2023
## Which problem is this PR solving?

With the bump to chart releaser 1.5.0 we lost the ability to do `cr
index` with an `ssh` git remote; the tool now requires us to use an
`https` remote. For the `v1.2.3-secure-tenancy` release I had to do the
`cr index` step manually from my laptop. See and
helm/chart-releaser#124.

The PR solves this problem and also removes some deprecated flags and
unused env vars.

## Short description of the changes

- set git remote to https url for `cr index` step.
- remove unused `--charts-repo` flag
- remove unused variables.

## How to verify that this has the expected result

I couldn't :/ but I'll try to do a honeycomb chart release once this is
merged to test it.
@poelzi
Copy link

poelzi commented Aug 21, 2023

Hit this as well. Needed to read source code to find out what the problem is....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants