Sp-dev-docs: Folder Update Errors - UniqueContentTypeOrder/Properties

Created on 7 Aug 2019  路  19Comments  路  Source: SharePoint/sp-dev-docs

Category

  • [ ] Question
  • [ ] Typo
  • [X] Bug
  • [ ] Additional article idea

Expected or Desired Behavior

We've had functional and unchanged CSOM operating against SharePoint Online for months without issue. Sometime between 5 August at noon Eastern (last successful execution) and 6 August at noon Eastern an 'Object reference not set to an instance of an object'
exception began surfacing in two areas [I suspect they're related since they happened concurrently, so for now I'm doing one bug submission. If you'd rather they be separated, that can be accomplished @VesaJuvonen ]. The first area is in setting a folder's UniqueContentTypeOrder and the second is setting a value for a folder's property bag. I suspect both are related since I can see the values for UniqueContentTypeOrder being persisted to the folder's property bag.

Obviously, I'm guessing here, but if Property persistence is an issue and UniqueContentTypeOrder on the back end relies on Property persistence, then I guess it would make sense to have a null object reference exception as it's storage does not return anything.

Microsoft.SharePointOnline.CSOM version 16.1.9021.1200 is being used.

The desired outcome is persisting Folder UniqueContentTypeOrder and Property values.

Observed Behavior

For UniqueContentTypeOrder, upon calling ClientContext ExecuteQuery, a server exception is generated:

Microsoft.SharePoint.Client.ServerException
  HResult=0x80131500
  Message=Object reference not set to an instance of an object.
  Source=Microsoft.SharePoint.Client.Runtime
  StackTrace:
   at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)
   at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()
   at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb)
   at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()

When setting a folder property bag entry, execution completes, but the value is not persisted to the property bag.

Steps to Reproduce

Create a few site content types deriving from Site Page and associate them with the Site Pages library. Configure the Site Pages library to use content types.

// Example for UniqueContentTypeOrder

using (ClientContext ctx = new ClientContext("<some SharePoint Online site collection>"))
{
    ctx.Credentials = new SharePointOnlineCredentials( ... , ... );
    Site site = ctx.Site;
    Web root = ctx.Site.RootWeb;
    ctx.Load(site);
    ctx.Load(root, r => r.AvailableContentTypes, r => r.ServerRelativeUrl);
    ctx.ExecuteQuery();

    List sitePages = root.GetList(root.ServerRelativeUrl + "/sitepages");
    ctx.Load(sitePages.ContentTypes);
    IList<ContentTypeId> order = new List<ContentTypeId>();

    // List ContentTypeIds are referenced for simplicity
    foreach (string ct in new string[] {
        "<sample list content type id 1>", // This is the content type id for the list's first sample content type
        "<sample list content type id 2>", // This is the content type id for the list's second sample content type
        "<sample list content type id 2>"  // This is the content type id for the list's third sample content type
    })
    {
        ContentType found = sitePages.ContentTypes.GetById(ct);
        ctx.Load(found);
        ctx.ExecuteQuery();
        order.Add(found.Id);
    }

    Folder sitePagesRoot = sitePages.RootFolder;
    ctx.Load(sitePagesRoot);
    ctx.Load(sitePagesRoot, r => r.UniqueContentTypeOrder); // Same result whether the UniqueContentTypeOrder is retrieved or not - regardless, it's always null as it has never been assigned before.
    ctx.ExecuteQuery();

    sitePagesRoot.UniqueContentTypeOrder = order;

    sitePagesRoot.Update();
    ctx.ExecuteQuery(); // Get an "Object reference not set to an instance of an object." exception.  Even occurs with an empty IList<ContentTypeId> object.

}

// Example for a folder Properties not being persisted

using (ClientContext ctx = new ClientContext("<some SharePoint Online site collection>"))
{
    ctx.Credentials = new SharePointOnlineCredentials( ... , ... );
    Site site = ctx.Site;
    Web root = ctx.Site.RootWeb;
    ctx.Load(site);
    ctx.Load(root, r => r.ServerRelativeUrl);
    ctx.ExecuteQuery();

    List sitePages = root.GetList(root.ServerRelativeUrl + "/sitepages");
    Folder sitePagesRoot = sitePages.RootFolder;
    ctx.Load(sitePagesRoot.Properties);
    ctx.ExecuteQuery();

    sitePagesRoot.Properties.FieldValues.Add("hello", "world"); // Original code, execution completes, not persisted in property bag
    sitePagesRoot.Properties.FieldValues["hello2"] = "world2"; // execution completes, not persisted in property bag
    //sitePagesRoot.Properties["Hello3"] = "world3";  // For completeness, chucks an "Object reference not set to an instance of an object."  exception

    sitePagesRoot.Update();
    ctx.ExecuteQuery();

}

Thoughts?

Steve

csorest to-be-reviewed bug-suspected

Most helpful comment

I'm experiencing the same "Object reference not set to an instance of an object." error too when calling PnP extension FieldAndContentTypeExtensions.AddContentTypeToListById() and ListExtensions.SetPropertyBagValue() (even if these are PnP extensions, they use CSOM in their implementation).

