Description
Describe the problem
The user may specify the URLs of additional package indexes via the board_manager.additional_urls
configuration key.
🐛 If the user sets this configuration key to a value with a format like so:
<non-scheme><reserved character><URL>
(where <non-scheme>
is any string that does not have the form of a URI scheme, <reserved character>
is a URI reserved character, and <URL>
is a URL)
Arduino CLI will panic.
To reproduce
$ arduino-cli version
arduino-cli Version: git-snapshot Commit: 84fc413ad Date: 2024-12-16T17:53:58Z
$ arduino-cli --config-file /tmp/arduino-cli.yaml config set board_manager.additional_urls foo=https://espressif.github.io/arduino-esp32/package_esp32_index.json
$ arduino-cli --config-file /tmp/arduino-cli.yaml core update-index
Error initializing instance: Invalid additional URL: parse "foo=https://espressif.github.io/arduino-esp32/package_esp32_index.json": first path segment in URL cannot contain colon
Downloading index: package_index.tar.bz2 downloaded
Downloading index: foo=https://espressif.github.io/arduino-esp32/package_esp32_index.json Unable to parse URL: parse "foo=https://espressif.github.io/arduino-esp32/package_esp32_index.json": first path segment in URL cannot contain colon
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x8 pc=0xb102b4]
goroutine 1 [running]:
net/url.(*URL).String(0x0)
C:/Users/per/sdk/go1.22.10/src/net/url/url.go:817 +0x34
github.com/arduino/arduino-cli/commands.(*arduinoCoreServerImpl).UpdateIndex.func1(...)
E:/git/arduino/arduino-cli/commands/instances.go:539
github.com/arduino/arduino-cli/commands.(*arduinoCoreServerImpl).UpdateIndex(0xc000009038, 0xc002f042c0, {0x19156e0, 0xc002408690})
E:/git/arduino/arduino-cli/commands/instances.go:567 +0x7d1
github.com/arduino/arduino-cli/internal/cli/core.UpdateIndex({0x1910788, 0xc0002da180}, {0x19218e8, 0xc000009038}, 0xc00012ac60)
E:/git/arduino/arduino-cli/internal/cli/core/update_index.go:57 +0x265
github.com/arduino/arduino-cli/internal/cli/core.runUpdateIndexCommand({0x1910788, 0xc0002da180}, {0x19218e8, 0xc000009038})
E:/git/arduino/arduino-cli/internal/cli/core/update_index.go:49 +0xa5
github.com/arduino/arduino-cli/internal/cli/core.initUpdateIndexCommand.func1(0xc000395508?, {0xc000110160?, 0x4?, 0x155faea?})
E:/git/arduino/arduino-cli/internal/cli/core/update_index.go:40 +0x2c
github.com/spf13/cobra.(*Command).execute(0xc000395508, {0xc000110140, 0x2, 0x2})
C:/Users/per/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:989 +0xab1
github.com/spf13/cobra.(*Command).ExecuteC(0xc000198c08)
C:/Users/per/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1117 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
C:/Users/per/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1041
github.com/spf13/cobra.(*Command).ExecuteContext(...)
C:/Users/per/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1034
main.main()
E:/git/arduino/arduino-cli/main.go:92 +0x474
Expected behavior
Panics do not occur under normal operating conditions, including invalid user input.
Note that of course it is not expected that Arduino CLI can download the index file in the face of an invalid configuration. It is only expected that it will handle this gracefully, without panicking.
Arduino CLI version
Operating system
Windows
Operating system version
11
Additional context
Originally reported at https://forum.arduino.cc/t/arduino-ide-2-3-4-compilation-error-no-connection-established/1332770
Additional reports
- https://forum.arduino.cc/t/downloading-index-library-index-tar-bz2-problem/1327204/1
- https://forum.arduino.cc/t/downloading-index-library-index-tar-bz2-problem/1327204/15
- https://forum.arduino.cc/t/ide-hangs-on-update/1343517
- https://forum.arduino.cc/t/ide-read-econnreset/1327036/3
Issue checklist
- I searched for previous reports in the issue tracker
- I verified the problem still occurs when using the nightly build
- My report contains all necessary details