Skip to content

Conversation

@georgend
Copy link
Contributor

Show full request body and response when Debug is called.

Show full request body and response when Debug is called.
@georgend georgend requested a review from peombwa March 30, 2021 15:20
@peombwa
Copy link
Member

peombwa commented Mar 30, 2021

"The stream was already consumed.." exception is still thrown when calling commands that make POST calls such as Test-MgDirectoryObjectProperty:

image

@peombwa
Copy link
Member

peombwa commented Mar 30, 2021

We should also honor $DebugPreference that is set by a customer.
Setting $DebugPreference to continue only prints out a limited number of debug messages. See repro steps below :
image

@peombwa
Copy link
Member

peombwa commented Mar 30, 2021

It would be nice to add Pester tests for some of these edge cases. e.g.

$ps = [powershell]::Create()
$ps.AddScript(@'
$DebugPreference = 'Continue'

Import-Module .\src\Authentication\Authentication\artifacts\Microsoft.Graph.Authentication.psd1
Import-Module .\src\DirectoryObjects\DirectoryObjects\Microsoft.Graph.DirectoryObjects.psd1

Connect-MgGraph
Test-MgDirectoryObjectProperty -DisplayName "New Name" -EntityType "Group" 
'@).Invoke()

# Assert that debug stream contains the expected debug log and no exception.
if ($ps.Streams.Debug -notLike "*Exception*") { pass test ... }
if ($ps.Streams.Debug -like "*HTTP/1.1 200 OK*) { pass test ...}
....

@georgend georgend self-assigned this Mar 31, 2021
@georgend georgend linked an issue Mar 31, 2021 that may be closed by this pull request
@peombwa
Copy link
Member

peombwa commented Apr 12, 2021

We should also honor $DebugPreference that is set by a customer.
Setting $DebugPreference to continue only prints out a limited number of debug messages. See repro steps below :
image

Is there a way for us to honor $DebugPreference? Without it, customers running cmdlets in scripts won't be able to bypass the confirm dialog.
image

@georgend
Copy link
Contributor Author

georgend commented Apr 13, 2021

@peombwa This seems to be part of a known issue, especially since there is nothing special we are doing that would disregard the customer preference. Also from the code, however, removing this check:-

if (invocationInfo.BoundParameters.ContainsKey("Debug"))

resolves the issue, ensuring the cmdlets respect all the preferences.
image

@georgend georgend requested review from darrelmiller and ddyett April 14, 2021 10:42
@georgend georgend merged commit 94b509e into dev Apr 16, 2021
@peombwa peombwa deleted the bugfixes/debugServiceModules branch May 10, 2021 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

-Debug does not print body for Service modules

3 participants