Return error on tctl create with no file or stdin input - #69620
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: de410cb950
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| stat, _ := os.Stdin.Stat() | ||
| if (stat.Mode() & os.ModeCharDevice) != 0 { |
There was a problem hiding this comment.
Handle stdin Stat errors before using FileInfo
When tctl create is invoked without a filename and stdin is closed or otherwise invalid, os.Stdin.Stat() returns a nil FileInfo with an error; ignoring that error makes the next line call stat.Mode() and panic instead of returning a normal CLI error. This can happen in automation that closes fd 0, and it is a regression from the decoder path returning an error rather than crashing. Please check and return/wrap the Stat error before inspecting the mode.
AGENTS.md reference: AGENTS.md:L16-L16
Useful? React with 👍 / 👎.
Close #14791
Changelog: Fixed a bug where
tctl createwould hang indefinitely instead of returning an error when run without a file or stdin input.Manual Test Plan
Test Environment
Test Cases