Skip to content

Bug report: adding app permission fails when the enterprise app doesn't exist #6112

@waldekmastykarz

Description

@waldekmastykarz

Priority

(Urgent) I can't use the CLI

Description

When you try to add a permission with admin consent to an Entra app, which doesn't have an enterprise app, the command fail with an error.

Steps to reproduce

  • create a new app reg
  • delete the associated enterprise app
  • m365 entra app permission add --appId some_app_id -d https://graph.microsoft.com/Tasks.Read --grantAdminConsent --debug

Expected results

Permission added with 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

The issue is caused by us assuming in the code that there's a matching service principal:

await this.grantAdminConsent(appServicePrincipal!, appPermissions, logger);

To fix this error, we should check if the service principal exists and create it if it doesn't to avoid the error.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions