Shotgun Jira Bridge throws error 'maximum recursion depth exceeded'

In recent days, I’ve been setting up the Shotgun Jira Bridge. Everything looks good, but as soon as I launch the web service I receive the following error message with a gigantic trace-back.

2019-08-26 14:03:24,802 DEBUG [connectionpool] https://mysite.atlassian.net:443 "POST /rest/auth/1/session HTTP/1.1" 401 None
2019-08-26 14:03:24,814 DEBUG [connectionpool] Starting new HTTPS connection (60): mysite.atlassian.net:443
2019-08-26 14:03:24,937 ERROR [bridge] maximum recursion depth exceeded

Did anyone experience the same behavior? If so, how did you solve it? I’m in the process of debugging it, but I’m thankful for any pointers.

Thank you
Christian

1 Like

This error seems to be related to the following issue described in the GitHub-project for the Jira-package: https://github.com/pycontribs/jira/issues/778

It seems like the authentication mode for the Jira session needs to change (https://github.com/shotgunsoftware/sg-jira-bridge/blob/master/sg_jira/bridge.py#L70), ‘basic_auth’ instead of just ‘auth’.

Is this a valid solution or should I expect further issues?

Indeed that is the issue. The Shotgun Jira Bridge was initially designed for Jira Server but worked with Jira Cloud as well. This is… until Atlassian made some major GDPR changes that deprecated cookie-based authentication. (see this post ).

We’re working on a PR for it and hope to have it available soonish :slight_smile:

4 Likes

Are you aware of other areas where I may need to change the implementation. Currently I’m working my way through the code from one error to the next. Right now the Shotgun Jira Bridge tells me that a project with the given key doesn’t exist.

JIRAError: JiraError HTTP 404 url: https://mysite.atlassian.net/rest/api/2/user/assignable/search?username=firstname.lastname%40mycompany.com&project=DUMMY01&maxResults=2000
    text: No project with the provided key exists
1 Like

Does the user you’re authenticating with have access to that project? How are you authenticating?

I’m assuming mysite is something you replaced in the URL for this post. I just tried that url on our Jira Cloud instance with a known project key and it worked fine.

I’d recommend logging in to your site with the user you’re authenticating as, then going to https://yoursite.atlassian.net/rest/api/2/project and ensuring that a project with the key DUMMY01 shows up in the list as a start to ensure that user is part of that project.

1 Like

Thank you very much for following up on this. Your assumptions are correct, I obfuscated any values. After I adjusted the authentication mode I’m able to launch the setup without any further issues.

However, as soon as I enable synchronization for a task I receive the following error:

2019-08-26 16:46:54,286 DEBUG [connectionpool] https://mysite.atlassian.net:443 "GET /rest/api/2/user/assignable/search?username=firstname.lastname%40mysite.com&project=DUMMY01&maxResults=2000 HTTP/1.1" 404 None
2019-08-26 16:46:54,288 ERROR [bridge] JiraError HTTP 404 url: https://mysite.atlassian.net/rest/api/2/user/assignable/search?username=firstname.lastname%40mysite.com&project=DUMMY01&maxResults=2000
        text: No project with the provided key exists

        response headers = {'X-AREQUESTID': 'abcdefgh-ijkl-mnop-qrst-uvwxyzabcdef', 'X-XSS-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'Content-Encoding': 'gzip', 'Transfer-Encoding': 'chunked', 'X-AACCOUNTID': 'abcdefghijklmnopqrstuvwx', 'Strict-Transport-Security': 'max-age=315360000; includeSubDomains; preload', 'Vary': 'Accept-Encoding', 'ATL-TraceId': 'abcdefghijklmnop', 'Server': 'AtlassianProxy/1.15.8.1', 'Connection': 'keep-alive', 'Cache-Control': 'no-cache, no-store, no-transform', 'Date': 'Mon, 26 Aug 2019 23:46:54 GMT', 'Content-Type': 'application/json;charset=UTF-8', 'Timing-Allow-Origin': '*'}
        response text = {"errorMessages":["No project with the provided key exists"],"errors":{}}
Traceback (most recent call last):
  File "/usr/local/sg-jira-bridge/sg_jira/bridge.py", line 309, in sync_in_jira
    safe_event
  File "/usr/local/sg-jira-bridge/sg_jira/handlers/enable_syncing_handler.py", line 98, in process_shotgun_event
    event,
  File "/usr/local/sg-jira-bridge/sg_jira/handlers/task_issue_handler.py", line 216, in process_shotgun_event
    "originalEstimate": "%d m" % (sg_entity["est_in_mins"] or 0)
  File "/usr/local/sg-jira-bridge/sg_jira/handlers/entity_issue_handler.py", line 125, in _create_jira_issue_for_entity
    jira_project=jira_project,
  File "/usr/local/sg-jira-bridge/sg_jira/jira_session.py", line 290, in find_jira_user
    maxResults=JIRA_RESULT_PAGING,
  File "/home/root/.local/lib/python2.7/site-packages/jira/client.py", line 2214, in search_assignable_users_for_issues
    return self._fetch_pages(User, None, 'user/assignable/search', startAt, maxResults, params)
  File "/home/root/.local/lib/python2.7/site-packages/jira/client.py", line 575, in _fetch_pages
    resource = self._get_json(request_path, params=page_params, base=base)
  File "/home/root/.local/lib/python2.7/site-packages/jira/client.py", line 2549, in _get_json
    r = self._session.get(url, params=params)
  File "/home/root/.local/lib/python2.7/site-packages/jira/resilientsession.py", line 151, in get
    return self.__verb('GET', url, **kwargs)
  File "/home/root/.local/lib/python2.7/site-packages/jira/resilientsession.py", line 147, in __verb
    raise_on_error(response, verb=verb, **kwargs)
  File "/home/root/.local/lib/python2.7/site-packages/jira/resilientsession.py", line 57, in raise_on_error
    r.status_code, error, r.url, request=request, response=r, **kwargs)
JIRAError: JiraError HTTP 404 url: https://mysite.atlassian.net/rest/api/2/user/assignable/search?username=firstname.lastname%40mysite.com&project=DUMMY01&maxResults=2000
        text: No project with the provided key exists

        response headers = {'X-AREQUESTID': 'abcdefgh-ijkl-mnop-qrst-uvwxyzabcdef', 'X-XSS-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'Content-Encoding': 'gzip', 'Transfer-Encoding': 'chunked', 'X-AACCOUNTID': 'abcdefghijklmnopqrstuvwx', 'Strict-Transport-Security': 'max-age=315360000; includeSubDomains; preload', 'Vary': 'Accept-Encoding', 'ATL-TraceId': 'abcdefghijklmnop', 'Server': 'AtlassianProxy/1.15.8.1', 'Connection': 'keep-alive', 'Cache-Control': 'no-cache, no-store, no-transform', 'Date': 'Mon, 26 Aug 2019 23:46:54 GMT', 'Content-Type': 'application/json;charset=UTF-8', 'Timing-Allow-Origin': '*'}
        response text = {"errorMessages":["No project with the provided key exists"],"errors":{}}
2019-08-26 16:46:54,299 ERROR [webapp] 127.0.0.1 - code 500, message

The project definitely exists. I also tried it with a different key, but the result is the same.

In order to debug the call I’m using Postman, but I run into the same issues.

Further research lead me to the following page of the documentation for the Jira REST API: https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-project-get It states that an Oauth scope of read:jira-work is required, so I’m wondering if I have to use ‘OAuth’ instead of ‘Basic Auth’. I’m currently the process to get this set up so I can use it.

Any additional information from your side is greatly appreciated.

1 Like

OAuth-based authentication seems to work. I’ll provide a detailed update as soon as I have collected all parts.

2 Likes

Quick status update on this topic. I’m still working on identifying all the problematic areas. The authentication was one major problem. With fixing this comes the problem that the script user is no longer available for differentiating between manual and automated events.

Another big issue is the lack of data that is accessible through the Jira REST API for a cloud instance. For example, the code expects an email address, but this is only shared with applications that are approved by Atlassian.

I’m making my way through these problems one by one. After I’m done, I’ll create a merge request to share my insights.

3 Likes