Why does the text ~ search syntax pick up the previous version of a post edited through the API?

Hello,

My organization has developed a script to export JIRA issues into an XML format, pass them through translation software, and then use the API to edit the JIRA issues to post the translations.

Content is marked as needing translation by adding a mention to a specific account ("accountname" below). We have a query that looks for these issues, something like:

project in (XXX) AND text ~ accountname

The API is successfully able to post the translation, which involves editing the target item (description or comment) to delete the request mention and paste in the translation content. However, after we do this, the issue still shows up in the query, even though the "accountname" text has been removed from the entire issue.

We verified the JSON and found that the only place the text still exists is in an "oldDisplayValue" field:

 "oldDisplayValue" : "Testing auto-translation\r\n\r\n[~accountname]",

We want to continue to use the query as a visual check to make sure that all of the issues marked for translation have been picked up and handled, but because of the false positives, we currently have to go to each post after the API edits it and do another manual edit (just open it and save so the "last edited" user changes). This removes it from the query.

Anybody know why this is not working?

1 answer

0 votes

Hi Dillon,

Do you use REST API or Java API (say, with Script Runner)? One case where this would happen is if you somehow make the changes without reindexing the issue. Please check that or post the code of how exactly you are updating the issue.

I'm also intrigued by "oldDisplayValue". Could you please post a larger part of JSON around this property, up to the field level?

Cheers,
Igor

Igor, thanks for the response. I'm not actually the programmer myself, but here's the info I received. We use the REST API.

HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest; request.ContentType = "application/json"; request.Method = method; // POST   if (data != null) {     using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))     {         writer.Write(data);     } }

 

“data” consists of something like the following. Each of those are pushed in separate chunk. (e.g. in the case of the following, it makes three “writes” to the post, to /rest/api/latest/issue/[postid]  

{"update": {"summary": [{"set": "Test | Test"}]}}  

{"update": {"description": [{"set": "Test\r\n\r\n----\r\n\r\nTest\r\n{color:lightgray}Test{color}"}]}}  

{"update": {"comment": [{"edit": {"id":[id],"body":"Test\r\n\r\n----\r\n\r\nTest\r\n{color:lightgray}Test{color}"} }]}}

The programmer also said that he only sees an option to reindex the whole site, which would take too long and can only be done by a site admin.

Here's a bit more of the JSON:

        "author" : "XXX",
        "created" : 1495678441000,
        "items" : [ {
          "fieldType" : "jira",
          "field" : "description",
          "oldDisplayValue" : "Testing auto-translation\r\n\r\n[~accountname]",
          "newDisplayValue" : "Testing auto-translation\r\n\r\n----\r\n\r\n自動翻訳テスト\r\n{color:lightgray}#t9n{color}"

 

Thanks!

Hi Dillon,

Thanks for the details. The REST API should reindex the issue, so I guess my idea was not related to this case.

The "oldDisplayValue" seems to come from the history of changes, which is not searched with "text ~".

Have you tried "description ~ value" instead of "text ~ value"?

Kind regards,
Igor

Hi Igor, thanks for your prompt responses!

We are also looking for mentions in comments, so just "description ~ value" wouldn't work, but we did originally try with "(description ~ value OR comment ~ value OR summary ~ value)" and narrowed it down to picking up on "comment ~ value". That may be relevant information, actually, if the only part of an issue we have touched with the API is the description, it does NOT return a false positive in the query. This only occurs for the comments, and according to the JSON file, oldDisplayValue is the only place in the comment that the string occurs, so it appears to us as though something is causing "text ~ value" (or "comment ~ value") to pick that up.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,849 views 12 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot