pycontribs / jira

Python Jira library. Development chat available on https://matrix.to/#/#pycontribs:matrix.org
https://jira.readthedocs.io
BSD 2-Clause "Simplified" License
1.94k stars 860 forks source link

Adding `reporter` to the input dict makes the `create_issue` fail #1632

Open sahushashikant opened 1 year ago

sahushashikant commented 1 year ago

Bug summary

I'm trying to create a Jira ticket and following is my input dict:

{
'project': {'key': 'PKEY'}, 
'summary': 'Test ticket', 
'description': 'Ticket description', 
'issuetype': {'name': 'Bug'}, 
'reporter': {'id': '140057972582720'}
}

I have tried replacing id with accountId and name, which I found in old documentations and on some forums, but I get the same error which is:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/isha/.local/lib/python3.8/site-packages/jira/client.py", line 1526, in create_issue
    r = self._session.post(url, data=json.dumps(data))
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 581, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/home/isha/.local/lib/python3.8/site-packages/jira/resilientsession.py", line 241, in request
    elif raise_on_error(response, **processed_kwargs):
  File "/home/isha/.local/lib/python3.8/site-packages/jira/resilientsession.py", line 69, in raise_on_error
    raise JIRAError(
jira.exceptions.JIRAError: JiraError HTTP 400 url: https://jira.isha.in/rest/api/2/issue

    response headers = {'Server': 'nginx/1.18.0 (Ubuntu)', 'Date': 'Thu, 30 Mar 2023 09:39:25 GMT', 'Content-Type': 'application/json;charset=UTF-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'X-AREQUESTID': '909x10727221x1', 'Referrer-Policy': 'strict-origin-when-cross-origin', 'X-XSS-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'SAMEORIGIN', 'Content-Security-Policy': 'sandbox', 'Strict-Transport-Security': 'max-age=31536000', 'Set-Cookie': 'JSESSIONID=D19A82C8B44DD4E5840862BC6CA6CF04; Path=/; Secure; HttpOnly, atlassian.xsrf.token=BG7O-LMA1-TWTB-H7Z9_5bbe1218afc268f415b50202ed6167d9bcc8b1d5_lin; Path=/; Secure; SameSite=None', 'X-Seraph-LoginReason': 'OK', 'X-ASESSIONID': 'z4yzak', 'X-AUSERNAME': 'xxx', 'Cache-Control': 'no-cache, no-store, no-transform', 'Content-Encoding': 'gzip', 'Vary': 'User-Agent'}
    response text = {"errorMessages":[],"errors":{"reporter":"Field 'reporter' cannot be set. It is not on the appropriate screen, or unknown."}}

Is there an existing issue for this?

Jira Instance type

Jira Cloud (Hosted by Atlassian)

Jira instance version

No response

jira-python version

3.5.0

Python Interpreter version

3.8

Which operating systems have you used?

Reproduction steps

# 1. Given a Jira client instance
jira: JIRA
# 2. When I call the function create_issue with reporter in the input
jira.create_issue({
'project': {'key': 'PKEY'}, 
'summary': 'Test ticket', 
'description': 'Ticket description', 
'issuetype': {'name': 'Bug'}, 
'reporter': {'id': '140057972582720'}
})
# 3. I get the error saying "Field 'reporter' cannot be set. It is not on the appropriate screen, or unknown."
...

Stack trace

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/isha/.local/lib/python3.8/site-packages/jira/client.py", line 1526, in create_issue
    r = self._session.post(url, data=json.dumps(data))
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 581, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/home/isha/.local/lib/python3.8/site-packages/jira/resilientsession.py", line 241, in request
    elif raise_on_error(response, **processed_kwargs):
  File "/home/isha/.local/lib/python3.8/site-packages/jira/resilientsession.py", line 69, in raise_on_error
    raise JIRAError(
jira.exceptions.JIRAError: JiraError HTTP 400 url: https://jira.isha.in/rest/api/2/issue

    response headers = {'Server': 'nginx/1.18.0 (Ubuntu)', 'Date': 'Thu, 30 Mar 2023 09:39:25 GMT', 'Content-Type': 'application/json;charset=UTF-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'X-AREQUESTID': '909x10727221x1', 'Referrer-Policy': 'strict-origin-when-cross-origin', 'X-XSS-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'SAMEORIGIN', 'Content-Security-Policy': 'sandbox', 'Strict-Transport-Security': 'max-age=31536000', 'Set-Cookie': 'JSESSIONID=D19A82C8B44DD4E5840862BC6CA6CF04; Path=/; Secure; HttpOnly, atlassian.xsrf.token=BG7O-LMA1-TWTB-H7Z9_5bbe1218afc268f415b50202ed6167d9bcc8b1d5_lin; Path=/; Secure; SameSite=None', 'X-Seraph-LoginReason': 'OK', 'X-ASESSIONID': 'z4yzak', 'X-AUSERNAME': 'xxx', 'Cache-Control': 'no-cache, no-store, no-transform', 'Content-Encoding': 'gzip', 'Vary': 'User-Agent'}
    response text = {"errorMessages":[],"errors":{"reporter":"Field 'reporter' cannot be set. It is not on the appropriate screen, or unknown."}}

Expected behaviour

The issue should have been created with the reporter field according to the documentation

Additional Context

No response

alanmxll commented 1 year ago

Hi @sahushashikant,

I had this problem a while ago. {"errorMessages":[],"errors":{"reporter":"Field 'reporter' cannot be set. It is not on the appropriate screen, or unknown."}}

Check if the 'reporter' field is enabled in your project's screen scheme.

studioj commented 1 year ago

hi @alanmxll this post tends to suggest you might not have the permission to change the reporter. Can you verify this?

Thank you

alanmxll commented 1 year ago

hi @alanmxll this post tends to suggest you might not have the permission to change the reporter. Can you verify this?

Thank you

Hi, @studioj . I think you ended up tagging me by mistake, it was the @sahushashikant that opened the issue.