Skip to content

Commit 4c3dfd2

Browse files
Copilotpmaytak
andauthored
Fix TokenAcquirerFactory null reference exception when AppContext.BaseDirectory is root path (#3443)
* Initial plan * Fix TokenAcquirerFactory DefineConfiguration null reference issue Co-authored-by: pmaytak <[email protected]> * Add comprehensive tests for DefineConfiguration null handling Co-authored-by: pmaytak <[email protected]> * Remove not useful tests. --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: pmaytak <[email protected]>
1 parent c6d5840 commit 4c3dfd2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Microsoft.Identity.Web.TokenAcquisition/TokenAcquirerFactory.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ private IConfiguration ReadConfiguration()
247247
/// <returns>Returns the base path for configuration files</returns>
248248
protected virtual string DefineConfiguration(IConfigurationBuilder builder)
249249
{
250-
return Path.GetDirectoryName(AppContext.BaseDirectory)!;
250+
string? basePath = Path.GetDirectoryName(AppContext.BaseDirectory);
251+
return !string.IsNullOrEmpty(basePath) ? basePath : AppContext.BaseDirectory;
251252
}
252253

253254
ITokenAcquirerFactory implementation;

0 commit comments

Comments
 (0)