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 D:\code\atlassian.net-sdk\Atlassian.Jira\Remote\CustomFieldValueSerializers.cs:line 20
at Atlassian.Jira.Remote.RemoteIssueJsonConverter.<GetCustomFieldValuesFromObject>b__9_1(JProperty field) in D:\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 D:\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 D:\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://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?
The answer to my reply is specifically in this page that Dario linked to, as written by Federico:
https://bitbucket.org/farmas/atlassian.net-sdk/src/gdpr/docs/how-to-handle-gdpr-changes.md
Adding the settings fixed the problem:
string acctname = "EMAIL@SOMEWHERE.COM";
string token = "XXXXXXXXXXX";
var settings = new JiraRestClientSettings();
settings.EnableUserPrivacyMode();
_jira = Jira.CreateRestClient("https://XXXXXXX.atlassian.net", acctname, token, settings);
As for the rest of Dario's answer, I can only apologise that I'm using the Atlassian SDK against Jira Cloud, my bad. And I'm sorry that I didn't realise that the Atlassian SDK is maintained elsewhere and I shouldn't have posted a new support request with Atlassian, but directly on that Bitbucket repository Issue section, and also sorry that I used the wrong community. I did my best to search all relevant web pages before posting, as shown on my post, but obviously I didn't search well enough, as everything was indeed already documented. It's as if, if I had read all this, this bug wouldn't have happened. After it was announced that they were making these breaking changes. None of it would have happened if I had use the software as documented/recommended.
It's resolved now, I'm running with alpha3 and the additional settings line.
Hi @Thierry ,
No worries at all and no need to apologize: the community is intended to be used to also discuss unsupported things (for the supported ones you can always open a support request) :)
Actually, I believe I should have used a better wording and just mention that you have way higher chances to get an answer in the developers community than in here (on development related topics), but there are still chances to get a reply in here as well.
For the rest, there are a lot of tools and framework provided by us, 3rd party vendors or just customers like you and therefore it is quite easy to get lost.
Hopefully this clarifies a bit and, again, I hope I didn't give the impression you were doing anything wrong.
Have a nice day!
Dario
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Thierry and @edward.curren ,
I believe that the issue you are talking about was fixed as part of:
Federico Silva Armas REPO OWNER
Hello everyone, I have published a new alpha release that includes all fixes known to date: https://www.nuget.org/packages/Atlassian.SDK/12.1.0-alpha03.It includes documentation that shows how to use the feature: https://bitbucket.org/farmas/atlassian.net-sdk/src/gdpr/docs/how-to-handle-gdpr-changes.md (docs will be eventually merged to master).
Given this, I am going to resolve this issue. If you find any problems with the alpha release, please open a separate issue (use component ‘GDRP’ so I can manage them).
Can you kindly test Atlassian.SDK/12.1.0-alpha03 (or later) and let us know if this solves the issue?
Also, for the future, please notice that:
If you meant to write an app for an Atlassian Cloud product then please see the following guides instead:
This is not the best place to get help on development related questions. The right resources are listed in https://developer.atlassian.com/resources. Specifically:
I hope this helps.
Cheers,
Dario
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Dario. This is exactly the issue I have been facing. I'll grab it and update my code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sent to support today, c# .net core 2 sample code to reproduce issue:
using Atlassian.Jira;
using System;
namespace AtlassianSdkUserBug
{
class Program
{
private static Jira _jira;
static void Main(string[] args)
{
string acctname = "EMAIL@SOMEWHERE.COM";
string token = "XXXXXXXXXXX";
_jira = Jira.CreateRestClient("https://XXXXXXX.atlassian.net", acctname, token);
IPagedQueryResult<Issue> ticketsForEpic = _jira.Issues.GetIssuesFromJqlAsync("\"Epic Link\"=XXX-1234", 100, 0).Result; //proper async taken out for sample code
foreach (Issue ticket in ticketsForEpic)
{
Console.WriteLine(ticket.Key);
}
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've raised support ticket JST-553829 just now.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Thierry,
I've been banging my head against the wall with this one for about a week now and my head hurts.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.