You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In one of my tenants, calling SiteCollectionManager.GetSiteCollectionAdminsAsync throws a NullReferenceException, from debugging within the PnP code, I've narrowed it down (I believe) to the deserialization of a Site object in this stack trace:
at PnP.Core.Test.Services.Core.CSOM.Utils.CustomConverters.SPGuidConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in /_/src/sdk/PnP.Core/Services/Core/CSOM/Utils/CustomConverters/SPGuidConverter.cs:line 11
at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo jsonTypeInfo, Nullable`1 actualByteCount)
at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo jsonTypeInfo)
at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
at PnP.Core.Services.Core.CSOM.Utils.CSOMResponseHelper.ProcessResponse[T](String response, Int64 propertyIdentifier) in /_/src/sdk/PnP.Core/Services/Core/CSOM/Utils/CSOMResponseHelper.cs:line 17
at PnP.Core.Admin.Services.Core.CSOM.Requests.Tenant.GetSiteByUrlRequest.ProcessResponse(String response) in /_/src/sdk/PnP.Core.Admin/Services/Core/CSOM/Requests/Tenant/GetSiteByUrlRequest.cs:line 235
at PnP.Core.Services.BatchClient.ProcessCsomBatchResponse(CsomBatch csomBatch, String batchResponse, HttpStatusCode statusCode) in /_/src/sdk/PnP.Core/Services/Core/BatchClient.cs:line 2313
at PnP.Core.Services.BatchClient.ExecuteCsomBatchAsync(Batch batch) in /_/src/sdk/PnP.Core/Services/Core/BatchClient.cs:line 2243
at PnP.Core.Services.BatchClient.ExecuteBatch(Batch batch) in /_/src/sdk/PnP.Core/Services/Core/BatchClient.cs:line 350
at PnP.Core.Model.BaseDataModel`1.RequestAsync(ApiCall apiCall, HttpMethod method, String operationName) in /_/src/sdk/PnP.Core/Model/Base/BaseDataModel.cs:line 965
at PnP.Core.Model.BaseDataModel`1.RawRequestAsync(ApiCall apiCall, HttpMethod method, String operationName) in /_/src/sdk/PnP.Core/Model/Base/BaseDataModel.cs:line 1021
at PnP.Core.Admin.Model.SharePoint.SiteCollectionManagement.GetSiteCollectionAdminsAsync(PnPContext context, Uri siteUrl, VanityUrlOptions vanityUrlOptions) in /_/src/sdk/PnP.Core.Admin/Model/SharePoint/Core/Internal/SiteCollectionManagement.cs:line 273
at PnP.Core.Admin.Model.SharePoint.SiteCollectionManager.GetSiteCollectionAdminsAsync(Uri site, VanityUrlOptions vanityUrlOptions) in /_/src/sdk/PnP.Core.Admin/Model/SharePoint/Core/Internal/SiteCollectionManager.cs:line 189
viewing the raw JSON, I believe this is the cause, the API returns: "SensitivityLabelId": null, and the deserializer expects to be able to deserialize this into a guid:
In my other tenant, this does not occur, and I'm not sure why. All of the other Guid-typed properties return "\\/Guid(00000000-0000-0000-0000-000000000000)\\/" (or an actual guid), which the deserializer is able to handle. I think SPGuidConverter needs to be able to handle null values (and just deserialize them to empty guid.)
Steps to reproduce
(I'm not sure the exact tenant configuration that causes this - one of my tenants does not encounter this, but the other one encounters it on many/most sites that I try to process. I do not have access to the SP admin console to check again settings.) - The absence of a sensitivity label on the site might be the cause? We have no sensitivity labels configured in this tenant.
Execute code, such as: var admins = await context.GetSiteCollectionManager().GetSiteCollectionAdminsAsync("site url");
Observe NullReferenceException thrown by the SPGuidConverter
@Sean-LM : thanks for the detailed error report, this makes fixing things much easier 👍
I've pushed a fix to make the GUID parsing more reliable, this should help with your issue. Please give this a try with the next nightly build (version 1.6.74 or higher) and if things still not work, then please re-open this issue or create a new one.
Thanks for using PnP Core SDK and providing feedback.
Category
Describe the bug
In one of my tenants, calling
SiteCollectionManager.GetSiteCollectionAdminsAsync
throws a NullReferenceException, from debugging within the PnP code, I've narrowed it down (I believe) to the deserialization of aSite
object in this stack trace:viewing the raw JSON, I believe this is the cause, the API returns:
"SensitivityLabelId": null,
and the deserializer expects to be able to deserialize this into a guid:pnpcore/src/sdk/PnP.Core/Model/SharePoint/Core/Internal/Site.cs
Line 117 in 2f54c02
pnpcore/src/sdk/PnP.Core/Services/Core/CSOM/Utils/CustomConverters/SPGuidConverter.cs
Line 11 in 2f54c02
In my other tenant, this does not occur, and I'm not sure why. All of the other Guid-typed properties return
"\\/Guid(00000000-0000-0000-0000-000000000000)\\/"
(or an actual guid), which the deserializer is able to handle. I thinkSPGuidConverter
needs to be able to handle null values (and just deserialize them to empty guid.)Steps to reproduce
(I'm not sure the exact tenant configuration that causes this - one of my tenants does not encounter this, but the other one encounters it on many/most sites that I try to process. I do not have access to the SP admin console to check again settings.) - The absence of a sensitivity label on the site might be the cause? We have no sensitivity labels configured in this tenant.
var admins = await context.GetSiteCollectionManager().GetSiteCollectionAdminsAsync("site url");
NullReferenceException
thrown by theSPGuidConverter
Expected behavior
Call to
GetSiteCollectionAdminsAsync
succeeds.Environment details (development & target environment)
Additional context
n/a
Thanks for your contribution! Sharing is caring.
The text was updated successfully, but these errors were encountered: