Skip to content

midcobra: log exec.ExitError only once in DebugMiddleware - #3149

Open
shu-chen-dot-ca wants to merge 1 commit into
jetify-com:mainfrom
shu-chen-dot-ca:fix-3123-debug-double-log
Open

shu-chen-dot-ca wants to merge 1 commit into
jetify-com:mainfrom
shu-chen-dot-ca:fix-3123-debug-double-log

Conversation

@shu-chen-dot-ca

Copy link
Copy Markdown

Summary

Fixes #3123.

When runErr wraps an *exec.ExitError, DebugMiddleware.postRun logged command error with the command's stderr and then fell through to a second, unconditional command error log. The second call is now in an else branch, so each error is logged once: with stderr for an *exec.ExitError, without it for any other error.

How was it tested?

  • Added TestDebugMiddlewarePostRunLogsErrorOnce in internal/boxcli/midcobra/debug_test.go. It covers a wrapped *exec.ExitError (one log line, with stderr) and a plain error (one log line, without stderr). The *exec.ExitError case fails on main (logged 2 command errors, want 1) and passes with the change.
  • Manually, with a devbox.json whose only package is path:/nonexistent/flake#hello, DEVBOX_DEBUG=1 devbox run -- true logged two command error lines (debug.go:74 with stderr, debug.go:76 without) before the change. With the change it logs one, still with stderr.
  • go tool golangci-lint run --timeout 5m (0 issues), go tool gofumpt -extra -l on all Go files (clean), and go test -race -cover -timeout 30m -p 4 ./... (all pass, including testscripts) on Linux.
Before After
before after

Community Contribution License

All community contributions in this pull request are licensed to the project
maintainers under the terms of the
Apache 2 License.

By creating this pull request, I represent that I have the right to license the
contributions to the project maintainers under the Apache 2 License as stated in
the
Community Contribution License.

@greptile-apps

greptile-apps Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · This PR appears safe to merge.RetriggerView in GreptileConfidence Score: 5/5

[Low impact] This PR appears safe to merge.

Summary

DebugMiddleware.postRun now logs each error once.

  • Failed commands now produce one debug error record.

Reviews (1) · Last reviewed commit: "midcobra: log exec.ExitError only once i..." · Reviewed by Greptile

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

DebugMiddleware.postRun logs exec.ExitError twice

1 participant