jira
jira copied to clipboard
Unable to add issues to epic after update 3.0.1 -> 3.1.1
Bug summary
Exception when trying to add issues to an epic:
File "/home/valentijn/dd/dojo/jira_link/helper.py", line 580, in add_jira_issue_for_finding
return add_jira_issue(finding, *args, **kwargs)
File "/home/valentijn/dd/dojo/jira_link/helper.py", line 695, in add_jira_issue
add_issues_to_epic(jira, obj, epic_id=epic.jira_id, issue_keys=[str(new_issue.id)], ignore_epics=True)
File "/home/valentijn/dd/dojo/jira_link/helper.py", line 565, in add_issues_to_epic
return jira.add_issues_to_epic(epic_id=epic_id, issue_keys=issue_keys, ignore_epics=ignore_epics)
File "/home/valentijn/venv/lib/python3.8/site-packages/jira/client.py", line 4768, in add_issues_to_epic
raise NotImplementedError(
NotImplementedError: Jira Agile Public API does not support this request
Used to work in 3.0.1 and I think this a supported operation. Could it have to do something with the changes made in https://github.com/pycontribs/jira/pull/1186 ?
There's some code referring to the old value of agile_rest_path
it seems?
if (
self._options["agile_rest_path"]
!= GreenHopperResource.GREENHOPPER_REST_PATH
):
# TODO(ssbarnea): simulate functionality using issue.update()?
raise NotImplementedError(
"Jira Agile Public API does not support this request"
)
Is there an existing issue for this?
- [X] I have searched the existing issues
Jira Instance type
Jira Cloud (Hosted by Atlassian) and JIRA Server
Jira instance version
8.20.1
jira-python version
3.1.1
Python Interpreter version
3.8
Which operating systems have you used?
- [X] Linux
- [ ] macOS
- [ ] Windows
Reproduction steps
Call `add_issues_to_epic`
Stack trace
see above
Expected behaviour
Issues being added to epic
Additional Context
No response
Can confirm that add_issues_to_epic works in 3.0.1 but is not working in 3.1.1. Manually this endpoint seems to working fine: https://developer.atlassian.com/cloud/jira/software/rest/api-group-epic/#api-agile-1-0-epic-epicidorkey-issue-get
Hey all just wanted to add that we are seeing this as well. Anyone figure out a workaround yet?
Please refer to my solution: https://github.com/pycontribs/jira/issues/964#issuecomment-1008920980
Please refer to my solution: #964 (comment)
Thanks. For JIRA Server it probably has to be the epic_link or epic name field (which is a custom field I believe). But in essence the idea of a jira api wrapper is to abstract away from having to update fields manually :-)
FWIW we already subclass jira.JIRA
in order to add some other helper methods and the like, so we've solved this by overriding the method as follows:
class JiraService(JIRA):
def __init__(self):
super().__init__()
def add_issues_to_epic(self, epic_key, issue_keys):
data = {"issues": issue_keys}
url = self._get_url(f"epic/{epic_key}/issue", base=self.AGILE_BASE_URL)
response = self._session.post(url, data=json.dumps(data))
return response
(note: lots of additional code related to auth and logging removed for clarity's sake in this example.)
So I believe this should be fixed in the latest release, do let me know if this is not the case
I'm using release 3.3.2
and I'm getting
jira.exceptions.JIRAError: JiraError HTTP 404 url: https://company-jira.atlassian.net/rest/agile/1.0/epics/PROJ-34/issue
text: null for uri: https://company-jira.atlassian.net/rest/agile/1.0/epics/PROJ-34/issue
I'm not sure why I'm getting a 404
because the Epic PROJ-34
does exist, but the URI in the error message does 404 when I visit it with a browser too.
@gekitsuu can you check if #1450 works for you with
pip install git+https://github.com/pycontribs/jira.git@bugfix/request_method_for_add_issues_to_epic
I installed the new version
➜ python -c 'import jira; print(jira.__version__)'
3.3.3.dev2+gea02922
And still get the same error
@gekitsuu Thanks, spotted another error, I've pushed an update, would be great if you can check again Thanks for the swift response
That worked in that I now get an error about next-gen issue (which I expected) Thanks!
Nice, I've added in a bit of a (hacky) test and was able to further confirm that both the original URL and request method were wrong, so hopefully we can properly close this issue with that PR.
Can I also further confirm if you are using Jira Cloud @gekitsuu ?
Thanks again for the quick testing
That’s correct
Perfect, will try and get this into a patch soon.
This api still has problems when using the jira cloud platform. Use the same interface test as .add_issues_to_epic(). The test is as follows.
An error occurs
{"errorMessages":["The request contains a next-gen issue. This operation cant add next-gen issues to epics. To add a next-gen issue to an epic, use the Edit issue operation and set the parent property (i.e., `\"parent\":{\"key\":\"PROJ-123\"}` where `PROJ-123` has an issue type at level one of the issue type hierarchy). See <a href=\"https://developer.atlassian.com/cloud/jira/platform/rest/v2/\"> developer.atlassian.com </a> for more details."],"errors":{}}%