Commit 573bb30
fix: include docker stderr in error messages (#278)
<!--
Thanks for opening a PR! Please delete any sections that don't apply.
-->
# Description
<!--
- **Motivation:** why this change is needed
- **What changed:** key implementation details
- **Related issues:** e.g., `Fixes #123`
-->
When Docker commands fail, only stdout was captured, making it difficult
to diagnose build and deployment failures. Docker typically writes error
details to stderr.
The `Executor.Run` method in `docker.go` now uses
`io.MultiWriter(os.Stderr, &stderrBuf)` to both display stderr in real
time and capture it for inclusion in the returned error message when the
command fails.
To reduce log pollution, outputs are now backed by `--verbose` flag.
Following a similar approach to the agentregistry-runtime, we print to
both stderr + buffer error when verbose is enabled, else we simply
output the buffer-captured error with the returned error message.
Fixes #193
## Validation
```sh
# init a skill
go run cmd/cli/main.go skill init test
```
Non-verbose output would only log the captured docker error
```sh
# invalid build without verbose logging
go run cmd/cli/main.go skill build test --image 'invalid!!tag'
```
```output
Building skill "hello-world-template" as Docker image: invalid!!tag
Error: build failed for skill "hello-world-template": docker build failed: exit status 1
ERROR: failed to build: invalid tag "invalid!!tag": invalid reference format
exit status 1
```
Verbose output will log std logs, the stderr, and final captured docker
error (which technically leads to duplicated from stderr + captured err
returned)
```sh
# invalid skill with verbose logging
go run cmd/cli/main.go skill build test --image 'invalid!!tag' --verbose
```
```output
Building skill "hello-world-template" as Docker image: invalid!!tag
Running: docker build -t invalid!!tag -f /var/folders/zy/pkk0_2ys5yx8y1syxw5xjxhh0000gn/T/skill-dockerfile-654053150 /Users/fabiangonz98/go/src/github.com/solo-io/agentregistry/test
Working directory: /Users/fabiangonz98/go/src/github.com/solo-io/agentregistry/test
ERROR: failed to build: invalid tag "invalid!!tag": invalid reference format
Error: build failed for skill "hello-world-template": docker build failed: exit status 1
ERROR: failed to build: invalid tag "invalid!!tag": invalid reference format
exit status 1
```
# Change Type
```
/kind fix
```
# Changelog
<!--
Provide the exact line to appear in release notes for the chosen
changelog type.
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
-->
```release-note
Include docker stderr in error messages for better debugging
```
# Additional Notes
<!--
Any extra context or edge cases for reviewers.
-->
---------
Signed-off-by: Fabian Gonzalez <fabian.gonzalez@solo.io>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Fabian Gonzalez <fabian.gonzalez@solo.io>1 parent eec7764 commit 573bb30
1 file changed
Lines changed: 17 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| 42 | + | |
| 43 | + | |
40 | 44 | | |
41 | 45 | | |
42 | 46 | | |
| |||
46 | 50 | | |
47 | 51 | | |
48 | 52 | | |
49 | | - | |
50 | | - | |
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
54 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
55 | 69 | | |
56 | 70 | | |
57 | 71 | | |
| |||
0 commit comments