I can reproduce the issue on an old Legacy Tenant created at https://demos.microsoft.com/environments and on a brand new Demo Tenant created today, but I cannot reproduce the issue on the free 1 year tenant from Office 365 Developer Program, it seems that issue has not propagated yet to all tenants.

Someone seems to have had the same issue too at https://social.technet.microsoft.com/Forums/office/en-US/a25004ba-e6e2-4f43-b8f4-e600b1b2754f/sharepoint-online-listrootfolder-updates-not-working-using-csom-c?forum=sharepointgeneral

If I try changing the order of content types from the UI on the tenant that has the issue, I get the same error message
image

All 19 comments

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

I think I am running into this as well. When I try to set a Property Value on the list with PnP Core C# myList.SetPropertyBagValue("TheKey","TheValue");
I get the "Object reference not set to an instance of an object." exception here: https://github.com/SharePoint/PnP-Sites-Core/blob/f2d6873bcdd29ce02f3b4226f73f7f9802a83826/Core/OfficeDevPnP.Core/Extensions/ListExtensions.cs#L449

I'm also experiencing this issue with UniqueContentTypeOrder - have had code running in our Production environment for several months with no issues, and we encountered the same exception within the last 2-3 days.

I have one more reported issue with errors around content type and property bags as well.

Experienced the exact same error when updating Folder Properties. In multiple production environments with code that hasn't changed the past year without issues.

I have observed same error when you try to update the content type within list from SharePoint UI. e.g. while trying to set a custom content type as default for a generic list.

I'm experiencing the same "Object reference not set to an instance of an object." error too when calling PnP extension FieldAndContentTypeExtensions.AddContentTypeToListById() and ListExtensions.SetPropertyBagValue() (even if these are PnP extensions, they use CSOM in their implementation).

I can reproduce the issue on an old Legacy Tenant created at https://demos.microsoft.com/environments and on a brand new Demo Tenant created today, but I cannot reproduce the issue on the free 1 year tenant from Office 365 Developer Program, it seems that issue has not propagated yet to all tenants.

Someone seems to have had the same issue too at https://social.technet.microsoft.com/Forums/office/en-US/a25004ba-e6e2-4f43-b8f4-e600b1b2754f/sharepoint-online-listrootfolder-updates-not-working-using-csom-c?forum=sharepointgeneral

If I try changing the order of content types from the UI on the tenant that has the issue, I get the same error message
image

Should this be listed as advisory in the Office portal? :|

We have the same error on our productive provisioning Site

We also have this in our production provisioning process. And is now blocking provisioning of our production sites.

This is clearly an issue and based on the information here and in duplicate at https://github.com/SharePoint/PnP-Sites-Core/issues/2352, it can be reproduced even from the UI, which makes it available to get support through standard channels.

I can try to speed up the dev support route, if someone can provide the exact oob CSOM calls which are causing the issue. That would be highly helpful for the internal communications and would clear the confusion... as if the issue is caused with oob APIs, it will be much more higher on the priority than if it's something which only occurs with the open-source PnP extension.

Does anyone has the exact oob CSOM API calls to reproduce this? Thx.

We are starting to see this working again on Tenants that used to be broken. So I guess a fix is rolling out already?

This is clearly an issue and based on the information here and in duplicate at SharePoint/PnP-Sites-Core#2352, it can be reproduced even from the UI, which makes it available to get support through standard channels.

I can try to speed up the dev support route, if someone can provide the exact oob CSOM calls which are causing the issue. That would be highly helpful for the internal communications and would clear the confusion... as if the issue is caused with oob APIs, it will be much more higher on the priority than if it's something which only occurs with the open-source PnP extension.

Does anyone has the exact oob CSOM API calls to reproduce this? Thx.

The demonstration sample code is in this bug report under "Steps to Reproduce" - https://github.com/SharePoint/sp-dev-docs/issues/4438

@percheron1 sorry for missing that, you are absolutely correct. @OliverZeiser - good update. It might be that someone got this through Premier Support and things are already being processed. Let's still follow up on the progress. I'll check internally based on the repro provided above.

I think I'm experiencing the same issue using the Apply-PnPProvisioningTemplate cmdlet as referenced here #4461 . It's occurring on two different tenants with different PnP templates which haven't been modified in a few weeks.

If anyone has a premier support and is still experiencing this issue, please do report the issue with the repro steps for oob API calls - that will reduce the investigation time for the premier support as they don't need to worry about the PnP wrapper - which obviously is using oob API under the covers. We are looking into this internally, but please do report any updates or new sightings. Thx.

There was a premier ticket opened for this (several) and it turned out it was a recent change to the taxonomy event receiver that was turned on recently. It is being addressed by the PG.

I think the issue I referenced above - #4527 - is related. @westleyMS could this event receiver also be responsible for that?

They rolled back the previous change, so it would not be related to the same code change.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

acksoft picture acksoft  路  3Comments

nanddeepn picture nanddeepn  路  3Comments

StfBauer picture StfBauer  路  3Comments

mikeparkie picture mikeparkie  路  3Comments

SteIvanov picture SteIvanov  路  3Comments