Hooks marked `interactive: true` have no non-interactive guard and can block instead of failing
- Dominant language
- Go
- Stars
- 569
- Forks
- 364
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 136
Description
### Problem
In `cli/azd/pkg/ext/hooks_runner.go`, interactive mode resolves as:
```go
scriptInteractive := consoleInteractive && hookConfig.Interactive
```
where `consoleInteractive` is derived from the output formatter. The decision does not consider whether stdin is attached to a terminal. A hook declared `interactive: true` can therefore be granted stdin in an environment where no interactive input will ever arrive.
### Impact
When such a hook prompts in an automated context, it waits on input that cannot come. Rather than failing with a clear cause, the command consumes the remaining execution budget and is terminated externally. The resulting output does not identify the prompt, the hook, or the missing value, so diagnosis requires reproducing the run locally.
The cost is asymmetric. A fast failure naming the missing value is a short fix. A block that is killed by an external timeout wastes the full budget, produces no usable diagnostic, and on constrained or self-hosted execution environments holds capacity for the entire duration.
The trigger is ordinary: a project gains a new required input, and any automated invocation that has not yet supplied it blocks instead of reporting what is missing.
### Proposed requirement
1. Detect that stdin is not an interactive terminal and do not grant a hook interactive stdin in that case.
2. When a hook would prompt and cannot, fail immediately with an error naming the hook and, where determinable, the value being requested.
3. Provide an explicit way to force non-interactive execution so prompts become errors deterministically, independent of output format.
4. Make the resolved interactivity decision visible in verbose output.
### Acceptance criteria
- [ ] Interactivity resolution accounts for whether stdin is a terminal, not only the output formatter
- [ ] A hook that would prompt without available input fails fast rather than blocking
- [ ] The failure names the hook
- [ ] An explicit non-interactive mode is available and documented
- [ ] Covered by a test that runs a prompting hook with no terminal attached
Contributor guide
Assessment
This issue has not been assessed yet.