question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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 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:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
waldekmastykarzcommented, Jan 17, 2022

I think in this case we could handle the empty response and assuming it’s an error, show a relevant error message.

1reaction
robdycommented, Jan 17, 2022

Before adding the users to group, you may have to check the presence of the valid SharePoint group in the web

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 sending patch request. Similarly in m365 teams tab add we’re not checking if the team exists before sending post request.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found