|
4 | 4 | using Microsoft.Agents.A365.DevTools.Cli.Constants; |
5 | 5 | using Microsoft.Agents.A365.DevTools.Cli.Exceptions; |
6 | 6 | using Microsoft.Agents.A365.DevTools.Cli.Helpers; |
| 7 | +using Microsoft.Agents.A365.DevTools.Cli.Services.Helpers; |
7 | 8 | using Microsoft.Extensions.Logging; |
8 | 9 | using System.Text.Json; |
9 | 10 | using System.Text.Json.Nodes; |
@@ -168,7 +169,8 @@ public async Task EnsureRedirectUrisAsync( |
168 | 169 | return; |
169 | 170 | } |
170 | 171 |
|
171 | | - var response = JsonNode.Parse(appCheckResult.StandardOutput); |
| 172 | + var sanitizedOutput = JsonDeserializationHelper.CleanAzureCliJsonOutput(appCheckResult.StandardOutput); |
| 173 | + var response = JsonNode.Parse(sanitizedOutput); |
172 | 174 | var apps = response?["value"]?.AsArray(); |
173 | 175 |
|
174 | 176 | if (apps == null || apps.Count == 0) |
@@ -307,7 +309,8 @@ public async Task EnsureRedirectUrisAsync( |
307 | 309 | } |
308 | 310 | } |
309 | 311 |
|
310 | | - var appResponse = JsonNode.Parse(appCheckResult.StandardOutput); |
| 312 | + var sanitizedOutput = JsonDeserializationHelper.CleanAzureCliJsonOutput(appCheckResult.StandardOutput); |
| 313 | + var appResponse = JsonNode.Parse(sanitizedOutput); |
311 | 314 | var apps = appResponse?["value"]?.AsArray(); |
312 | 315 |
|
313 | 316 | if (apps == null || apps.Count == 0) |
@@ -409,7 +412,8 @@ private async Task<Dictionary<string, string>> ResolvePermissionIdsAsync(string |
409 | 412 | return permissionNameToIdMap; |
410 | 413 | } |
411 | 414 |
|
412 | | - var graphSpResponse = JsonNode.Parse(graphSpResult.StandardOutput); |
| 415 | + var sanitizedOutput = JsonDeserializationHelper.CleanAzureCliJsonOutput(graphSpResult.StandardOutput); |
| 416 | + var graphSpResponse = JsonNode.Parse(sanitizedOutput); |
413 | 417 | var graphSps = graphSpResponse?["value"]?.AsArray(); |
414 | 418 |
|
415 | 419 | if (graphSps == null || graphSps.Count == 0) |
@@ -470,7 +474,8 @@ private async Task<HashSet<string>> GetConsentedPermissionsAsync(string clientAp |
470 | 474 | return consentedPermissions; |
471 | 475 | } |
472 | 476 |
|
473 | | - var spResponse = JsonNode.Parse(spCheckResult.StandardOutput); |
| 477 | + var sanitizedOutput = JsonDeserializationHelper.CleanAzureCliJsonOutput(spCheckResult.StandardOutput); |
| 478 | + var spResponse = JsonNode.Parse(sanitizedOutput); |
474 | 479 | var servicePrincipals = spResponse?["value"]?.AsArray(); |
475 | 480 |
|
476 | 481 | if (servicePrincipals == null || servicePrincipals.Count == 0) |
@@ -499,7 +504,8 @@ private async Task<HashSet<string>> GetConsentedPermissionsAsync(string clientAp |
499 | 504 | return consentedPermissions; |
500 | 505 | } |
501 | 506 |
|
502 | | - var grantsResponse = JsonNode.Parse(grantsResult.StandardOutput); |
| 507 | + var sanitizedGrantsOutput = JsonDeserializationHelper.CleanAzureCliJsonOutput(grantsResult.StandardOutput); |
| 508 | + var grantsResponse = JsonNode.Parse(sanitizedGrantsOutput); |
503 | 509 | var grants = grantsResponse?["value"]?.AsArray(); |
504 | 510 |
|
505 | 511 | if (grants == null || grants.Count == 0) |
@@ -549,7 +555,8 @@ private async Task<bool> ValidateAdminConsentAsync(string clientAppId, string gr |
549 | 555 | return true; // Best-effort check - will be verified during first interactive authentication |
550 | 556 | } |
551 | 557 |
|
552 | | - var spResponse = JsonNode.Parse(spCheckResult.StandardOutput); |
| 558 | + var sanitizedOutput = JsonDeserializationHelper.CleanAzureCliJsonOutput(spCheckResult.StandardOutput); |
| 559 | + var spResponse = JsonNode.Parse(sanitizedOutput); |
553 | 560 | var servicePrincipals = spResponse?["value"]?.AsArray(); |
554 | 561 |
|
555 | 562 | if (servicePrincipals == null || servicePrincipals.Count == 0) |
@@ -579,7 +586,8 @@ private async Task<bool> ValidateAdminConsentAsync(string clientAppId, string gr |
579 | 586 | return true; // Best-effort check |
580 | 587 | } |
581 | 588 |
|
582 | | - var grantsResponse = JsonNode.Parse(grantsCheckResult.StandardOutput); |
| 589 | + var sanitizedGrantsOutput = JsonDeserializationHelper.CleanAzureCliJsonOutput(grantsCheckResult.StandardOutput); |
| 590 | + var grantsResponse = JsonNode.Parse(sanitizedGrantsOutput); |
583 | 591 | var grants = grantsResponse?["value"]?.AsArray(); |
584 | 592 |
|
585 | 593 | if (grants == null || grants.Count == 0) |
|
0 commit comments