cli-microsoft365 icon indicating copy to clipboard operation
cli-microsoft365 copied to clipboard

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

Open reshmee011 opened this issue 1 year ago • 5 comments

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

  • https://reshmeeauckloo.sharepoint.com/sites/contosoportal
  • https://reshmeeauckloo.sharepoint.com/sites/TheLanding

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 avatar May 29 '24 06:05 reshmee011

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

reshmee011 avatar May 30 '24 16:05 reshmee011

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

milanholemans avatar Jun 02 '24 21:06 milanholemans

@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?

milanholemans avatar Jun 02 '24 21:06 milanholemans

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.

reshmee011 avatar Jun 03 '24 05:06 reshmee011

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).

milanholemans avatar Jun 11 '24 22:06 milanholemans

@reshmee011 are you still working on this?

milanholemans avatar Sep 22 '24 21:09 milanholemans

@milanholemans: hope you are doing fine. I work on one PR at a time , I am just waiting for the PR I created to be merged before starting to work on this one. Happy to let someone else work on it. I’ll pick up another issue once my current PR is merged.

reshmee011 avatar Sep 22 '24 22:09 reshmee011

Ok, thank you for letting us know. We had a lot of open PRs, but the amount is gradually dropping. We'll try to pick up your open PR ASAP.

milanholemans avatar Sep 23 '24 07:09 milanholemans

@milanholemans: I have started working on the fix. The endpoint to update the home site properties will be UpdateTargetedSite instead of SetSPHSite. There are additional properties that can be supported like audiences properties, draftmode, order. https://learn.microsoft.com/en-us/viva/connections/set-up-admin-center. Shall I write a better spec for review that would work with UpdateTargetedSite endpoint?

I could not spot when the endpoint SetSPHSiteWithConfiguration will be called with vivaConnectionsDefaultStart parameter anymore. Let me know if you are able to find anything.

reshmee011 avatar Nov 09 '24 21:11 reshmee011

Since SharePoint home sites are now quite related to Viva Connections, I'm wondering if we should get rid of the spo homesite commands and move them to viva connections commands. What do you think @pnp/cli-for-microsoft-365-maintainers?

milanholemans avatar Nov 09 '24 22:11 milanholemans

@milanholemans : I will wait for further direction how to approach the fix as it is a full refactor of the functionality to work with the changes of home site linked to viva connections.

reshmee011 avatar Nov 10 '24 09:11 reshmee011

Since SharePoint home sites are now quite related to Viva Connections, I'm wondering if we should get rid of the spo homesite commands and move them to viva connections commands. What do you think @pnp/cli-for-microsoft-365-maintainers?

To me, they're independent. You define the home site separate of VC. I vote we keep them separate.

waldekmastykarz avatar Nov 12 '24 06:11 waldekmastykarz

In the UI, when you want to set up a home site, you are redirected to the Viva Connections admin page. But all right, let's keep it separate.

milanholemans avatar Nov 12 '24 08:11 milanholemans

@milanholemans : How shall we proceed? Start with writing the specs how to fix the bug with the endpoint UpdateTargetedSite with a follow up cmdlet to add home site using the endpoint AddHomeSite?.

reshmee011 avatar Nov 12 '24 22:11 reshmee011

@milanholemans : How shall we proceed? Start with writing the specs how to fix the bug with the endpoint UpdateTargetedSite with a follow up cmdlet to add home site using the endpoint AddHomeSite?.

Looks like a good idea indeed. Thanks.

milanholemans avatar Nov 13 '24 21:11 milanholemans

@reshmee011, this issue is a duplicate of #6489, right?

milanholemans avatar Aug 05 '25 09:08 milanholemans

Yes it is duplicate, this one is for the bug and #6489 for enhancement.

reshmee011 avatar Aug 05 '25 09:08 reshmee011

Ok since we will fix it in #6489 anyway, let's close this one.

milanholemans avatar Aug 05 '25 10:08 milanholemans

Sounds good. Happy for it to be closed.

reshmee011 avatar Aug 05 '25 10:08 reshmee011