plicit / scoop-search-multisource

Searches Scoop buckets: local, remote, zip, html
MIT License
39 stars 0 forks source link

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

Closed DessertArbiter closed 2 years ago

DessertArbiter commented 2 years ago

I was getting the error when I tried to do a generic search such as scoops crystaldiskmark, but I managed to narrow the issue down to Ryanjiena/scoop-apps (which I have added as a local bucket in my scoop installation). I'm almost positive that its related to the CJK Unified Ideographs Unicode block, because many of the descriptions in the manifests are in Chinese.

scoops -source "[bucket] https://github.com/Ryanjiena/scoop-apps" crystaldiskinfo
____________________
#1 Searching  [bucket] https://github.com/Ryanjiena/scoop-apps
loadAppListFromGitRepoUrl: https://github.com/Ryanjiena/scoop-apps
2022/04/10 21:22:10 Cloning repository: https://github.com/Ryanjiena/scoop-apps
Cloning into 'C:\Users\tim\scoop\cache\buckets\https%3A%2F%2Fgithub.com%2FRyanjiena%2Fscoop-apps'...

2022/04/10 21:22:13 Search took 2.5449816s
panic: runtime error: index out of range [1] with length 1

goroutine 1 [running]:
main.loadAppFromManifest({0xc000283500, 0x623, 0x624})
        /home/runner/work/scoop-search-multisource/scoop-search-multisource/sources.go:95 +0x7f4
main.loadAppListFromDir({0xc000016240, 0x52})
        /home/runner/work/scoop-search-multisource/scoop-search-multisource/sources.go:136 +0x310
main.loadAppListFromGitRepoUrl({0xc00000a339, 0x27})
        /home/runner/work/scoop-search-multisource/scoop-search-multisource/sources.go:381 +0x7f
main.loadBucketsFrom({0xc00000a331, 0xba84c5}, {0xc00000a339, 0xb67b4f})
        /home/runner/work/scoop-search-multisource/scoop-search-multisource/sources.go:45 +0x205
main.(*SearchState).SearchSource(0xc000052320, 0xc000142840)
        /home/runner/work/scoop-search-multisource/scoop-search-multisource/main.go:67 +0x51
main.(*SearchState).Run(0xc000052320, 0xc00016f0a0)
        /home/runner/work/scoop-search-multisource/scoop-search-multisource/main.go:110 +0xa9a
main.main()
        /home/runner/work/scoop-search-multisource/scoop-search-multisource/main.go:177 +0xc5

But when I tried the same search in the Japanese language bucket tetradice/scoop-iyokan-jp, which also contains characters in the CJK Unified Ideographs Unicode block, there were no errors.

scoops -source "[bucket] https://github.com/tetradice/scoop-iyokan-jp" crystaldiskinfo
____________________
#1 Searching  [bucket] https://github.com/tetradice/scoop-iyokan-jp
loadAppListFromGitRepoUrl: https://github.com/tetradice/scoop-iyokan-jp
2022/04/10 21:37:57 Cloning repository: https://github.com/tetradice/scoop-iyokan-jp
Cloning into 'C:\Users\tim\scoop\cache\buckets\https%3A%2F%2Fgithub.com%2Ftetradice%2Fscoop-iyokan-jp'...

- 3 apps matched in 1/1 buckets

____________________
TOTAL: 3 apps matched in 1 buckets from 1 sources

MERGED RESULTS:

'https://github.com/tetradice/scoop-iyokan-jp' bucket:
    crystaldiskinfo (8.6.2)
    crystaldiskinfo-kureikei (8.6.2)
    crystaldiskinfo-shizuku (8.6.2)

2022/04/10 21:37:58 Search took 777.4017ms
plicit commented 2 years ago

Thanks for your thorough description! I was able to reproduce the error. It turns out that the "bin" field in one of Ryanjiena's manifests was causing the panic:

https://github.com/Ryanjiena/scoop-apps/blob/master/bucket/MouseInc.json "bin": [ [ "MouseInc.exe" ] ],

Sub-arrays like that are supposed to be used for aliases and command line arguments, e.g.: ["prog.exe", "aliasForProg", "--arg1"]

But the alias is missing which caused the panic. He could just replace it with: "bin": "MouseInc.exe"

I'm not sure if scoop would install his manifest, but I'm updating my app to be more robust so that it will process his manifest and if it fails to parse a manifest in the future, then it will notify the user and either skip or search part of the manifest.