Skip to content

As a gRPC consumer of the CLI, I need better error codes to distinguish between errors #1762

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

Open
3 tasks done
kittaakos opened this issue Jun 14, 2022 · 11 comments · Fixed by #2076 or #2429
Open
3 tasks done
Assignees
Labels
topic: code Related to content of the project itself topic: gRPC Related to the gRPC interface type: enhancement Proposed improvement

Comments

@kittaakos
Copy link
Contributor

kittaakos commented Jun 14, 2022

Describe the request

To keep the startup performance OK, the IDE2 does not run a core and library index update before initializing the gRPC client. The Arduino core client initialization in the IDE2 happens the following way:

  • create the gRPC core client,
  • init the core client,
  • run the index update asynchronously.

However, this does not always work. The command line CLI auto-magically updates the core and lib indexes on the first run (#1043). This is not available when consuming the CLI's capabilities via the gRPC APIs.

On the first start (directories/data is missing or empty), the gRPC init step will fail with the following errors:

[
  { "code": 9, "message": "Loading index file: loading json index file /Users/a.kitta/Library/Arduino15/package_index.json: open /Users/a.kitta/Library/Arduino15/package_index.json: no such file or directory" },
  { "code": 9, "message": "Error loading hardware platform: discovery builtin:serial-discovery not found" },
  { "code": 9, "message": "Error loading hardware platform: discovery builtin:mdns-discovery not found" },
  { "code": 9, "message": "Loading index file: reading library_index.json: open /Users/a.kitta/Library/Arduino15/library_index.json: no such file or directory" }
]

When the IDE2 sees these errors, IDE2 knows that this is the first start, and the core and lib indexes must be updated before running the init phase of the gRCP core client. The above error is recoverable in IDE2.


There are "ignorable" errors. For example, if I use the https://arduino.esp8266.com/stable/package_esp8266com_index.json 3rd party URL, and install the 3.0.0 version (see the steps here), then there will be an error status:

{ "code": 9, "message": "Error loading hardware platform: loading platform release esp8266:[email protected]: loading boards: skipping loading of boards esp8266:esp8266:espduino: malformed custom board options" }

This error does not cause any CLI error, so should be ignored.

Describe the current behavior

All errors the IDE2 receives from the CLI have code: 9. There is no way to detect if the error is recoverable, non-recoverable, or ignorable.

It would be great if some details about the error would be available.

Arduino CLI version

0.23.0

Operating system

macOS

Operating system version

12.3.1

Additional context

Related


Keywords

  • "error protocol"

Issue checklist

  • I searched for previous requests in the issue tracker
  • I verified the feature was still missing when using the nightly build
  • My request contains all necessary details
@kittaakos
Copy link
Contributor Author

Besides the application-level error handling for the services, I would like to get a proper exit code and a terminating daemon process when something went wrong. Now, IDE2 must sniff into the stderr of the process, parse such messages and kill the daemon process because it's not terminating, although the daemon is nonfunctional:

  • To figure out the directories.data is unusable, IDE2 must parse this.

    invalid path creating config dir: /alma error: mkdir /alma: read-only file system time="2022-12-16T11:07:49+01:00" level=error msg="Error: invalid path creating config dir: /alma error: mkdir /alma: read-only file system"
    
  • To determine a Failed to listen on TCP port. Address already in use. error message:
    failed to listen, address already in use, bind, only one usage of each socket address

  • For invalid address: Failed to listen on TCP port. Unknown address.:
    is unknown name or tcp/ and is an invalid port

  • To provide the Failed to listen on TCP port. Invalid port. to the user:
    is an invalid port and failed to serve

Please help IDE2, terminate the daemon process on unrecoverable errors, such as inaccessible data dir or port issues, and provide an exit code. IDE2 wants to help users understand what went wrong, but it's hard because IDE2 is also just guessing the error. Thanks!

@kittaakos
Copy link
Contributor Author

invalid path creating config dir: /alma error: mkdir /alma: read-only file system time="2022-12-16T11:07:49+01:00" level=error msg="Error: invalid path creating config dir: /alma error: mkdir /alma: read-only file system"

And it's not even creating any config dir, the directories.data is incorrect.

@umbynos
Copy link
Contributor

umbynos commented Jan 23, 2023

This requires some more brainstorming with @cmaglie

@umbynos
Copy link
Contributor

umbynos commented Feb 6, 2023

For now we will fix only this error. If there is a need to fix other errors, this is the moment to speak. We will follow the same pattern used already another error ("upload require programmer error"), we should use the same methodology.

@kittaakos
Copy link
Contributor Author

this is the moment to speak.

For now we will fix only this error.

IDE2 wants to avoid parsing error messages from the CLI as it's unreliable.

@kittaakos
Copy link
Contributor Author

kittaakos commented Feb 28, 2023

I am going to reopen this issue as a generic go-to ticket until the CLI can provide error codes for at least the following issues:

  • the sketch is invalid
  • the sketch is missing
  • the sketch is not verified
  • no FQBN
  • invalid FQBN
  • the platform is not installed
  • the dependent platform is not installed when installing a 3rd party platform
  • verify has failed

@kittaakos kittaakos reopened this Feb 28, 2023
@kittaakos
Copy link
Contributor Author

For now we will fix only this error.

There are open questions on the initial changes at #2076 (comment).

@umbynos
Copy link
Contributor

umbynos commented May 15, 2023

Probably should not be necessary anymore after #2119

@kittaakos
Copy link
Contributor Author

Probably should not be necessary anymore after #2119

It's an essential feature. Please see: #1762 (comment)

I am going to reopen this issue as a generic go-to ticket until the CLI can provide error codes for at least the following issues:

  • the sketch is invalid
  • the sketch is missing
  • the sketch is not verified
  • no FQBN
  • invalid FQBN
  • the platform is not installed
  • the dependent platform is not installed when installing a 3rd party platform
  • verify has failed

@kittaakos
Copy link
Contributor Author

Please add a specific error code when the programmer is missing from debug --info (#2394). Currently, clients must parse the stderr. This won't work when the CLI language is not English. Thanks!

@kittaakos
Copy link
Contributor Author

It's just partially done. See #1762 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself topic: gRPC Related to the gRPC interface type: enhancement Proposed improvement
Projects
None yet
7 participants