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')
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: https://github.com/pnp/cli-microsoft365/blob/309a9b850e70fa4410150a5ec27325dbc7c8808d/src/m365/entra/commands/app/app-permission-remove.ts#L185-L186, 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.