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

Fail to read Item when TaxonomyFieldValue.TermGuid is null #1414

Closed
1 task done
czullu opened this issue Mar 8, 2024 · 1 comment
Closed
1 task done

Fail to read Item when TaxonomyFieldValue.TermGuid is null #1414

czullu opened this issue Mar 8, 2024 · 1 comment
Assignees
Labels
area: model 📐 Related to the core SDK models bug Something isn't working

Comments

@czullu
Copy link

czullu commented Mar 8, 2024

Category

  • Bug

Describe the bug

Checking the TaxonomyFieldValue in CSOM i can see that TermGuid is defined as a string.
[Remote]
public string TermGuid
{
get
{
return m_termGuid;
}
set
{
m_termGuid = value;
}
}

The TermId in IFieldTaxonomyValue is defined as Guid

While CSOM is able to return List-Item with
<d:LeadStatus m:type="SP.Taxonomy.TaxonomyFieldValue">
<d:Label>26</d:Label>
<d:TermGuid/>
<d:WssId m:type="Edm.Int32">26</d:WssId>
</d:LeadStatus>

PnP.Core will fail to parse TermGuid and throw an Error:
Type = System.FormatException
Message = One of the identified items was in an invalid format.
Source = System.Text.Json.Rethrowable
TargetSite = System.Guid GetGuid()
HResult = -2146233033
StackTrace = at System.Text.Json.JsonElement.GetGuid()
at PnP.Core.Model.SharePoint.FieldTaxonomyValue.FromJson(JsonElement json)
at PnP.Core.Services.JsonMappingHelper.ProcessSpecialRestFieldTypeAsync(TransientObject pnpObject, String propertyName, JsonElement json)
at PnP.Core.Services.JsonMappingHelper.FromJsonRest(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.FromJsonRest(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.ProcessSharePointRestInteractiveResponse(BatchRequest restRequest, HttpStatusCode statusCode, Dictionary2 responseHeaders, Stream responseContent) at PnP.Core.Services.BatchClient.ExecuteSharePointRestInteractiveAsync(Batch batch) at PnP.Core.Services.BatchClient.ExecuteSharePointRestBatchAsync(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.QueryModel.BaseDataModelExtensions.BaseGetAsync[T](IQueryable1 source, ApiCall apiCall, Expression1[] selectors)
at PnP.Core.Model.SharePoint.ListCollection.GetByServerRelativeUrlAsync(String serverRelativeUrl, Expression`1[] selectors)

Steps to reproduce

Unfortunately i could not find out how to get into this situation yet. First idea was that cloud happen when referred Term is deleted but test shows that Value of TermGuid remains to have the Guid as string. The List is created from a List Template but they not contain values...

Expected behavior

Return the Field as Null if TermGuid is Empty

Environment details (development & target environment)

current dev Branch

@jansenbe jansenbe self-assigned this Mar 12, 2024
@jansenbe jansenbe added bug Something isn't working area: model 📐 Related to the core SDK models labels Mar 12, 2024
@jansenbe
Copy link
Contributor

@czullu : I've made the TermId parsing more resilient and set Guid.Empty when the passed string is not a GUID, hope this fixes things for you. Closing this now, but please re-open when not working and share the new stacktrace

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