Hello! I am trying to create Jira issues using the...
# prefect-server
j
Hello! I am trying to create Jira issues using the JiraTask and got this error (full text in thread):
Copy code
jira.exceptions.JIRAError: JiraError HTTP 400 url: <https://our_jira_url/rest/api/2/issue>
	text: expected Object containing a 'name' property
	
	response text = {"errorMessages":[],"errors":{"assignee":"expected Object containing a 'name' property"}}
The issue is that for jira_create options, you're passing this dict, which does not have a 'name' property for the assignee object.
Copy code
options = {
            "project": project_name,
            "assignee": {"accountId": assignee},
            "issuetype": {"name": issue_type},
            "summary": summary,
            "description": description,
        }
Do others successfully use the JiraTask with Jira Server? Was the JiraTask maybe only intended to be used with Jira Cloud (api/3/issue) and not Jira Server (api/2/issue)? I know that my company has one of the largest single-instance Jira applications in the world, and we have a bunch of customizations so I don't know if this is only an issue for us. I've asked our internal Jira team if this particular issue might be related to a customization but haven't heard back yet. If I add a 'name' property to the assignee object (
"assignee": {"accountId": assignee, 'name': assignee},
), JiraTask will work and correctly create a Jira ticket. I obviously don't know if changing that in your codebase would break JiraTask for other users...
Copy code
[2022-01-24 15:35:32+0000] ERROR - prefect.TaskRunner | Task 'JiraTask': Exception encountered during task execution!  

Traceback (most recent call last):
  File "~/.pyenv/versions/myvenv/site-packages/prefect/engine/task_runner.py", line 880, in get_task_run_state
    logger=self.logger,
  File "~/.pyenv/versions/myvenv/site-packages/prefect/utilities/executors.py", line 467, in run_task_with_timeout
    return task.run(*args, **kwargs)  # type: ignore
  File "~/.pyenv/versions/myvenv/site-packages/prefect/utilities/tasks.py", line 456, in method
    return run_method(self, *args, **kwargs)
  File "~/.pyenv/versions/myvenv/site-packages/prefect/tasks/jira/jira_task.py", line 141, in run
    created = jira.create_issue(options)
  File "~/.pyenv/versions/myvenv/site-packages/jira/client.py", line 1448, in create_issue
    r = <http://self._session.post|self._session.post>(url, data=json.dumps(data))
  File "~/.pyenv/versions/myvenv/site-packages/jira/resilientsession.py", line 198, in post
    return self.__verb("POST", str(url), data=data, json=json, **kwargs)
  File "~/.pyenv/versions/myvenv/site-packages/jira/resilientsession.py", line 189, in __verb
    raise_on_error(response, verb=verb, **kwargs)
  File "~/.pyenv/versions/myvenv/site-packages/jira/resilientsession.py", line 70, in raise_on_error
    **kwargs,
jira.exceptions.JIRAError: JiraError HTTP 400 url: <https://our_jira_url/rest/api/2/issue>
	text: expected Object containing a 'name' property
	
	response headers = {[snipped for corp privacy]}
	response text = {"errorMessages":[],"errors":{"assignee":"expected Object containing a 'name' property"}}
k
Hi @Jen Evenson, thanks for the report. I’ve actually never come across someone using the Jira task here so I wouldn’t know unfortunately. I think the task was written for the v2 API judging by the last commit. I am a bit hesitant to recommend changing the task in the task library for now since there hasn’t been anyone commenting (unless you become sure this change is needed). I would recommend making a Github issue to record this, but suggest you create a sublclass in the meantime for you use case. Does that work for you?
👍 1