Hi,
Using the Atlassian SDK v12.0.0 via Nuget, in a .Net Core 2.0 console app. Sometimes between February 5th, 2020 and February 12th, it stopped working with the following exception:
NullReferenceException Object reference not set to an instance of an object.
at Atlassian.Jira.Remote.SingleObjectCustomFieldValueSerializer.FromJson(JToken json) in
\code\atlassian.net-sdk\Atlassian.Jira\Remote\CustomFieldValueSerializers.cs:line 20
at Atlassian.Jira.Remote.RemoteIssueJsonConverter.<GetCustomFieldValuesFromObject>b__9_1(JProperty field) in
\code\atlassian.net-sdk\Atlassian.Jira\Remote\RemoteIssueJsonConverter.cs:line 164
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)
at Atlassian.Jira.Remote.RemoteIssueJsonConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer) in
\code\atlassian.net-sdk\Atlassian.Jira\Remote\RemoteIssueJsonConverter.cs:line 71
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at Atlassian.Jira.Remote.IssueService.<>c__DisplayClass20_0.<GetIssuesFromJqlAsync>b__2(JObject issueJson) in
\code\atlassian.net-sdk\Atlassian.Jira\Remote\IssueService.cs:line 128
at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
at xxxxxxx.JiraService.<GetTicketsWithoutPaging>d__25.MoveNext() in xxxxxxx\JiraService.cs:line 189
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at xxxxxxx.JiraService.<GetTicketsForEpic>d__21.MoveNext() in xxxxxxx\JiraService.cs:line 95
Running with the source code, it throws here:
public class SingleObjectCustomFieldValueSerializer : ICustomFieldValueSerializer
{
private readonly string _propertyName;
public SingleObjectCustomFieldValueSerializer(string propertyName)
{
this._propertyName = propertyName;
}
public string[] FromJson(JToken json)
{
return new string[1] { json[this._propertyName].ToString() }; // <---- throws here ######
}
and _property name is set to "name". This "name" is set in JiraRestClientSettings.cs, here:
public JiraRestClientSettings()
{
this.Cache = new JiraCache();
JsonSerializerSettings = new JsonSerializerSettings()
{
NullValueHandling = NullValueHandling.Ignore
};
this.CustomFieldSerializers = new Dictionary<string, ICustomFieldValueSerializer>();
this.CustomFieldSerializers.Add(GetBuiltInType("labels"), new MultiStringCustomFieldValueSerializer());
this.CustomFieldSerializers.Add(GetBuiltInType("float"), new FloatCustomFieldValueSerializer());
this.CustomFieldSerializers.Add(GetBuiltInType("userpicker"), new SingleObjectCustomFieldValueSerializer("name")); // <--- HERE ######
this.CustomFieldSerializers.Add(GetBuiltInType("grouppicker"), new SingleObjectCustomFieldValueSerializer("name"));
this.CustomFieldSerializers.Add(GetBuiltInType("project"), new SingleObjectCustomFieldValueSerializer("key"));
Changing this line to use "displayName" instead of "name" fixes my problem and I can run my application:
this.CustomFieldSerializers.Add(GetBuiltInType("userpicker"), new SingleObjectCustomFieldValueSerializer("displayName"));I have read these articles:
https://confluence.atlassian.com/cloud/blog/2018/06/say-goodbye-to-usernames-in-atlassian-cloud
https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide/
https://community.developer.atlassian.com/t/announcement-reminder-on-removal-of-user-names/
and also this community question:
https://community.atlassian.com/t5/Jira-questions/JIRA-REST-API-missing-parameters/qaq-p/1302944
However, this code is inside the SDK, it's not my code, all I'm doing is this:
IPagedQueryResult<Issue> pagedTickets = await _jira.Issues.GetIssuesFromJqlAsync(jql, 100, startAt);
foreach (var item in pagedTickets)
{
Console.WriteLine(item.Key);
}
(where _jira is created by a call to Jira.CreateRestClient("https://xxxxxx.atlassian.net",......)
My jql is listing tickets in an epic, I am not using usernames in the query, nor want usernames., I have a "Tester" Custom Field on my issues, which allows one user to be picked (similar to Assignee), which I think is the cause of the use of the SingleObjectCustomFieldValueSerializer and GetBuiltInType("userpicker").
How can it be fixed? is there a workaround?