Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in the JQL Query: 'SET' is a reserved JQL word #45

Closed
nicolasbock opened this issue Jul 29, 2024 · 2 comments
Closed

Error in the JQL Query: 'SET' is a reserved JQL word #45

nicolasbock opened this issue Jul 29, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@nicolasbock
Copy link
Contributor

Hi,

I added a the following configuration to our repository:

settings:
  # Jira project key to create the issue in
  jira_project_key: "SET"

  # Dictionary mapping GitHub issue status to Jira issue status
  status_mapping:
    opened: Wishlist
    closed: Done

  # (Optional) Jira project components that should be attached to the created
  # issue Component names are case-sensitive
  components:
    - athena

  # (Optional) GitHub labels. Only issues with one of those labels will be
  # synchronized. If not specified, all issues will be synchronized
  # labels:
  # - jira

  # (Optional) (Default: false) Add a new comment in GitHub with a link to Jira
  # created issue
  add_gh_comment: true

  # (Optional) (Default: true) Synchronize issue description from GitHub to Jira
  sync_description: true

  # (Optional) (Default: true) Synchronize comments from GitHub to Jira
  sync_comments: true

  # (Optional) (Default: None) Parent Epic key to link the issue to
  epic_key: "SET-926"

  # (Optional) Dictionary mapping GitHub issue labels to Jira issue types. If
  # label on the issue is not in specified list, this issue will be created as a
  # Bug
  label_mapping:
    enhancement: Story
    bug: Story

Opening a new issue does not create a new Jira task. The backtrace on the server side is as follows:

Exception occurred
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/anyio/streams/memory.py", line 97, in receive
    return self.receive_nowait()
  File "/usr/local/lib/python3.10/dist-packages/anyio/streams/memory.py", line 92, in receive_nowait
    raise WouldBlock
anyio.WouldBlock

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/base.py", line 78, in call_next
    message = await recv_stream.receive()
  File "/usr/local/lib/python3.10/dist-packages/anyio/streams/memory.py", line 112, in receive
    raise EndOfStream
