-
Notifications
You must be signed in to change notification settings - Fork 7
CLI plugins error handling #109
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves the CLI plugins' error handling by providing explicit error messages when unsupported Docker subcommands are encountered. Key changes include:
- Introducing a helper function (spawnDockerCommand) to handle Docker process spawning and error propagation.
- Refactoring command registrations to use the new helper for both build and scout commands.
- Updating settings and prompt logic to disable repetitive error prompts.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/utils/spawnDockerCommand.ts | Adds a centralized function to spawn Docker commands and handle errors. |
src/utils/settings.ts | Provides helper functions to access and update Docker extension settings. |
src/utils/prompt.ts | Updates user prompt functions and introduces an error message function for unknown commands. |
src/utils/os.ts | Implements functions to determine the Docker Desktop path and verify its installation. |
src/utils/monitor.ts | Refactors Docker engine checking to use the new spawn helper and removes redundant logic. |
src/extension.ts | Refactors command registration to use the new spawn helper, ensuring consistent error handling. |
): Promise<void> { | ||
// TODO: Get a proper error message from Allie | ||
await vscode.window.showErrorMessage( | ||
`Docker Desktop does not know the command "${command}".`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aevesdocker could we please get an error message for when an extension tries to run a docker subcommand like docker scout
or docker ai
but it is not available because the user is running an older version of Docker Desktop from before that command was introduced?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is not available because the user is running an older version of Docker Desktop from before that command was introduced?
- It might be unavailable because the user installed Docker CE instead of installing Docker Desktop (likely case on Linux). We can reuse
promptInstallDesktop
in that case although the wording would be different of course. - For the Docker Desktop prompts, Varun had mentioned to me we should show them based on the
docker.extension.dockerEngineAvailabilityPrompt
setting so we will need to add a conditional here similar tocheckForDockerEngine
. Sorry for not making that clear earlier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For 2 are we just happy with the fact that if the user sets docker.extension.dockerEngineAvailabilityPrompt
to false they will not get a prompt regardless of if it's docker engine missing or they are running an unavailable command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For 2 are we just happy with the fact that if the user sets
docker.extension.dockerEngineAvailabilityPrompt
to false they will not get a prompt regardless of if it's docker engine missing or they are running an unavailable command?
You got it. 👍 I think the idea is "if I have it set to false
do not tell me to open or install or update Docker Desktop".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we all good, or still need me?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we still need one for the case:
It might be unavailable because the user installed Docker CE instead of installing Docker Desktop (likely case on Linux). We can reuse promptInstallDesktop in that case although the wording would be different of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can discuss this during standup to try and get a grasp on all the possibilities.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stanislavHamara We have three different cases here:
docker
is not found and Node.js throws thatENOENT
error- use the
promptInstallDesktop
function to prompt the user to install Docker Desktop if the user wants to be prompted (pergetExtensionSetting('dockerEngineAvailabilityPrompt')
)
- use the
docker scout
is not found and we get the non-zero exit code (which suggestsdocker
itself is installed) andisDockerDesktopInstalled
returnsfalse
, this is likely the Linux use case- similar to 1 above, we can prompt the user about this but we need a separate, distinct message from Allie first
- the reverse case of 2,
isDockerDesktopInstalled
returnstrue
- as discussed on the call, this might not even be a real problem so we will just ignore this for now
@aevesdocker We need your help with 2 above.
vscode-extension/src/utils/prompt.ts
Lines 59 to 63 in 23dc878
const response = await vscode.window.showInformationMessage( | |
'Docker is not running. To get help with your Dockerfile, install Docker.', | |
"Don't show again", | |
'Install Docker Desktop', | |
); |
To help jog your memory, these are the strings we use for the case where "Docker is not installed you should install Docker Desktop". This time we need a message to convey that Docker Scout could not be found and you can get it if you install Docker Desktop (without mentioning that Docker is not running as we know they have the
docker
CLI installed in this particular case).
If any of the above is unclear, please let me know. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So something simple like
Docker Scout is not available. To access Docker Scout's features, install Docker Desktop.
with the same action options as above - Don't show again/Install Docker Desktop
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aevesdocker That sounds fine to me. 👍 Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This refactoring is a good start and we can make further changes after this is merged.
Problem Description
If a user has an old version of docker that does not include e.g.
docker scout
ordocker ai
commands and the extension relies on them, we just error out "silently" in the console.Proposed Solution
This PR introduces an error message being shown when a particular sub command of docker is not available.
Proof of Work
TBD once we get a correct error message