Skip to content

Commit 8aea6a6

Browse files
Populate RegionDetails on failure unconditionally, matching success path
Addresses PR review: the success path (UpdateTelemetry) always calls CreateRegionDetails, so RegionDetails is non-null even when no region is used (RegionOutcome.None). Drop the failure-path guard so both paths behave identically. Updates the non-regional test to assert RegionOutcome.None. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 3f021d0 commit 8aea6a6

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/client/Microsoft.Identity.Client/Internal/Requests/RequestBase.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
using Microsoft.Identity.Client.Cache.Items;
1515
using Microsoft.Identity.Client.Core;
1616
using Microsoft.Identity.Client.Instance.Discovery;
17-
using Microsoft.Identity.Client.Region;
1817
using Microsoft.Identity.Client.OAuth2;
1918
using Microsoft.Identity.Client.TelemetryCore.Internal.Events;
2019
using Microsoft.Identity.Client.Utils;
@@ -304,7 +303,7 @@ private static AuthenticationResultMetadata CreateFailureMetadata(ApiEvent apiEv
304303
CachedAccessTokenCount = apiEvent.CachedAccessTokenCount,
305304
CacheRefreshReason = apiEvent.CacheInfo,
306305
TokenEndpoint = apiEvent.TokenEndpoint,
307-
RegionDetails = apiEvent.RegionOutcome == RegionOutcome.None ? null : CreateRegionDetails(apiEvent),
306+
RegionDetails = CreateRegionDetails(apiEvent),
308307
};
309308
}
310309

tests/Microsoft.Identity.Test.Unit/PublicApiTests/ConfidentialClientApplicationTests.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -489,12 +489,13 @@ public async Task ClientCreds_FailedRequest_CarriesFailureMetadata_Async()
489489
() => cca.AcquireTokenForClient(TestConstants.s_scope.ToArray()).ExecuteAsync())
490490
.ConfigureAwait(false);
491491

492-
// Assert - the failed attempt still surfaces metadata on the exception. Only data that was
493-
// actually captured is populated: the token endpoint was resolved, but no region was
494-
// configured so RegionDetails is left null.
492+
// Assert - the failed attempt still surfaces metadata on the exception. The token endpoint
493+
// was resolved; RegionDetails is populated with RegionOutcome.None (no region configured),
494+
// consistent with the success path.
495495
Assert.IsNotNull(ex.AuthenticationResultMetadata);
496496
Assert.IsNotNull(ex.AuthenticationResultMetadata.TokenEndpoint);
497-
Assert.IsNull(ex.AuthenticationResultMetadata.RegionDetails);
497+
Assert.IsNotNull(ex.AuthenticationResultMetadata.RegionDetails);
498+
Assert.AreEqual(Microsoft.Identity.Client.Region.RegionOutcome.None, ex.AuthenticationResultMetadata.RegionDetails!.RegionOutcome);
498499
}
499500
}
500501

0 commit comments

Comments
 (0)