Python JIRA API

kanchana wijerathna June 5, 2020

We have developed some code to contact JIRA using Python and jira2.0 python packge

anyway sometimes we got "We cannot instantiate empty resources: {}" error in the log. any clues on this ?

1 answer

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 6, 2020

We can't help you with a problem that's in your own code, especially if you have not given us the code.

You'll need to debug why the resource is empty in your code.

kanchana wijerathna June 7, 2020

Hi Nic,

 

Error coming from one of below methods

 

def sync_comments(issueSource,issueDestination,instanceSource,instanceDestionation,last_run_time,last_run_time_upper_bound,side):
logging.info("Synchronizing issue comments - new issues")
try:
issue = instanceSource.issue(issueSource.key)
comments = issue.fields.comment.comments
for comment in comments:

if comment.author.name != 'lse_jira_sync_user' and comment.author.name != 'lse_sync_user':
instanceDestionation.add_comment(issueDestination, build_comment(comment, side))
except JIRAError as e:
logging.info(e)
print(e)

def sync_attachments(issueSource,issueDestination,instanceSource,instanceDestionation,last_run_time,last_run_time_upper_bound):
logging.info("Synchronizing issue attachments - new issues")
try:
issue_source = instanceSource.issue(issueSource.key)
for attachment in issue_source.fields.attachment:
if attachment.author.name != 'lse_jira_sync_user' and attachment.author.name != 'lse_sync_user':

image = attachment.get()
jira_filename = attachment.filename
with open("attachments/" + jira_filename, 'wb') as out_file:
out_file.write(image)
with open("attachments/" + jira_filename, 'rb') as f:
instanceDestionation.add_attachment(issueDestination,f)
if os.path.exists("attachments/" + jira_filename):
os.remove("attachments/" + jira_filename)

except JIRAError as e:
logging.info(e)
print(e)
kanchana wijerathna June 7, 2020

Also this is not for all tickets, but sometimes we are getting this error, and it was not there in the staging server. this happens only after production push

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 8, 2020

You'll need to go through your code to work out where the empty resource is being returned.

Suggest an answer

Log in or Sign up to answer