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

Don't panic on firmware list without Internet connection #127

Closed
per1234 opened this issue Jan 28, 2022 · 0 comments · Fixed by #128
Closed

Don't panic on firmware list without Internet connection #127

per1234 opened this issue Jan 28, 2022 · 0 comments · Fixed by #128
Assignees
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: enhancement Proposed improvement

Comments

@per1234
Copy link
Contributor

per1234 commented Jan 28, 2022

Describe the current behavior

Running the arduino-fwuploader firmware list command while your computer does not have access to the Internet results in a user unfriendly stack trace.

To Reproduce

  1. Disconnect your computer from the Internet.
  2. Run the arduino-fwuploader firmware list command.
$ arduino-fwuploader version
arduino-fwuploader Version: test-c061e884578ceb9ffcc643a6ec545e1c3fc2b344-git-snapshot Commit: c061e88 Date: 2022-01-14T10:17:26Z

$ arduino-fwuploader firmware list
downloading index https://downloads.arduino.cc/arduino-fwuploader/boards/module_firmware_index.json.gz: Get "https://downloads.arduino.cc/arduino-fwuploader/boards/module_firmware_index.json.gz": dial tcp: lookup downloads.arduino.cc: no such host
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0xa59430]

goroutine 1 [running]:
github.com/arduino/arduino-fwuploader/cli/firmware.list({0x0, 0x0})
        /home/runner/work/arduino-fwuploader/arduino-fwuploader/cli/firmware/list.go:65 +0x90
github.com/arduino/arduino-fwuploader/cli/firmware.newListCommand.func1(0xc0001b6c80, {0xf93458, 0x0, 0x0})
        /home/runner/work/arduino-fwuploader/arduino-fwuploader/cli/firmware/list.go:41 +0x27
github.com/spf13/cobra.(*Command).execute(0xc0001b6c80, {0xf93458, 0x0, 0x0})
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:856 +0x5f8
github.com/spf13/cobra.(*Command).ExecuteC(0xc0001b6000)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:960 +0x3ad
github.com/spf13/cobra.(*Command).Execute(...)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:897
main.main()
        /home/runner/work/arduino-fwuploader/arduino-fwuploader/main.go:34 +0x45

Describe the request

Print an error message that clearly communicates the problem to the user:

The output of the other commands under these conditions is fine:

$ arduino-fwuploader.exe firmware flash -b arduino:samd:nano33iot -a COM36 -m NINA
Can't load package index: downloading index https://downloads.arduino.cc/packages/package_index.json.gz: Get "https://downloads.arduino.cc/packages/package_index.json.gz": dial tcp: lookup downloads.arduino.cc: no such host

IMO, panics should only be used in cases that should never occur. When such a thing does occur, a developer must investigate and the stack trace will be very useful for that. But the tool running without access to the Internet is a normal condition, and so should be handled gracefully.

Environment

  • Updater version: test-c061e884578ceb9ffcc643a6ec545e1c3fc2b344-git-snapshot Commit: c061e88 Date: 2022-01-14T10:17:26Z
  • OS and platform: Windows 10

Additional context

Real world example of this causing some alarming looking Arduino IDE 2.x startup output, which acted as a "red herring":
https://forum.arduino.cc/t/arduino-2-0-not-starting-up/950998/5

@per1234 per1234 added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Jan 28, 2022
@per1234 per1234 added the conclusion: resolved Issue was resolved label Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants