File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
src/Authentication/Authentication/Cmdlets Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -999,8 +999,11 @@ private string QualifyFilePath(string path)
999999 /// </summary>
10001000 private void ResetGraphSessionEnvironment ( )
10011001 {
1002- _originalEnvironment = GraphSession . Instance . Environment ;
1003- GraphSession . Instance . Environment = _originalEnvironment ;
1002+ var currentEnvironment = GraphSession . Instance . Environment ;
1003+ if ( currentEnvironment != null && ! currentEnvironment . Equals ( _originalEnvironment ) )
1004+ {
1005+ GraphSession . Instance . Environment = _originalEnvironment ;
1006+ }
10041007 }
10051008
10061009 #region CmdLet LifeCycle
@@ -1039,6 +1042,8 @@ private async Task ProcessRecordAsync()
10391042 if ( ShouldCheckHttpStatus && ! isSuccess )
10401043 {
10411044 var httpErrorRecord = await GenerateHttpErrorRecordAsync ( httpResponseMessageFormatter , httpRequestMessage ) ;
1045+ // A reset of the GraphSession Environment is required to avoid side effects
1046+ ResetGraphSessionEnvironment ( ) ;
10421047 ThrowTerminatingError ( httpErrorRecord ) ;
10431048 }
10441049 await ProcessResponseAsync ( httpResponseMessage ) ;
You can’t perform that action at this time.
0 commit comments