pnp / pnpcore

The PnP Core SDK is a modern .NET SDK designed to work for Microsoft 365. It provides a unified object model for working with SharePoint Online and Teams which is agnostic to the underlying API's being called
https://aka.ms/pnp/coresdk/docs
MIT License
298 stars 192 forks source link

Loading Team Tabs fails with error "System.FormatException: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)." #1407

Closed nicolaor closed 7 months ago

nicolaor commented 7 months ago

Category

Describe the bug

When trying to load team tabs using PnPContext we get the following exception:

Steps to reproduce

This is the code we are executing (the exception happens on line 83) image

Here is the Stacktrace:

System.FormatException: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx). at System.Guid.GuidResult.SetFailure(Boolean overflow, String failureMessageID) at System.Guid.TryParseExactN(ReadOnlySpan1 guidString, GuidResult& result) at System.Guid.TryParseGuid(ReadOnlySpan1 guidString, GuidResult& result) at System.Guid.Parse(ReadOnlySpan1 input) at System.Guid.Parse(String input) at PnP.Core.Services.JsonMappingHelper.GetJsonFieldValue(IDataModelWithContext pnpObject, String fieldName, ApiResponse apiResponse, JsonElement jsonElement, Type propertyType, Boolean useCustomMapping, Func2 fromJsonCasting) at PnP.Core.Services.JsonMappingHelper.FromJsonGraph(TransientObject pnpObject, EntityInfo entity, ApiResponse apiResponse, Func2 fromJsonCasting) at PnP.Core.Services.JsonMappingHelper.FromJson(TransientObject pnpObject, EntityInfo entity, ApiResponse apiResponse, Func2 fromJsonCasting) at PnP.Core.Model.BaseDataModel1.ProcessResponseAsync(ApiResponse apiResponse, Expression1[] expressions) at PnP.Core.Services.JsonMappingHelper.FromJsonGraph(TransientObject pnpObject, EntityInfo entity, ApiResponse apiResponse, Func2 fromJsonCasting) at PnP.Core.Services.JsonMappingHelper.FromJson(TransientObject pnpObject, EntityInfo entity, ApiResponse apiResponse, Func2 fromJsonCasting) at PnP.Core.Services.JsonMappingHelper.MapJsonToModel(BatchRequest batchRequest) at PnP.Core.Services.BatchClient.ProcessGraphRestBatchResponse(Batch batch, String batchResponse) at PnP.Core.Services.BatchClient.ExecuteMicrosoftGraphBatchRequestAsync(Batch batch) at PnP.Core.Services.BatchClient.ExecuteMicrosoftGraphBatchAsync(Batch batch) at PnP.Core.Services.BatchClient.ExecuteBatch(Batch batch) at PnP.Core.Model.BaseDataModel1.BaseRetrieveAsync(ApiCall apiOverride, Func2 fromJsonCasting, Action1 postMappingJson, Expression1[] expressions) at CN365Common.Validation.Validators.CN365Template.ChannelTabs.Validate(PnPContext pnpContext, String channelId) in /home/vsts/work/1/s/CN365Common/Validation/Validators/CN365Template/ChannelTabs.cs:line 83

Based on the PnP model of TeamChannelTab, the Id is expected to be a Guid, but in our case we have multiple Channels where the Tab-Id seems to be an Integer. Here the results from the Graph Request image

Definition in PnP Model image

Expected behavior

Teams Tabs can be loaded into PnP model even if the Tab-Id is not a Guid

Environment details (development & target environment)

Additional context

This behavior seems to affect only older teams, newly created Teams always have use Guids for the Tab Ids The above Team was created in April 2020.

jansenbe commented 7 months ago

Thanks for using PnP Core SDK @nicolaor and reporting this issue. The underlying used graph API indeed returns a string as id, I'll update this in the SDK (will be a small breaking change for folks using this, but will mention this in the release notes).

jansenbe commented 7 months ago

Change is in and will be part of the next nightly build, closing this issue now.