pnp / cli-microsoft365

Manage Microsoft 365 and SharePoint Framework projects on any platform
https://aka.ms/cli-m365
MIT License
882 stars 312 forks source link

➜ m365 spo homesite set throwing Error: Operation is not valid due to the current state of the object. #6066

Open reshmee011 opened 1 month ago

reshmee011 commented 1 month ago

Priority

(Low) Something is a little off

Description

The cmdlet m365 spo homesite set -u https://reshmeeauckloo.sharepoint.com/sites/contosoportal is throwing "Error: Operation is not valid due to the current state of the object."

image

Steps to reproduce

Go to Office 365 admin center -> Settings -> Viva -> Viva connections Ensure there are multiple Viva Connections. In my instance I have

m365 spo homesite set -u https://reshmeeauckloo.sharepoint.com/sites/contosoportal is throwing "Error: Operation is not valid due to the current state of the object."

Expected results

The home site is set without any errors thrown

Actual results

The home site is not set and error"Error: Operation is not valid due to the current state of the object." is thrown

Diagnostics

No response

CLI for Microsoft 365 version

v7.9.0

nodejs version

v20.8.1

Operating system (environment)

Windows

Shell

PowerShell

cli doctor

No response

Additional Info

No response

reshmee011 commented 1 month ago

I can work on the bug after it has been reviewed.

milanholemans commented 1 month ago

Thank you for reporting this @reshmee011, your help is much appreciated!

milanholemans commented 1 month ago

@reshmee011 since it's possible now to specify more than one home site, do you think it would make sense to rename the command to spo homesite add?

reshmee011 commented 1 month ago

spo homesite add will add another homesite which can be a different cmdlet definitely and spo homesite set will update an existing home site with additional values.

If there multiple viva connection experiences are enabled at the tenant, i.e. Tenant Property "IsMultipleVivaConnectionsFlightEnabled", the endpoint UpdateTargetedSite is called. Otherwise SetSPHSiteWithConfiguration is called with the additional properties DraftMode.

milanholemans commented 3 weeks ago

Thank you @reshmee011, sounds like a plan. Let's get this command fixed and see if we can implement a spo homesite add command as well. This would mean that the option vivaConnectionsDefaultStart will have to be required for the spo homesite set command. (breaking change so that's for V8).