Zenhub API: {"message":"Validation failed: Issues would create a cycle in epics"}


I’m trying to use the ZenHubIO API to sync issues between Jira, Github and ZenHub. I have no issue creating issues from jira to github. However, if the issue is an Epic, the Epic is not synced correctly (i.e. considered an Epic on Jira but not on Github/Zenhub). I managed to track down the issue and it comes down to the POST request. Following the API, the request should be in the form

curl -X POST https://api.zenhub.com/p1/repositories/<repo #>/issues/<issue #>/convert_to_epic -H 'X-Authentication-Token: AUTH TOKEN' -H "Content-Type: application/json" -d '{"issues": [{"repo_id": <repo #>, "issue_number": <issue #>}]}'

I’ve made sure I make the API calls with the correct credentials and repo/issue numbers by running other API calls that work just fine. However, when I run the above request, I’m greeted with {"message":"Validation failed: Issues would create a cycle in epics (<*some number*>)"}. Every issue I test this on is a newly created issue i.e. has no dependencies, no parent epics, is not an epic itself, etc. Any pointers on how to solve this or what I could do to better diagnose this problem? I’m using Golang to automate the process of http requests but I don’t think it matters.


So turns out it was a very trivial issue. I was sending a request body (see the end of the command in the question) -H "Content-Type: application/json" -d '{"issues": [{"repo_id": <repo #>, "issue_number": <issue #>}]}'

Since I already specified the repo number and issue number in the url itself, I didn’t need to also add a body. I’m guessing it was trying to convert to an epic twice? which gave me that error message. I think one could send a request body with multiple repo IDs and issue numbers if one were to set the repo id and issue id as a variable in the POST url.

Answered By – Omar Farag

Answer Checked By – David Goodson (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.