Skip to content

Commit

Permalink
Merge branch 'dev' into WeeklyExamplesUpdate/202407102119
Browse files Browse the repository at this point in the history
  • Loading branch information
timayabi2020 authored Jul 12, 2024
2 parents 252c633 + 9ff2b42 commit 1c93b76
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -999,8 +999,11 @@ private string QualifyFilePath(string path)
/// </summary>
private void ResetGraphSessionEnvironment()
{
_originalEnvironment = GraphSession.Instance.Environment;
GraphSession.Instance.Environment = _originalEnvironment;
var currentEnvironment = GraphSession.Instance.Environment;
if(currentEnvironment != null && !currentEnvironment.Equals(_originalEnvironment))
{
GraphSession.Instance.Environment = _originalEnvironment;
}
}

#region CmdLet LifeCycle
Expand Down Expand Up @@ -1039,6 +1042,8 @@ private async Task ProcessRecordAsync()
if (ShouldCheckHttpStatus && !isSuccess)
{
var httpErrorRecord = await GenerateHttpErrorRecordAsync(httpResponseMessageFormatter, httpRequestMessage);
// A reset of the GraphSession Environment is required to avoid side effects
ResetGraphSessionEnvironment();
ThrowTerminatingError(httpErrorRecord);
}
await ProcessResponseAsync(httpResponseMessage);
Expand Down

0 comments on commit 1c93b76

Please sign in to comment.