Skip to content

Bug report: Unhandled exception when trying to add user to a non-existent SharePoint group referred to by ID #2935

@waldekmastykarz

Description

@waldekmastykarz

Description

When you try to add a user to a non-existent SharePoint group, referring to the group by its ID, we throw an unhandled exception.

Steps to reproduce

m365 spo group user add -u [site_url] --groupId [non-existent group ID] --userName [email protected]

Expected results

Error: group not found

Actual results

/Users/user/github/pnp/cli-microsoft365/dist/cli/Cli.js:436
                if (JSON.stringify(originalProperties) === JSON.stringify(Object.getOwnPropertyNames(logStatement[0]))) {
                                                                                 ^

TypeError: Cannot convert undefined or null to object
    at Function.getOwnPropertyNames (<anonymous>)
    at Function.formatOutput (/Users/user/github/pnp/cli-microsoft365/dist/cli/Cli.js:436:82)
    at Object.log (/Users/user/github/pnp/cli-microsoft365/dist/cli/Cli.js:164:40)
    at /Users/user/github/pnp/cli-microsoft365/dist/m365/spo/commands/group/group-user-add.js:51:20
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Diagnostics

No response

CLI for Microsoft 365 version

Latest from main

nodejs version

v16.13.0

Operating system (environment)

macOS

Shell

zsh

cli doctor

No response

Additional Info

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions