Priority
(Low) Something is a little off
Description
When in .m365rc.json you specify an Entra app for which you don't have a service principal, running the app permission add --grantAdminConsent command fails with Error: Cannot read properties of undefined (reading 'id')
Steps to reproduce
In .m365rc.json specify an ID of an app that exists in your directory but for which there's no service principal
Expected results
Running app permission add checks if the service principal exists, creates it if necessary, and grants admin consent
Actual results
Error: Cannot read properties of undefined (reading 'id')
Diagnostics
No response
CLI for Microsoft 365 version
Latest from main
nodejs version
v20
Operating system (environment)
macOS
Shell
zsh
cli doctor
No response
Additional Info
In this line:
|
await this.grantAdminConsent(appServicePrincipal!, appPermissions, logger); |
we need to avoid the assumption that the SP exists. We need to check if it does, and creates it if it doesn't, like we do in
|
let appServicePrincipal = servicePrincipals.find(sp => sp.appId === appObject.appId); |
|
if (!appServicePrincipal) { |
|
appServicePrincipal = await this.createServicePrincipal(appObject.appId!, logger); |
|
} |
Priority
(Low) Something is a little off
Description
When in .m365rc.json you specify an Entra app for which you don't have a service principal, running the
app permission add --grantAdminConsentcommand fails withError: Cannot read properties of undefined (reading 'id')Steps to reproduce
In .m365rc.json specify an ID of an app that exists in your directory but for which there's no service principal
Expected results
Running
app permission addchecks if the service principal exists, creates it if necessary, and grants admin consentActual results
Error: Cannot read properties of undefined (reading 'id')
Diagnostics
No response
CLI for Microsoft 365 version
Latest from main
nodejs version
v20
Operating system (environment)
macOS
Shell
zsh
cli doctor
No response
Additional Info
In this line:
cli-microsoft365/src/m365/app/commands/permission/permission-add.ts
Line 106 in 309a9b8
cli-microsoft365/src/m365/entra/commands/app/app-permission-add.ts
Lines 139 to 142 in 309a9b8