JetBrains / YouTrackSharp

.NET Standard 2.0 Library to access YouTrack API.
https://www.jetbrains.com/youtrack
Apache License 2.0
134 stars 105 forks source link

GetChangeHistory() NullReferenceException in JArray conversion for Change with ProjectActivityItem changed from Null to Something #117

Closed vvkirik1 closed 1 year ago

vvkirik1 commented 2 years ago

Expected behavior

Get proper changeHistory of an issue by IIssuesService.GetChangeHistoryForIssue(issueId).Result

Actual behavior

In YouTrackSharp.Issues.IssuesService => GetChangeHistoryForIssue() at the end conversion from ActivityItem to Change via Change.FromApiEntity() proceeds, during which Activities with type ProjectActivityItem type setting From/To Value property with new JArray creating JObject from Activity.Removed and Activity.Added properties. However, during JObject.FromObject() method ValidationUtils.ArgumentNotNull called which throws NullReferenceException cause of input parameter (Activity.Removed property in my case) being Null

Steps to reproduce the behavior

Try to GetChangeHistoryForIssue() of Issue that has ActivityItem like this:


{ "removed": null, "added": { "numberInProject": 1311, "project": { "shortName": "PRJCT" }, "id": "95-6922", "$type": "DatabaseIssueKey" }, "targetMember": "project", "category": { "id": "ProjectCategory", "$type": "ActivityCategory" }, "timestamp": 1633610245836, "field": { "presentation": "project", "id": "project", "$type": "PredefinedFilterField" }, "id": "0-0.76-8449959", "type": "MODIFY_LINK", "target": { "created": 1633512386476, "usesMarkdown": true, "id": "74-543473", "$type": "Issue" }, "$type": "ProjectActivityItem" }


vvkirik1 commented 2 years ago

Any workarounds tho?

rekolobov commented 1 year ago

My apologies for the extremely late reply, Issue was fixed in the scope of 2022.3.1