Occasional error adding attachment to newly created issue

Hello,

I’m hitting an issue using the REST API. We’ve integrated Jira into our application, so that users can report a bug. We use the rest API to create the issue, and then we make another call to the REST api to attach a screen shot to the issue. These are internal tools, so we do this all with the exact same service account.

Creating issues seems to succeed at least 99% of the time.

Attaching the screenshot seems to fail around 50% of the time, with the error:

“Issue does not exist or you do not have permission to see it.”

If this was a permissions issue, then I would suspect the failure would be more consistent.

However, it seems like the issue shoudl definitely exist, because when this occurs, the API call to create the issue has succeeded, and we can view the issue on the website.

Someone suggested adding a delay between the call to create the issue and the call to attach the screen shot… I haven’t tried this yet, because the API is telling me that the issue exists… Is there really some race condition in the JIRA API? It seems like that would be fixed so customers don’t have to add hacks like this, but perhaps I’m wrong.

Thanks,
sam

Hi @SamChristiansen
Unfortunately, the delay is indeed necessary, because the rest API uses a cache that is not yet aware of the existence of the newly created issue (it’s not a real cache in that sense, more like a shallow replica)
We encountered the same issue in JMWE, but a delay of one second was enough.

Thanks for the help!

I added a 1-second delay, and to my surprise, the issue was now 100% consistent! We were never able to attach screen shots any more!

After doing some investigation, it looks like there is a race condition. We had an automation set up which was changing the security level of the issue, and the service account that was trying to attach the screenshot was randomly failing based on whether or not that automation had run.

Hope this saves someone else in the future some time.

thanks,
sam