Add actionable guidance for PowerShell hook failures#6804
Add actionable guidance for PowerShell hook failures#6804spboyer wants to merge 1 commit intoAzure:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds actionable guidance for PowerShell hook failures by detecting common error patterns in stderr output and displaying targeted hints to help users resolve issues. This addresses issue #6797, which identified PowerShell hook failures as the 4th largest error category (~6,347 errors, 4.96% of all azd errors).
Changes:
- Added
pwshFailureGuidance()function inerror.gothat detects 5 common PowerShell failure patterns - Created comprehensive table-driven tests in
pwsh_guidance_test.goto cover all patterns - Added
StderrOutput()getter andNewTestExitError()test helper toExitErrortype inrunresult.go
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| cli/azd/pkg/exec/runresult.go | Adds StderrOutput() accessor and NewTestExitError() test constructor to ExitError for easier testing |
| cli/azd/cmd/middleware/pwsh_guidance_test.go | Comprehensive table-driven tests covering all 5 PowerShell failure patterns plus edge cases |
| cli/azd/cmd/middleware/error.go | Implements pwshFailureGuidance() to detect common PowerShell errors and integrated hint display in ErrorMiddleware |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3506da2 to
e6e5036
Compare
When PowerShell hooks fail, detect common failure patterns in stderr output and display targeted hints to help users resolve the issue. Patterns detected include missing modules, Az module not found, execution policy restrictions, and expired authentication. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
e6e5036 to
22fb706
Compare
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
vhvb1989
left a comment
There was a problem hiding this comment.
Let's hope 🤞 we don't get many false-positives for all those string.contains()
Summary
When PowerShell hooks fail, detects common failure patterns in stderr output and displays targeted hints to help users resolve the issue.
Fixes #6797
Changes
error.go
pwsh_guidance_test.go (new)
runresult.go
Data Context
PowerShell hook failures account for 4.96% of all azd errors (~6,347). AI templates hit 6.59%.