anyio.EndOfStream

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/github_jira_sync_app/main.py", line 102, in catch_exceptions_middleware
    return await call_next(request)
  File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/base.py", line 84, in call_next
    raise app_exc
  File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/base.py", line 70, in coro
    await self.app(scope, receive_or_disconnect, send_no_error)
  File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/usr/local/lib/python3.10/dist-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "/usr/local/lib/python3.10/dist-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 66, in app
    response = await func(request)
  File "/usr/local/lib/python3.10/dist-packages/fastapi/routing.py", line 237, in app
    raw_response = await run_endpoint_function(
  File "/usr/local/lib/python3.10/dist-packages/fastapi/routing.py", line 163, in run_endpoint_function
    return await dependant.call(**values)
  File "/github_jira_sync_app/main.py", line 213, in bot
    existing_issues = jira.search_issues(
  File "/usr/local/lib/python3.10/dist-packages/jira/client.py", line 3099, in search_issues
    issues = self._fetch_pages(
  File "/usr/local/lib/python3.10/dist-packages/jira/client.py", line 739, in _fetch_pages
    resource = self._get_json(request_path, params=page_params, base=base)
  File "/usr/local/lib/python3.10/dist-packages/jira/client.py", line 3871, in _get_json
    r = self._session.get(url, params=params)
  File "/usr/local/lib/python3.10/dist-packages/requests/sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/jira/resilientsession.py", line 241, in request
    elif raise_on_error(response, **processed_kwargs):
  File "/usr/local/lib/python3.10/dist-packages/jira/resilientsession.py", line 69, in raise_on_error
    raise JIRAError(
jira.exceptions.JIRAError: JiraError HTTP 400 url: https://warthogs.atlassian.net/rest/api/2/search?jql=project%3DSET+AND+description+~%22%5C%22This+issue+was+created+from+GitHub+Issue+https%3A%2F%2Fgithub.com%2Fcanonical%2Fathena-core%2Fissues%2F173%5C%22%22&startAt=0&validateQuery=True&fields=%2Aall&maxResults=50
    text: Error in the JQL Query: 'SET' is a reserved JQL word. You must surround it in quotation marks to use it in a query. (line 1, character 9)
    
    response headers = {'Date': 'Sat, 27 Jul 2024 17:23:44 GMT', 'Content-Type': 'application/json;charset=UTF-8', 'Server': 'AtlassianEdge', 'Timing-Allow-Origin': '*', 'X-Arequestid': 'cf00e1daf14dec44ddc330082788b52c', 'X-Aaccountid': '64107e219d6383e32a30c36c', 'Cache-Control': 'no-cache, no-store, no-transform', 'X-Content-Type-Options': 'nosniff', 'X-Xss-Protection': '1; mode=block', 'Atl-Traceid': '5afdfa56b3df4033b91ea3f101a63849', 'Strict-Transport-Security': 'max-age=63072000; includeSubDomains; preload', '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"}', 'Transfer-Encoding': 'chunked'}
    response text = {"errorMessages":["Error in the JQL Query: 'SET' is a reserved JQL word. You must surround it in quotation marks to use it in a query. (line 1, character 9)"],"errors":{}}
27.07.2024 17:23:47 (ERROR) Exception occurred
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/anyio/streams/memory.py", line 97, in receive
    return self.receive_nowait()
  File "/usr/local/lib/python3.10/dist-packages/anyio/streams/memory.py", line 92, in receive_nowait
    raise WouldBlock
anyio.WouldBlock

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/base.py", line 78, in call_next
    message = await recv_stream.receive()
  File "/usr/local/lib/python3.10/dist-packages/anyio/streams/memory.py", line 112, in receive
    raise EndOfStream
anyio.EndOfStream

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/github_jira_sync_app/main.py", line 102, in catch_exceptions_middleware
    return await call_next(request)
  File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/base.py", line 84, in call_next
    raise app_exc
  File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/base.py", line 70, in coro
    await self.app(scope, receive_or_disconnect, send_no_error)
  File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/usr/local/lib/python3.10/dist-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "/usr/local/lib/python3.10/dist-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 66, in app
    response = await func(request)
  File "/usr/local/lib/python3.10/dist-packages/fastapi/routing.py", line 237, in app
    raw_response = await run_endpoint_function(
  File "/usr/local/lib/python3.10/dist-packages/fastapi/routing.py", line 163, in run_endpoint_function
    return await dependant.call(**values)
  File "/github_jira_sync_app/main.py", line 213, in bot
    existing_issues = jira.search_issues(
  File "/usr/local/lib/python3.10/dist-packages/jira/client.py", line 3099, in search_issues
    issues = self._fetch_pages(
  File "/usr/local/lib/python3.10/dist-packages/jira/client.py", line 739, in _fetch_pages
    resource = self._get_json(request_path, params=page_params, base=base)
  File "/usr/local/lib/python3.10/dist-packages/jira/client.py", line 3871, in _get_json
    r = self._session.get(url, params=params)
  File "/usr/local/lib/python3.10/dist-packages/requests/sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/jira/resilientsession.py", line 241, in request
    elif raise_on_error(response, **processed_kwargs):
  File "/usr/local/lib/python3.10/dist-packages/jira/resilientsession.py", line 69, in raise_on_error
    raise JIRAError(
jira.exceptions.JIRAError: JiraError HTTP 400 url: https://warthogs.atlassian.net/rest/api/2/search?jql=project%3DSET+AND+description+~%22%5C%22This+issue+was+created+from+GitHub+Issue+https%3A%2F%2Fgithub.com%2Fcanonical%2Fathena-core%2Fissues%2F173%5C%22%22&startAt=0&validateQuery=True&fields=%2Aall&maxResults=50
    text: Error in the JQL Query: 'SET' is a reserved JQL word. You must surround it in quotation marks to use it in a query. (line 1, character 9)
    
    response headers = {'Date': 'Sat, 27 Jul 2024 17:23:47 GMT', 'Content-Type': 'application/json;charset=UTF-8', 'Server': 'AtlassianEdge', 'Timing-Allow-Origin': '*', 'X-Arequestid': '097e63df153fc389dfc639d9fe493abe', 'X-Aaccountid': '64107e219d6383e32a30c36c', 'Cache-Control': 'no-cache, no-store, no-transform', 'X-Content-Type-Options': 'nosniff', 'X-Xss-Protection': '1; mode=block', 'Atl-Traceid': '872be110ec61497aab21ff13bdb7e8e0', 'Strict-Transport-Security': 'max-age=63072000; includeSubDomains; preload', '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"}', 'Transfer-Encoding': 'chunked'}
    response text = {"errorMessages":["Error in the JQL Query: 'SET' is a reserved JQL word. You must surround it in quotation marks to use it in a query. (line 1, character 9)"],"errors":{}}
@beliaev-maksim
Copy link
Member

@nicolasbock can you please propose a PR fix?

I think we need to wrap project name in double quotes here:

rf'project={settings["jira_project_key"]} AND description ~"\"{jira_task_desc_match}\""',

@beliaev-maksim beliaev-maksim added the bug Something isn't working label Jul 29, 2024
@nicolasbock
Copy link
Contributor Author

Addressed in #46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants