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)
999
999
/// </summary>
1000
1000
private void ResetGraphSessionEnvironment ( )
1001
1001
{
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
+ }
1004
1007
}
1005
1008
1006
1009
#region CmdLet LifeCycle
@@ -1039,6 +1042,8 @@ private async Task ProcessRecordAsync()
1039
1042
if ( ShouldCheckHttpStatus && ! isSuccess )
1040
1043
{
1041
1044
var httpErrorRecord = await GenerateHttpErrorRecordAsync ( httpResponseMessageFormatter , httpRequestMessage ) ;
1045
+ // A reset of the GraphSession Environment is required to avoid side effects
1046
+ ResetGraphSessionEnvironment ( ) ;
1042
1047
ThrowTerminatingError ( httpErrorRecord ) ;
1043
1048
}
1044
1049
await ProcessResponseAsync ( httpResponseMessage ) ;
You can’t perform that action at this time.
0 commit comments