Skip to content

Remove redundant stdin nil check in api command#1688

Merged
dgageot merged 1 commit intodocker:mainfrom
dgageot:fix-1665
Feb 11, 2026
Merged

Remove redundant stdin nil check in api command#1688
dgageot merged 1 commit intodocker:mainfrom
dgageot:fix-1665

Conversation

@dgageot
Copy link
Member

@dgageot dgageot commented Feb 10, 2026

The stdin variable is a copy of os.Stdin captured before it's set to nil, and os.Stdin is virtually always non-nil. The check provided no real protection and could confuse maintainers.

Fixes #1665

The stdin variable is a copy of os.Stdin captured before it's set to nil,
and os.Stdin is virtually always non-nil. The check provided no real
protection and could confuse maintainers.

Fixes docker#1665

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@dgageot dgageot requested a review from a team as a code owner February 10, 2026 18:35
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.

Review Summary

Approved - This is a good code cleanup that removes a redundant nil check.

The change correctly removes the && stdin != nil check because:

  1. The stdin variable is a copy of os.Stdin captured before os.Stdin is set to nil (line 93)
  2. The Go runtime virtually always initializes os.Stdin to a valid value
  3. As issue #1665 correctly identified, the check was "potentially misleading" rather than protective
  4. The check would only matter if os.Stdin were already nil at program start, which doesn't happen in practice

The removal makes the code clearer by eliminating a check that appears to guard against a condition that doesn't occur. No real bugs were found in the changed code.

@dgageot dgageot merged commit a1ae6ce into docker:main Feb 11, 2026
7 of 8 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.

[bug] Unnecessary stdin != nil check after os.Stdin = nil

2 participants