-
Notifications
You must be signed in to change notification settings - Fork 267
Adds default 30 second timeout to all prompts #6626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds a global, configurable timeout for interactive prompts in azd to prevent indefinite hangs in non-interactive environments (e.g., CI/CD), and improves error/suggestion messaging around prompt failures.
Changes:
- Introduces a global UX prompt timeout configuration and
ErrPromptTimeouterror type. - Applies the timeout across UX prompt components and input console interactions, with
AZD_PROMPT_TIMEOUTenv-var control. - Improves propagation/display of prompt-timeout errors (including for extensions) and captures interactive stderr for better extension error reporting.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| cli/azd/pkg/ux/select.go | Applies global prompt timeout to UX Select prompts and converts deadline errors to ErrPromptTimeout. |
| cli/azd/pkg/ux/prompt.go | Applies global prompt timeout to UX Prompt prompts and converts deadline errors to ErrPromptTimeout. |
| cli/azd/pkg/ux/multi_select.go | Applies global prompt timeout to UX MultiSelect prompts and converts deadline errors to ErrPromptTimeout. |
| cli/azd/pkg/ux/confirm.go | Applies global prompt timeout to UX Confirm prompts and converts deadline errors to ErrPromptTimeout. |
| cli/azd/pkg/ux/config.go | Adds global UX config for prompt timeout and defines ErrPromptTimeout. |
| cli/azd/pkg/ux/config_test.go | Adds unit tests for UX timeout config and ErrPromptTimeout.Error(). |
| cli/azd/pkg/input/prompt_timeout.go | Adds env-var parsing/utilities for prompt timeout in input layer. |
| cli/azd/pkg/input/prompt_timeout_test.go | Adds unit tests for env-var parsing and helper behaviors. |
| cli/azd/pkg/input/console.go | Adds timeout behavior to console interactions and default-value fallback handling. |
| cli/azd/cmd/container.go | Initializes global UX timeout from AZD_PROMPT_TIMEOUT. |
| cli/azd/cmd/middleware/ux.go | Adds prompt-timeout suggestion handling in error output. |
| cli/azd/cmd/middleware/ux_test.go | Adds tests asserting --no-prompt suggestion on ErrPromptTimeout. |
| cli/azd/cmd/extensions.go | Attempts to translate extension prompt-timeout failures into ErrPromptTimeout. |
| cli/azd/pkg/extensions/runner.go | Includes captured stderr in ExtensionRunError for more informative failures. |
| cli/azd/pkg/exec/command_runner.go | Captures stdout/stderr even for interactive commands and marks output available for errors. |
| cli/azd/internal/errors_test.go | Adds tests for ErrorWithSuggestion behavior. |
| cli/azd/extensions/microsoft.azd.demo/internal/cmd/prompt.go | Fixes demo extension prompt command to return errors instead of swallowing them. |
| cli/azd/docs/environment-variables.md | Documents the new AZD_PROMPT_TIMEOUT environment variable. |
Comments suppressed due to low confidence (3)
cli/azd/pkg/exec/command_runner.go:182
- By forcing outputAvailable=true for ExitError (including interactive runs), stdout/stderr will now be embedded into error strings. This can unintentionally leak secrets or large amounts of output into user-facing errors/logs (interactive commands often print tokens, env dumps, etc.). Consider keeping outputAvailable=false for interactive runs (as before) or sanitizing/truncating output before attaching it to ExitError.
// Output is now always available since we capture even for interactive commands
err = NewExitError(
*exitErr,
args.Cmd,
result.Stdout,
result.Stderr,
true)
cli/azd/pkg/exec/command_runner.go:123
- Capturing stdout/stderr into unbounded bytes.Buffers for interactive commands can lead to high memory usage if an interactive process is noisy/long-running. If the goal is mainly to surface extension errors, consider capturing only stderr, or capping captured output to the last N bytes.
cmd.Stdin = r.stdin
// Use MultiWriter to both display to terminal AND capture output
cmd.Stdout = io.MultiWriter(r.stdout, &stdout)
cmd.Stderr = io.MultiWriter(r.stderr, &stderr)
} else {
cli/azd/pkg/input/console.go:622
- Timeout fallback for Prompt only applies when the default string is non-empty. However, promptFromOptions will pass through an explicitly configured empty-string DefaultValue (which survey treats the same as “no default”). This creates inconsistent semantics: callers that set DefaultValue: "" will not get fallback behavior on timeout. Consider standardizing by either treating empty string as “no default” everywhere (don’t set it on the survey prompt), or treating any explicitly provided string (including empty) as an available default for timeout fallback.
// Handle prompt timeout - return default value if available
var timeoutErr *uxlib.ErrPromptTimeout
if errors.As(err, &timeoutErr) {
if defaultValue, ok := options.DefaultValue.(string); ok && defaultValue != "" {
return defaultValue, nil
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
vhvb1989
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider creating an issue to link this and make it part of the sprint
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
Automatic Prompt Timeout Feature
What Changed
Added automatic 30-second timeout for all interactive prompts in
azd, configurable viaAZD_PROMPT_TIMEOUTenvironment variable.Business Justification
Problem: In CI/CD pipelines, automated scripts, and coding agent scenarios,
azdcommands can hang indefinitely waiting for user input that will never come - blocking pipelines, wasting compute resources, and causing deployment failures.Solution: Prompts now automatically timeout after 30 seconds (configurable), failing fast with a clear error message and actionable suggestion to set
--no-promptor provide required inputs.Behavior
AZD_PROMPT_TIMEOUTValue0or negativeUser Experience
When a prompt times out, users see:

Impact
AZD_PROMPT_TIMEOUT=0to restore old behavior