Skip to content

Daily fixes#1990

Merged
dgageot merged 2 commits intodocker:mainfrom
dgageot:daily-fixes-20
Mar 9, 2026
Merged

Daily fixes#1990
dgageot merged 2 commits intodocker:mainfrom
dgageot:daily-fixes-20

Conversation

@dgageot
Copy link
Member

@dgageot dgageot commented Mar 9, 2026

No description provided.

@dgageot dgageot requested a review from a team as a code owner March 9, 2026 08:32
Copy link

@docker-agent docker-agent bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Code Review

Assessment: APPROVE

This PR contains clean refactoring improvements and a bug fix:

✅ cmd/root/api.go: Refactors error handling to remove else-after-return anti-pattern (Go style improvement). The cleanup defer pattern is safe - setupRecordingProxy always returns a valid cleanup function when err == nil, and the defer is only reached after confirming no error occurred.

✅ cmd/root/sandbox.go: Fixes a bug where os.Exit() prevented deferred cleanup functions from running. Now returns cli.StatusError instead, allowing proper resource cleanup.

✅ main.go: Adds proper handling for cli.StatusError to exit with correct status codes, completing the sandbox.go fix.

All changes improve code quality and correctness. No bugs detected in the changed code.

dgageot added 2 commits March 9, 2026 10:01
Replace the direct os.Exit() call with a cli.StatusError return so
that all deferred cleanup functions (including stopTokenWriter) run
normally. The exit code is propagated via cli.StatusError and handled
in main.go.

This removes the need to manually call stopTokenWriter() before
os.Exit() and ensures all defers in the call chain execute.

Fixes docker#1981
Fixes docker#1986

Assisted-By: docker-agent
The defer for recordCleanup was inside an else block, which meant it
was scoped to that block only. Restructure to declare variables first,
check the error, then defer cleanup unconditionally - matching the
pattern already used in run.go.

Fixes docker#1980
Fixes docker#1987

Assisted-By: docker-agent
@dgageot dgageot merged commit 5f307f7 into docker:main Mar 9, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants