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

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

Closed
1 task done
nicolaor opened this issue Feb 26, 2024 · 2 comments
Assignees
Labels
area: model 📐 Related to the core SDK models bug Something isn't working

Comments

@nicolaor
Copy link

Category

  • Bug

Describe the bug

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

  • System.FormatException:Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)

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)

  • SDK version: 1.11.0
  • OS: Linux
  • SDK used in: Azure Function
  • Framework: .NET 6.0

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 jansenbe self-assigned this Feb 28, 2024
@jansenbe jansenbe added bug Something isn't working area: model 📐 Related to the core SDK models labels Feb 28, 2024
@jansenbe
Copy link
Contributor

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
Copy link
Contributor

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

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