-
Notifications
You must be signed in to change notification settings - Fork 267
Fix panic on prompt cancellation during middleware resolution #6513
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
Conversation
When a user cancels a prompt (Ctrl+C) during middleware dependency resolution (e.g., during environment initialization), the interrupt error should be propagated immediately rather than being logged and ignored. This prevents panics from accessing nil pointers in subsequent code that expects initialized dependencies. Changes: - Import terminal package for InterruptErr - Check for interrupt error in middleware resolution - Return error immediately if interrupt is detected - Add unit test for interrupt error scenario Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
|
/azp run azure-dev - cli |
|
Azure Pipelines successfully started running 1 pipeline(s). |
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
This PR fixes a panic that occurred when users cancelled prompts (Ctrl+C) during middleware dependency resolution in commands like azd provision. The interrupt error was previously logged but ignored, causing execution to continue with nil dependencies and resulting in nil pointer dereference panics.
Changes:
- Added interrupt error propagation in middleware resolution to halt execution immediately when users cancel prompts
- Added comprehensive test coverage validating interrupt error behavior prevents action invocation
- Cleaned up go.mod dependencies in azure.ai.finetune extension by moving directly-used packages from indirect to direct
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| cli/azd/cmd/middleware/middleware.go | Added interrupt error check during middleware resolution to propagate user cancellations instead of ignoring them |
| cli/azd/cmd/middleware/middleware_test.go | Added test case verifying interrupt errors halt execution and prevent actions from running |
| cli/azd/extensions/azure.ai.finetune/go.mod | Moved sethvargo/go-retry and gopkg.in/yaml.v3 from indirect to direct dependencies as they are directly imported in extension code |
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
| // Check if the error is an interrupt error (user cancelled a prompt) | ||
| // In this case, we should not continue and return the error immediately | ||
| if errors.Is(err, terminal.InterruptErr) { | ||
| return nil, err | ||
| } |
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.
Would we consider terminating on all errors here? I could imagine if the LoginGuard for example, were to fail to construct, we wouldn't want to skip the guard completely and run the main logic.
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.
Separate proposal #6517
weikanglim
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.
We should consider what the "right" behavior is for middleware construction.
When users cancel prompts (Ctrl+C) during middleware dependency resolution—such as environment initialization in
azd provision—the interrupt error was logged but ignored, causing execution to continue with nil dependencies and panic on nil pointer dereference.Changes
terminal.InterruptErrduring middleware resolution and return immediately instead of continuing the chainNon-interrupt resolution failures retain existing behavior (logged and chain continues).
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
code.cloudfoundry.org/update-job-proxy /update-job-proxy ACCEPT ndor/bin/git test -e si_-_Surum_1.pem /opt/hostedtoolcache/go/1.25.5/x64/pkg/tool/linu53 /usr/bin/test -bool crt it test -e igiCert_Assured_ID_Root_G2.pem /opt/hostedtoolcache/go/1.25.5/x-e(dns block)dario.cat/update-job-proxy /update-job-proxy ACCEPT ndor/bin/git test -e si_-_Surum_1.pem /opt/hostedtoolcache/go/1.25.5/x64/pkg/tool/linu53 /usr/bin/test -bool crt it test -e igiCert_Assured_ID_Root_G2.pem /opt/hostedtoolcache/go/1.25.5/x-e(dns block)go.googlesource.com/update-job-proxy /update-job-proxy ACCEPT ndor/bin/git test -e si_-_Surum_1.pem /opt/hostedtoolcache/go/1.25.5/x64/pkg/tool/linu53 /usr/bin/test -bool crt it test -e igiCert_Assured_ID_Root_G2.pem /opt/hostedtoolcache/go/1.25.5/x-e(dns block)go.opentelemetry.io/update-job-proxy /update-job-proxy ACCEPT ndor/bin/git test -e si_-_Surum_1.pem /opt/hostedtoolcache/go/1.25.5/x64/pkg/tool/linu53 /usr/bin/test -bool crt it test -e igiCert_Assured_ID_Root_G2.pem /opt/hostedtoolcache/go/1.25.5/x-e(dns block)go.uber.org/update-job-proxy /update-job-proxy ACCEPT ndor/bin/git test -e si_-_Surum_1.pem /opt/hostedtoolcache/go/1.25.5/x64/pkg/tool/linu53 /usr/bin/test -bool crt it test -e igiCert_Assured_ID_Root_G2.pem /opt/hostedtoolcache/go/1.25.5/x-e(dns block)google.golang.org/update-job-proxy /update-job-proxy ACCEPT ndor/bin/git test -e si_-_Surum_1.pem /opt/hostedtoolcache/go/1.25.5/x64/pkg/tool/linu53 /usr/bin/test -bool crt it test -e igiCert_Assured_ID_Root_G2.pem /opt/hostedtoolcache/go/1.25.5/x-e(dns block)gopkg.in/update-job-proxy /update-job-proxy ACCEPT ndor/bin/git test -e si_-_Surum_1.pem /opt/hostedtoolcache/go/1.25.5/x64/pkg/tool/linu53 /usr/bin/test -bool crt it test -e igiCert_Assured_ID_Root_G2.pem /opt/hostedtoolcache/go/1.25.5/x-e(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.