GothenburgBitFactory / bugwarrior

Pull github, bitbucket, and trac issues into taskwarrior
http://pypi.python.org/pypi/bugwarrior
GNU General Public License v3.0
739 stars 210 forks source link

JiraError HTTP 400 #1003

Closed chopovsky closed 1 year ago

chopovsky commented 1 year ago

I installed BW via pip install and have the following config in bugwarriorrc:

jira.base_uri = https://<mycompany>.atlassian.net
jira.username = '<email>@<mycompany>.ai'
jira.password = API_KEY

when running bugwarrior-pull I get the following error

INFO:bugwarrior.db:Service-defined UDAs exist: you can optionally use the `bugwarrior-uda` command to export a list of UDAs you can add to your taskrc file.
INFO:bugwarrior.services:Starting to aggregate remote issues.
INFO:bugwarrior.services:Spawning 1 workers.
INFO:bugwarrior.services:Working on [<mycompany>_jira]
ERROR:bugwarrior.services:Worker for [<mycompany>_jira] failed: JiraError HTTP 400 url: https://<mycompany>.atlassian.net/rest/api/latest/search?jql=assignee%3D%22%27<email>%5Cu0040<mycompany>.ai%27%22+AND+resolution+is+null&startAt=0&validateQuery=True&fields=%2Aall&maxResults=100
    text: Field 'assignee' does not exist or this field cannot be viewed by anonymous users., Field 'resolution' does not exist or this field cannot be viewed by anonymous users.

    response headers = {'Date': 'Wed, 23 Aug 2023 07:02:07 GMT', 'Content-Type': 'application/json;charset=UTF-8', 'Server': 'AtlassianEdge', 'Timing-Allow-Origin': '*', 'X-Arequestid': 'c254c2cf4faa286f71c22897a89b6948', 'X-Seraph-Loginreason': 'AUTHENTICATED_FAILED', 'Set-Cookie': 'atlassian.xsrf.token=5ae8806e927f7e68c490bf85211b4c150bc7bce3_lout; Path=/; SameSite=None; Secure', 'Cache-Control': 'no-cache, no-store, no-transform', 'X-Content-Type-Options': 'nosniff', 'X-Xss-Protection': '1; mode=block', 'Atl-Traceid': '98b61956dce1c740', 'Report-To': '{"endpoints": [{"url": "https://dz8aopenkvv6s.cloudfront.net"}], "group": "endpoint-1", "include_subdomains": true, "max_age": 600}', 'Nel': '{"failure_fraction": 0.001, "include_subdomains": true, "max_age": 600, "report_to": "endpoint-1"}', 'Strict-Transport-Security': 'max-age=63072000; includeSubDomains; preload', 'Transfer-Encoding': 'chunked'}
    response text = {"errorMessages":["Field 'assignee' does not exist or this field cannot be viewed by anonymous users.","Field 'resolution' does not exist or this field cannot be viewed by anonymous users."],"warningMessages":[]}
Traceback (most recent call last):
  File "/home/<user>/programs/anaconda3/lib/python3.9/site-packages/bugwarrior/services/__init__.py", line 504, in _aggregate_issues
    for issue in service.issues():
  File "/home/<user>/programs/anaconda3/lib/python3.9/site-packages/bugwarrior/services/jira.py", line 361, in issues
    cases = self.jira.search_issues(self.query, maxResults=None)
  File "/home/<user>/programs/anaconda3/lib/python3.9/site-packages/jira/client.py", line 3084, in search_issues
    issues = self._fetch_pages(
  File "/home/<user>/programs/anaconda3/lib/python3.9/site-packages/jira/client.py", line 729, in _fetch_pages
    resource = self._get_json(request_path, params=page_params, base=base)
  File "/home/<user>/programs/anaconda3/lib/python3.9/site-packages/jira/client.py", line 3853, in _get_json
    r = self._session.get(url, params=params)
  File "/home/<user>/programs/anaconda3/lib/python3.9/site-packages/requests/sessions.py", line 600, in get
    return self.request("GET", url, **kwargs)
  File "/home/<user>/programs/anaconda3/lib/python3.9/site-packages/jira/resilientsession.py", line 246, in request
    elif raise_on_error(response, **processed_kwargs):
  File "/home/<user>/programs/anaconda3/lib/python3.9/site-packages/jira/resilientsession.py", line 71, in raise_on_error
    raise JIRAError(
jira.exceptions.JIRAError: JiraError HTTP 400 url: https://<mycompany>.atlassian.net/rest/api/latest/search?jql=assignee%3D%22%27<email>%5Cu0040<mycompany>.ai%27%22+AND+resolution+is+null&startAt=0&validateQuery=True&fields=%2Aall&maxResults=100
    text: Field 'assignee' does not exist or this field cannot be viewed by anonymous users., Field 'resolution' does not exist or this field cannot be viewed by anonymous users.

    response headers = {'Date': 'Wed, 23 Aug 2023 07:02:07 GMT', 'Content-Type': 'application/json;charset=UTF-8', 'Server': 'AtlassianEdge', 'Timing-Allow-Origin': '*', 'X-Arequestid': 'c254c2cf4faa286f71c22897a89b6948', 'X-Seraph-Loginreason': 'AUTHENTICATED_FAILED', 'Set-Cookie': 'atlassian.xsrf.token=5ae8806e927f7e68c490bf85211b4c150bc7bce3_lout; Path=/; SameSite=None; Secure', 'Cache-Control': 'no-cache, no-store, no-transform', 'X-Content-Type-Options': 'nosniff', 'X-Xss-Protection': '1; mode=block', 'Atl-Traceid': '98b61956dce1c740', 'Report-To': '{"endpoints": [{"url": "https://dz8aopenkvv6s.cloudfront.net"}], "group": "endpoint-1", "include_subdomains": true, "max_age": 600}', 'Nel': '{"failure_fraction": 0.001, "include_subdomains": true, "max_age": 600, "report_to": "endpoint-1"}', 'Strict-Transport-Security': 'max-age=63072000; includeSubDomains; preload', 'Transfer-Encoding': 'chunked'}
    response text = {"errorMessages":["Field 'assignee' does not exist or this field cannot be viewed by anonymous users.","Field 'resolution' does not exist or this field cannot be viewed by anonymous users."],"warningMessages":[]}
INFO:bugwarrior.services:Done with [<mycompany>_jira] in 2.210265s
INFO:bugwarrior.services:Terminating workers
ERROR:bugwarrior.command:Aborted (critical error in target '<mycompany>_jira')
Traceback (most recent call last):
  File "/home/<user>/programs/anaconda3/lib/python3.9/site-packages/bugwarrior/command.py", line 73, in pull
    synchronize(issue_generator, config, main_section, dry_run)
  File "/home/<user>/programs/anaconda3/lib/python3.9/site-packages/bugwarrior/db.py", line 357, in synchronize
    for issue in issue_generator:
  File "/home/<user>/programs/anaconda3/lib/python3.9/site-packages/bugwarrior/services/__init__.py", line 572, in aggregate_issues
    raise RuntimeError(
RuntimeError: critical error in target '<mycompany>_jira'

while

curl -D- -u '<email>@<mycompany>.ai':API_KEY https://<mycompany>.atlassian.net/rest/api/2/search\?assignee\='<email>@<mycompany>.ai'

works well.

Any help would be appreciated

chopovsky commented 1 year ago

I figured out that it was due to the unnecessary single quotes in the line

jira.username = '<email>@<mycompany>.ai'

worked well after removing them