You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
No Error Displayed When $ErrorView Set to ConciseView #12191
In PS7 with $ErrorView set to ConciseView a custom function in a script module does not display an error, but an error is recorded in $Error. Changing to NormalView fixes this issue. I have tested the same command in VS Code's Integrated Terminal running PS7 with ConciseView and an error is output as expected. I can't explain why this works differently based on the host.
The error itself is coming from Invoke-RestMethod which is reaching out to an Office 365 REST API. I don't see the same behavior with built in commands.
Name Value
---- -----
PSVersion 7.0.0
PSEdition Core
GitCommitId 7.0.0
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
PS>Connect-O365ServiceCommunications-ClientID (new-guid) -ClientSecret 2-TenantID (new-guid) Invoke-RestMethod:
Line |28|$Response=Invoke-RestMethod-Method Post -Uri $Url-Body $Body| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| {"error":"invalid_request","error_description":"AADSTS90002: Tenant '94451173-27af-4457-9369-571accb75354' not found. This may happen if there are no active subscriptions for the tenant. Check to make sure you have the correct tenant ID. Check with your subscription administrator.\r\nTrace ID: e3531849-ac96-40e0-b31b-d575c3091c00\r\nCorrelation ID: 96f214bb-c6b2-41f1-b7e1-e2cc47832376\r\nTimestamp: 2020-03-27 20:29:10Z","error_codes":[90002],"timestamp":"2020-03-27 20:29:10Z","trace_id":"e3531849-ac96-40e0-b31b-d575c3091c00","correlation_id":"96f214bb-c6b2-41f1-b7e1-e2cc47832376","error_uri":"https://login.microsoftonline.com/error?code=90002"}
InvalidOperation:
Line |29|$Script:SCConnection= [O365ServiceCommunications_Connection]@{
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Unable to find type [O365ServiceCommunications_Connection].
Need a better repro. What size is your terminal? If you can repro, can you output $host.ui.RawUI.WindowSize?
You can see there that I ran it once and no error was displayed while the host window was scaled to a small size. Then I expanded the window and ran it again and the error was rendered to the screen.
I had no idea that had an impact on displaying the error!
EDIT: I also confirmed the same issues exists in the VS Code integrated terminal if I squish it down really small.
EDIT 2: It appears to also matter what the error's source is. For instance in your case you received an error that the command is unknown. If I remove the module and repro that, I get the error displayed regardless of window size. If I actually load the module so the command is available, then I only get an error if the window is large enough. Hopefully that helps a bit.
This seems to be the cause of errors not showing up in Azure Pipelines. The powershell task has been updated (not yet released it seems) to workaround the issue by explicitly setting $ErrorView to NormalView before any code is invoked.
Activity
daxian-dbw commentedon Mar 24, 2020
Matt McNabb (@mattmcnabb) Could you please provide a repro for us to investigate?
mattmcnabb commentedon Mar 25, 2020
Dongbo Wang (@daxian-dbw) here's the actual code I'm running:
https://github.com/mattmcnabb/O365ServiceCommunications/blob/master/Source/Public/Connect-O365ServiceCommunications.ps1
There's not much to it. I have this issue when I run this command with a bad value for
$ClientSecretand get an error from the server.SteveL-MSFT commentedon Mar 27, 2020
Matt McNabb (@mattmcnabb), I tried your script with PS7 and got this error:
Need a better repro. What size is your terminal? If you can repro, can you output
$host.ui.RawUI.WindowSize?mattmcnabb commentedon Mar 27, 2020
Steve Lee (@SteveL-MSFT) Window size really seems to be the issue here:
You can see there that I ran it once and no error was displayed while the host window was scaled to a small size. Then I expanded the window and ran it again and the error was rendered to the screen.
I had no idea that had an impact on displaying the error!
EDIT: I also confirmed the same issues exists in the VS Code integrated terminal if I squish it down really small.
EDIT 2: It appears to also matter what the error's source is. For instance in your case you received an error that the command is unknown. If I remove the module and repro that, I get the error displayed regardless of window size. If I actually load the module so the command is available, then I only get an error if the window is large enough. Hopefully that helps a bit.
krokofant commentedon May 12, 2020
This seems to be the cause of errors not showing up in Azure Pipelines. The powershell task has been updated (not yet released it seems) to workaround the issue by explicitly setting $ErrorView to NormalView before any code is invoked.
mattmcnabb commentedon May 15, 2020
Steve Lee (@SteveL-MSFT) I'm no longer able to reproduce this issue in PowerShell 7.0.1. I'm thinking maybe this was fixed with #11880?
vexx32 commentedon May 15, 2020
Yep, seems to be the case. Glad it's sorted out!
I'll close this one for now. 🙂