-
Notifications
You must be signed in to change notification settings - Fork 165
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
incomplete results returned as network errors occurring during paging are not written #702
Comments
Thanks for bringing this to our attention. We will fix it in the next releases. |
FYI also observed that if the service returns a service error (e.g., 500-series result code) for a GET of a page after the first, then this is not being returned (or included in the debug/verbose log). |
@markwahl-msft, an exception is always thrown whenever the network goes down and the request times out (100 seconds). e.g., The script below captures a network error as expected, albeit suppressed. $stopwatch = [System.Diagnostics.Stopwatch]::new()
try {
Connect-MgGraph
$stopwatch.Start()
$messages = Get-MgUserMessage -UserId $env:App_User_Id -All -ErrorAction Stop
}
catch {
$stopwatch.Stop()
Write-Error "Something happened!!"
Write-Host "Elapsed Time: $($stopwatch.Elapsed.TotalSeconds) seconds."
$_.Exception
$stopwatch.Reset()
} The network error is indeed suppressed as noted here and will be fixed by #712. Is there a specific command that's not throwing an exception when a network error occurs? I'm using the latest SDK (v1.6.0) to test this. |
|
I'm still not able to repro this on my end, even with @peter ➜ M $assignments = $null
@peter ➜ M $assignments = Get-MgEntitlementManagementAccessPackageAssignment -All -ErrorAction Stop
Get-MgEntitlementManagementAccessPackageAssignment_List: C:\Users\peter\Documents\PowerShell\Modules\Microsoft.Graph.Identity.Governance\1.6.0\custom\Get-MgEntitlementManagementAccessPackageAssignment.ps1:159
Line |
159 | Microsoft.Graph.Identity.Governance.private\Get-MgEntitlementMana …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Value cannot be null. (Parameter 'httpResponse')
@peter ➜ M $assignments.count
0
@peter ➜ M $stopwatch = [System.Diagnostics.Stopwatch]::new()
@peter ➜ M try {
>> Connect-MgGraph
>> $stopwatch.Start()
>> $assignments = $null
>> $assignments = Get-MgEntitlementManagementAccessPackageAssignment -All -ErrorAction Stop
>> }
>> catch {
>> $stopwatch.Stop()
>> Write-Error "Something happened!!"
>> Write-Host "Assignment count: $($assignments.count)."
>> Write-Host "Elapsed Time: $($stopwatch.Elapsed.TotalSeconds) seconds."
>> $_.Exception
>> $stopwatch.Reset()
>> }
Welcome To Microsoft Graph!
Write-Error: Something happened!!
Assignment count: 0.
Elapsed Time: 105.4817364 seconds.
Message : Value cannot be null. (Parameter 'httpResponse')
ParamName : httpResponse
TargetSite : Void .ctor(System.Net.Http.HttpResponseMessage)
StackTrace : at Microsoft.Graph.PowerShell.HttpMessageFormatter..ctor(HttpResponseMessage httpResponse)
at Microsoft.Graph.PowerShell.Module.Finally(String id, CancellationToken cancellationToken, Func`1
getEventData, Func`4 signal)
.... Are you able to repro this with v1.6.0? Also, can you please share your |
Also, does this happen intermittently, or it constantly never throws an error when the network is down? |
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. |
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. |
In a script that uses a cmdlet to list a large result set, such as
try { $res = Get-Mg... -All -ErrorAction Stop} catch { ... }
the cmdlet is expected under normal circumstances to page through and return the complete result set, and under abnormal circumstances such as an Internet outage, report a terminating or non-terminating error. The caller indicates withErrorAction Stop
that it wants the PSh runtime to use thecatch
block for a non-terminating error.If the network is up the whole time, this script works as expected and a complete result is returned. And, if the network has gone down before the cmdlet starts processing, then an error is caught by the script, as expected.
However, if the network goes down in the middle of processing, after some calls have been made and partial results returned, but not before the last page has been returned, then no error is provided to the script, and incomplete results are returned. For example, there might be 430 entries (5 pages of 100) in the Graph-based service, but if the network goes down partway through, $res.Count is 200 and no error is reported.
This can cause problems for client automation since there is no indication that there is an incomplete result set or what the cause might be, even with -Verbose -Debug present as well.
AB#9914
The text was updated successfully, but these errors were encountered: