Bug report: Unhandled exception when trying to add user to a non-existent SharePoint group referred to by ID
See original GitHub issueDescription
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 user@contoso.onmicrosoft.com
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
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Sharepoint integration - User cannot be found?? - MSDN
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information ...
Read more >The URL is invalid. It may refer to a ... - SharePoint Stuff
In this post we describe an issue observed where files could not be uploaded or edited in SharePoint 2010 and how to resolve....
Read more >The URL 'shared documents/test.pdf' is invalid but file exists
I upload a file ~7+ MB and editform2.aspx takes my data and upon save I get following error. Can anyone please suggest a...
Read more >What is an unhandled promise rejection? - Stack Overflow
The origin of this error lies in the fact that each and every promise is expected to handle promise rejection i.e. have a...
Read more >Dell EMC NetWorker - Error Message Guide
Authentication warning: the user's OS groups cannot be verified ... Bad or missing record: save set ID <save_set_id>, low water mark <int>,.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think in this case we could handle the empty response and assuming it’s an error, show a relevant error message.
I’m not sure if this is a good idea. We’d potentially add one more request to each command execution, while error handling does not add anything in terms of the performance.
I can imagine it’s not a big deal, though. The question would be - what’s the general approach?
Based on
m365 teams team set
- we’re not checking whether the team exists before sendingpatch
request. Similarly inm365 teams tab add
we’re not checking if the team exists before sendingpost
request.