fix: auto-detect non-TTY stdin to prevent segfault in edit, move, and delete#980
fix: auto-detect non-TTY stdin to prevent segfault in edit, move, and delete#980steven-range wants to merge 2 commits intoankitpokhrel:mainfrom
Conversation
`issue edit` panics with a segfault in the survey library when stdin is not a terminal (e.g. piped input, CI, scripted agents) because survey assumes interactive TTY input. `issue create` and `epic create` already handle this by checking `cmdutil.StdinHasData()` and implicitly setting noInput=true. Apply the same guard to `issue edit` for consistency. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Same pattern as the edit fix — these commands use survey prompts for missing arguments but don't check for a TTY first. In non-TTY contexts (CI, agents, scripts), this causes a segfault when the required arguments aren't provided. - issue move: guard setIssueKey and setDesiredState - issue delete: guard setIssueKey When stdin is not a terminal and required args are missing, fail with a clear error message instead of crashing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
| if !params.noInput && cmdutil.StdinHasData() { | ||
| params.noInput = true | ||
| } |
There was a problem hiding this comment.
Unless, I'm wrong it means this
| if !params.noInput && cmdutil.StdinHasData() { | |
| params.noInput = true | |
| } | |
| params.noInput = cmdutil.StdinHasData() |
There was a problem hiding this comment.
I don't want to blindly overwrite. If the user (or coding agent) sends --no-input, that should be retained regardless of cmdutil.StdinHasData(). There may be an argument to simplify to what you've proposed, since piping something could indicate programmatic usage, but I don't think we can guarantee that. Changing that would be more than a bug fix, which is the intended purpose here.
It could become params.noInput = params.noInput || cmdutil.StdinHasData(), but I think that obscures readability for no tangible benefit.
There was a problem hiding this comment.
Thanks for your detailed reply. You are right 😅👍
I missed the fact we don't want to reset noInput to false depending on the value of the stdin.
What does this PR solve?
Several commands panic with a segfault in the survey library when stdin is not a terminal (e.g. piped input, CI pipelines, scripted agents). The crash occurs because the survey library assumes interactive TTY input.
issue createandepic createalready handle this case by checkingcmdutil.StdinHasData()and implicitly settingnoInput=truewhen stdin is not a TTY. This PR applies the same pattern to three other commands:issue edit: implicitly setsnoInput=truewhen stdin is not a TTY (matchingissue createbehavior)issue move: errors with a clear message when required args (issue key, desired state) are missing in non-TTY contextissue delete: errors with a clear message when issue key arg is missing in non-TTY contextHow to test?
Before this fix:
After this fix:
Checklist
Note: No test files exist for
internal/cmd/issue/edit/,move/, ordelete/(consistent with the rest of the cmd layer). Changes are minimal guards matching the existing pattern inissue create.