Skip to content

Bug report: entra app permission remove fails when service principal doesn't exist #6291

@waldekmastykarz

Description

@waldekmastykarz

Priority

(Medium) I'm annoyed but I'll live

Description

When you run entra app permission remove --appId 'f1417aa3-bf0b-4cc5-a845-a0b2cf11f690' --applicationPermissions 'https://graph.microsoft.com/Sites.FullControl.All https://microsoft.sharepoint-df.com/Sites.FullControl.All' --revokeAdminConsent --force and the service principal doesn't exist, the command fails with: Error: Cannot read properties of undefined (reading 'id')

Steps to reproduce

Run the command

Expected results

Command completes

Actual results

Command fails with an error

Diagnostics

No response

CLI for Microsoft 365 version

Latest from main

nodejs version

20

Operating system (environment)

macOS

Shell

zsh

cli doctor

No response

Additional Info

Here:

const appServicePrincipal = servicePrincipals.find(sp => sp.appId === appObject.appId);
await this.revokeAdminConsent(appServicePrincipal!, appPermissions, logger);
, we shouldn't assume that the service principal exists. If it turns out it doesn't, we should skip revoking the consent because there's nothing to revoke it on, but we shouldn't fail with an unhandled exception.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions