Fix PowerShell error parsing to handle timeout and non-XML stderr#4066
Fix PowerShell error parsing to handle timeout and non-XML stderr#4066vyadavmsft wants to merge 1 commit intomainfrom
Conversation
When PowerShell commands timeout and are killed, stderr may be empty or contain non-XML content. The _parse_error_message() method was attempting to parse all stderr as XML without validation, causing ElementTree.ParseError. Changes: - Add check for empty/whitespace-only stderr - Return raw stderr if it doesn't start with CLIXML header - Wrap XML parsing in try-except to handle malformed XML gracefully - Return raw stderr (minus CLIXML header) if parsing fails This prevents crashes when processes are killed due to timeout or produce non-standard error output.
|
I looked into similar issues before, and it seems the empty PowerShell output is caused by cached results. You might want to handle unexpected cache behavior—either by skipping the cache altogether or tweaking the PowerShell command to work better with it. |
in my case its not a cache issue , The Get-VMSwitch PowerShell command hanging for 10 minutes suggests a Hyper-V infrastructure issue, not a cache issue . it wasn't valid XML because the process was killed mid-execution, The XML parsing crash happened AFTER the timeout - the original problem was the hanging Get-VMSwitch command. |
|
@vyadavmsft have you tried again with the latest code containing the PR 4077? |
When PowerShell commands timeout and are killed, stderr may be empty or contain non-XML content. The _parse_error_message() method was attempting to parse all stderr as XML without validation, causing ElementTree.ParseError.
Changes:
This prevents crashes when processes are killed due to timeout or produce non-standard error output.