Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/readme.graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,11 @@ directive:
let duplicateDebugRegex = /^(\s*)(WriteDebug\(\$"{id}:.*)/gmi
$ = $.replace(duplicateDebugRegex, "");

// catch all exceptions in ProcessRecordAsync.
let processAsyncFinallyRegex = /(finally\s*{\s*await \(\(Microsoft\.Graph\.PowerShell\.Runtime\.IEventListener\)this\)\.Signal\(Microsoft\.Graph\.PowerShell\.Runtime\.Events\.CmdletProcessRecordAsyncEnd\);)/gmi
let catchAllExceptionImplementation = '((Runtime.IEventListener)this).Signal(Runtime.Events.CmdletException, $"{ex.GetType().Name} - {ex.Message} : {ex.StackTrace}").Wait(); if (((Runtime.IEventListener)this).Token.IsCancellationRequested) { return; } WriteError(new global::System.Management.Automation.ErrorRecord(ex, string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null));'
$ = $.replace(processAsyncFinallyRegex, `catch (System.Exception ex){${catchAllExceptionImplementation}}\n$1`);

return $;
}

Expand Down
6 changes: 3 additions & 3 deletions tools/Custom/HttpMessageLogFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static string GetHttpRequestLog(HttpRequestMessage request)
string body = string.Empty;
try
{
body = (request.Content == null) ? string.Empty : FormatString(request.Content.ReadAsStringAsync().Result);
body = (request.Content == null) ? string.Empty : FormatString(request.Content.ReadAsStringAsync().GetAwaiter().GetResult());
}
catch { }

Expand All @@ -44,7 +44,7 @@ public static string GetHttpResponseLog(HttpResponseMessage response)
string body = string.Empty;
try
{
body = (response.Content == null) ? string.Empty : FormatString(response.Content.ReadAsStringAsync().Result);
body = (response.Content == null) ? string.Empty : FormatString(response.Content.ReadAsStringAsync().GetAwaiter().GetResult());
}
catch { }

Expand All @@ -56,11 +56,11 @@ public static string GetHttpResponseLog(HttpResponseMessage response)
return stringBuilder.ToString();
}

private static Regex regexPattern = new Regex("(\\s*\"access_token\"\\s*:\\s*)\"[^\"]+\"", RegexOptions.Compiled);
private static object SanitizeBody(string body)
{
IList<Regex> regexList = new List<Regex>();
// Remove access_token:* instances in body.
Regex regexPattern = new Regex("(\\s*\"access_token\"\\s*:\\s*)\"[^\"]+\"");
regexList.Add(regexPattern);

foreach (Regex matcher in regexList)
Expand Down
2 changes: 1 addition & 1 deletion tools/Custom/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private async Task OnResponseCreated(string id, CancellationToken cancellationTo
var response = eventData?.ResponseMessage as HttpResponseMessage;
if (response != null)
{
if (response.Headers.Warning != null)
if (response.Headers.Warning != null && response.Headers.Warning.Any())
{
string warningHeader = response.Headers.Warning.ToString();
await signal(Events.Warning, cancellationToken,
Expand Down