Index out of range error when syncing recipe with no version found #732

Closed
opened 2025-12-13 04:02:17 +00:00 by jade · 3 comments
Member

To reproduce:

You need a recipe that does not have any correctly setup versions. I encountered this when trying to setup my new kiwix recipe. Then, run abra recipe sync kiwix. The console result is:

➜  kiwix git:(main) abra recipe sync kiwix
panic: runtime error: index out of range [-1]

goroutine 1 [running]:
coopcloud.tech/abra/cli/recipe.init.func15(0xc000644900?, {0xc000057b70, 0x1, 0x1})
	/home/d1/hack/abra/cli/recipe/sync.go:137 +0x1685
github.com/spf13/cobra.(*Command).execute(0x1dbf3e0, {0xc000057b50, 0x1, 0x1})
	/home/d1/hack/abra/vendor/github.com/spf13/cobra/command.go:1019 +0xae7
github.com/spf13/cobra.(*Command).ExecuteC(0xc000632608)
	/home/d1/hack/abra/vendor/github.com/spf13/cobra/command.go:1148 +0x465
github.com/spf13/cobra.(*Command).Execute(...)
	/home/d1/hack/abra/vendor/github.com/spf13/cobra/command.go:1071
coopcloud.tech/abra/cli.Run({0x14bc528, 0xb}, {0x14cd800, 0x28})
	/home/d1/hack/abra/cli/run.go:317 +0x1195
main.main()
	/home/d1/hack/abra/cmd/abra/main.go:22 +0xa9

The problem

The failure occurs in the line latestRelease := tags[len(tags)-1] with the specified index being -1. This means that len(tags) must be 0.

The proximate solution is that there should be some check immediately before that to assert that there are tags.

However, note that there is code that is intended to handle this case on line 80. if len(tags) == 0 && nextTag == "" {. While this if statement doesn't wrap the failing code on like 137, it should output a warning in the case of no tags. Perhaps len(tags) is zero and yet nextTag is not ""?

## To reproduce: You need a recipe that does not have any correctly setup versions. I encountered this when trying to setup my new `kiwix` recipe. Then, run `abra recipe sync kiwix`. The console result is: ``` ➜ kiwix git:(main) abra recipe sync kiwix panic: runtime error: index out of range [-1] goroutine 1 [running]: coopcloud.tech/abra/cli/recipe.init.func15(0xc000644900?, {0xc000057b70, 0x1, 0x1}) /home/d1/hack/abra/cli/recipe/sync.go:137 +0x1685 github.com/spf13/cobra.(*Command).execute(0x1dbf3e0, {0xc000057b50, 0x1, 0x1}) /home/d1/hack/abra/vendor/github.com/spf13/cobra/command.go:1019 +0xae7 github.com/spf13/cobra.(*Command).ExecuteC(0xc000632608) /home/d1/hack/abra/vendor/github.com/spf13/cobra/command.go:1148 +0x465 github.com/spf13/cobra.(*Command).Execute(...) /home/d1/hack/abra/vendor/github.com/spf13/cobra/command.go:1071 coopcloud.tech/abra/cli.Run({0x14bc528, 0xb}, {0x14cd800, 0x28}) /home/d1/hack/abra/cli/run.go:317 +0x1195 main.main() /home/d1/hack/abra/cmd/abra/main.go:22 +0xa9 ``` ## The problem The failure occurs in the line `latestRelease := tags[len(tags)-1]` with the specified index being `-1`. This means that `len(tags)` must be `0`. The proximate solution is that there should be some check immediately before that to assert that there are tags. However, note that there is code that is intended to handle this case on line 80. `if len(tags) == 0 && nextTag == "" {`. While this if statement doesn't wrap the failing code on like 137, it should output a warning in the case of no tags. Perhaps len(tags) is zero and yet nextTag is not ""?
ammaratef45 self-assigned this 2025-12-18 21:19:30 +00:00
ammaratef45 added the
critical fix
label 2025-12-18 21:22:22 +00:00
Member

@jade How sure are you of the root cause? I saw that you fixed kiwix somehow so I tried on another new recipe that never had a release before (https://recipes.coopcloud.tech/shlink) and I think the line latestRecipeVersion := versions[len(versions)-1] is the error instead of latestRelease := tags[len(tags)-1]

Note that relying on the line number in the error is not accurate because the code changes, if you haven't changed the abra version you are running maybe you can share the output of abra --version and we can make sure whether it is an emty tag or version list for your case

@jade How sure are you of the root cause? I saw that you fixed kiwix somehow so I tried on another new recipe that never had a release before (https://recipes.coopcloud.tech/shlink) and I think the line `latestRecipeVersion := versions[len(versions)-1]` is the error instead of `latestRelease := tags[len(tags)-1]` Note that relying on the line number in the error is not accurate because the code changes, if you haven't changed the abra version you are running maybe you can share the output of `abra --version` and we can make sure whether it is an emty tag or version list for your case
decentral1se added the
bug
label 2025-12-18 22:02:24 +00:00
Member

working on this in #738

working on this in https://git.coopcloud.tech/toolshed/abra/pulls/738
Owner
https://git.coopcloud.tech/toolshed/abra/pulls/738
decentral1se added this to the Abra "next" project 2026-01-01 17:45:19 +00:00
decentral1se moved this to Done in Abra "next" on 2026-01-01 17:46:28 +00:00
Sign in to join this conversation.
3 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: toolshed/abra#732
No description provided.