Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetSiteCollectionPropertiesAsync throw an exception #703

Closed
1 task done
FlorianLabranche opened this issue Jan 3, 2022 · 9 comments
Closed
1 task done

GetSiteCollectionPropertiesAsync throw an exception #703

FlorianLabranche opened this issue Jan 3, 2022 · 9 comments
Assignees
Labels
area: model 📐 Related to the core SDK models bug Something isn't working

Comments

@FlorianLabranche
Copy link

Category

  • Bug

Describe the bug

Getting site collection properties throw the following exception :

System.ArgumentOutOfRangeException: 'Year, Month, and Day parameters describe an un-representable DateTime.'

Steps to reproduce

Below code snippet can be used to repro the issue:

using var context = await pnpContextFactory.CreateAsync("SiteToWorkWith");

var siteUri = new Uri($"https://contoso.sharepoint.com/sites/{Guid.NewGuid()}");
var communicationSiteToCreate = new CommunicationSiteOptions(siteUri, "New site")
{
    Description = "Test from PnP",
    Language = PnP.Core.Admin.Model.SharePoint.Language.English,
    Owner = "[email protected]"
};

// Create site collection
using var newSiteContext = await context.GetSiteCollectionManager().CreateSiteCollectionAsync(communicationSiteToCreate);

// Below line throw an exception : "System.ArgumentOutOfRangeException: 'Year, Month, and Day parameters describe an un-representable DateTime.'"
var siteProperties = await context.GetSiteCollectionManager().GetSiteCollectionPropertiesAsync(siteUri);

Environment details (development & target environment)

  • SDK version: 1.5.15-nightly
  • OS: Windows 10
  • SDK used in: Console App
  • Framework: .NET 6.0
  • Browser(s): N.A.
  • Tooling: Visual Studio 2022

Additional context

The above code snippet was working fine last week.
It seems to be related with CSOMDateConverter but I couldn't get deeper in the investigation.

Thank you for the great work on this project ! 🙏

@jansenbe jansenbe self-assigned this Jan 3, 2022
@jansenbe jansenbe added area: model 📐 Related to the core SDK models question Further information is requested labels Jan 3, 2022
@jansenbe
Copy link
Contributor

jansenbe commented Jan 3, 2022

@FlorianLabranche : does this happen for any site collection or just for a newly created one? Do you happen to have a stack trace? If you catch the exception and to a .ToString() all needed error info should be available.

@jansenbe
Copy link
Contributor

jansenbe commented Jan 3, 2022

@FlorianLabranche : I can reproduce the issue. Thanks for bringing it up, fill work on a fix. For some reason CSOM returns Date(2022,0,3,13,32,4,77) as last change date for the created site...note the 0.

@jansenbe jansenbe added bug Something isn't working and removed question Further information is requested labels Jan 3, 2022
@FlorianLabranche
Copy link
Author

@jansenbe : Thank you for your quick response.

It happens on every site collection. I tried on sites created on 12/24/21 and 10/26/21.

Here is the full stack trace :

System.ArgumentOutOfRangeException: Year, Month, and Day parameters describe an un-representable DateTime.
at System.DateTime..ctor(Int32 year, Int32 month, Int32 day, Int32 hour, Int32 minute, Int32 second, Int32 millisecond)
at PnP.Core.Services.Core.CSOM.Utils.DateHelpers.DateConstuctorStrategy.ConverDate(String dateValue)
at PnP.Core.Services.Core.CSOM.Utils.DateHelpers.CSOMDateConverter.ConverDate(String dateValue)
at PnP.Core.Services.Core.CSOM.Utils.CustomConverters.DateTimeConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
at System.Text.Json.Serialization.JsonConverter1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.Metadata.JsonPropertyInfo1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.JsonConverter1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.JsonConverter1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan1 utf8Json, JsonTypeInfo jsonTypeInfo, Nullable1 actualByteCount) at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan1 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)
at PnP.Core.Admin.Services.Core.CSOM.Requests.Tenant.GetSitePropertiesRequest.ProcessResponse(String response)
at PnP.Core.Services.BatchClient.ProcessCsomBatchResponse(CsomBatch csomBatch, String batchResponse, HttpStatusCode statusCode)
at PnP.Core.Services.BatchClient.ExecuteCsomBatchAsync(Batch batch)
at PnP.Core.Services.BatchClient.ExecuteBatch(Batch batch)
at PnP.Core.Model.BaseDataModel1.RequestAsync(ApiCall apiCall, HttpMethod method, String operationName) at PnP.Core.Model.BaseDataModel1.RawRequestAsync(ApiCall apiCall, HttpMethod method, String operationName)
at PnP.Core.Admin.Model.SharePoint.SiteCollectionManagement.GetSiteCollectionPropertiesByUrlAsync(PnPContext context, Uri siteUrl, Boolean detailed)
at PnP.Core.Admin.Model.SharePoint.SiteCollectionManager.GetSiteCollectionPropertiesAsync(Uri site)
at Program.

$(String[] args) in C:\Sources\PoC\PnP.Core.Demo\PnP.Core.Demo\Program.cs:line 33

@jansenbe
Copy link
Contributor

jansenbe commented Jan 3, 2022

@FlorianLabranche : this feels like a SharePoint API bug to me. I've added additional safety measures for this case and will trigger the creation of a new nightly build. Within half an hour you can test again with the newest nightly.

@jansenbe
Copy link
Contributor

jansenbe commented Jan 3, 2022

@FlorianLabranche : 1.5.16 is available for testing.

@FlorianLabranche
Copy link
Author

@jansenbe : great ! Thank you for the reactivity.

I don't know if it can be of any help, but with the following code I have the right date:

using var adminContext = await pnpContextFactory.CreateAsync(new Uri("https://contoso-admin.sharepoint.com"));
using ClientContext csomContext = PnPCoreSdk.Instance.GetClientContext(adminContext);

var tenant = new Tenant(csomContext);
var properties = tenant.GetSitePropertiesByUrl("https://contoso.sharepoint.com/sites/e051703b-bdad-45e1-ac50-e8e3a4205014", true);
tenant.Context.Load(properties);
tenant.Context.ExecuteQueryAsync().Wait();

image

@jansenbe
Copy link
Contributor

jansenbe commented Jan 3, 2022

@FlorianLabranche : thanks for the info, good to see that asking for "details" will get this property correctly filled. Still weird this suddenly changed server side, I'll see if I can find out more

@FlorianLabranche
Copy link
Author

@jansenbe this issue is happening again (since monday 29/03).
Should I open a new issue ?

I was sill working on 1.5.16-nightly and updating to 1.5.104 changes nothing.

@jansenbe
Copy link
Contributor

@FlorianLabranche : please open a new issue with the new stack trace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: model 📐 Related to the core SDK models bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants