Repository navigation
cli: Include the failed command's output in error results - #1358
Draft
Christof Marti (chrmarti) wants to merge 1 commit into
Draft
Christof Marti (chrmarti) wants to merge 1 commit into
Christof Marti (chrmarti) wants to merge 1 commit into
Conversation
The JSON result of up, set-up, build and run-user-commands only had the failed command line as message and a generic description, so the actual error, for example Docker's 'Error response from daemon: ...', was only in the log. The new errorOutput property carries the last lines of the failed command's terminal output or standard error, without terminal control sequences, so callers like the Dev Containers extension can report the cause. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
devcontainer up,set-up,buildorrun-user-commandsfails, the JSON result only has the failed command line asmessageand a genericdescription(e.g. "An error occurred setting up the container."). The actual error, for example Docker'sError response from daemon: ..., is only in the log output, which makes failures reported by callers like the Dev Containers extension hard to diagnose.This adds an
errorOutputproperty to the error results with the end of the failed command's output:docker run, TTY builds) and the standard error otherwise (e.g. non-TTY builds, Docker Compose), followingoriginalErrorfrom theContainerErrorto the failed command.Example with
"runArgs": ["--network", "missing"]:{ "outcome": "error", "message": "Command failed: docker run --sig-proxy=false -a STDOUT -a STDERR --mount ... --network missing ...", "description": "An error occurred setting up the container.", "errorOutput": "docker: Error response from daemon: failed to set up container networking: network missing not found\nRun 'docker run --help' for more information", ... }Testing:
src/test/errors.test.tsdrives the realrunCommandandrunCommandNoPtywith failing fake processes.docker runfailure (above) and a failing DockerfileRUNstep, whereerrorOutputends with BuildKit'sERROR: failed to build: failed to solve: process "..." did not complete successfully: exit code: 3.