mikebowler / jirametrics

A tool to extract data from Jira and either generate reports or export to CSV files
Apache License 2.0
36 stars 1 forks source link

Error with custom workflow status items #22

Closed GeekTieGuy closed 6 months ago

GeekTieGuy commented 6 months ago

I have a custom workflow in Jira, and jirametrics can successfully download the data, but when it comes to generating just one html report (the story point accuracy one), and I run 'jirametrics export' to avoid redownloading the data, I get this message:

Redefining status category Status(name="Review", id=11923, category_name="In Progress", category_id=4) with Status(name="Review", id=11659, category_name="To Do", category_id=2). Was one set in the config?

What do I do to get around this?

mikebowler commented 6 months ago

Almost certainly you defined a status_category_mapping in your config and Jira is also returning a mapping for that status and the categories are different. Try commenting out the "status_category_mapping" to see if it fixes the problem.

mikebowler commented 6 months ago

If you're on the latest code then it shouldn't care if you still have your own status category mapping so long as it matches what comes back from Jira. There was a bug in earlier code where it might complain even if they were the same, but that was fixed a while back.

GeekTieGuy commented 6 months ago

Thanks! Here is my config - is there a status_category_mapping I'm not seeing?

Exporter.configure do target_path 'target'

jira_config 'jira.config'

project do
  file_prefix 'sample'

  download do
    rolling_date_count 90
  end

  board id: 561 do
    cycletime do
        start_at first_time_in_status_category('In Progress')
        stop_at currently_in_status_category('Done')
    end
  end

  file do
    file_suffix '.html'
    html_report do
      story_point_accuracy_chart
    end
  end

end end

mikebowler commented 6 months ago

No, I don't see a status_category_mapping at all in there. It does look like you have one too many 'end's at the bottom but that should give you a different error.

I plugged that into my local config (changing the board id only) and it downloaded and generated the report successfully. So I have to assume that there is some bad data in what you currently have downloaded. Can you delete the target directory and do a download again?

GeekTieGuy commented 6 months ago

Let me try status_category_mapping first - where do I find that in the Wiki?

mikebowler commented 6 months ago

It appears you've uncovered a bug in the docs. status_category_mapping should be in project configuration and isn't. I'll make a note to fix that.

Basically, you put this declaration inside a project block: status_category_mapping status: 'MyNewStatus', category: 'In Progress'

That's not going to fix your immediate problem though. That fixes a problem where a status has been removed from Jira but the history of changes still references it. The error you have above should only happen when you did a status_category_mapping in a case where you didn't need to, and it was different from what Jira is actually returning.

GeekTieGuy commented 6 months ago

And just one more question: what is the set of categories? I assume they are "To Do", "In Progress" and "Done". Is that correct?

mikebowler commented 6 months ago

Yes. In theory, those are the only three possible status categories in any Jira instance. In practice, I've also seen NULL, where the category isn't set. I'm still not sure how that was possible.

GeekTieGuy commented 6 months ago

Could it be that if I have a slash or ampersand in some of the status fields in Jira, that might throw off a parser somewhere? I have a huge list of statuses in the json that gets generated in the target directory upon download. Not all of them are actually used on my board.

I also see some status entried in the json that say "No Category" for the statusCategory name node.

mikebowler commented 6 months ago

Assuming that the error you're getting is still the one at the top of this thread then I'd say no.

Redefining status category Status(name="Review", id=11923, category_name="In Progress", category_id=4) with Status(name="Review", id=11659, category_name="To Do", category_id=2).

The status that's causing it grief is called Review and somehow it's trying to redefine the category. Is it possible that you have two statuses in the JSON that are both called Review? That shouldn't be possible but with Jira, we often see things that are theoretically impossible.

GeekTieGuy commented 6 months ago

There is an interesting node on the "Review" status in question:

"scope": { "type": "PROJECT", "project": { "id": "13739" } }

And yes, there are two "Review" status nodes in the *_statuses.json
GeekTieGuy commented 6 months ago

When I delete the duplicate Review status that has that extra "scope" node from the json entirely, the jirametrics export command no longer throws an error. And it produces the html too. So I have a good workaround for now. Thanks for the discussion!

mikebowler commented 6 months ago

I'm looking through the samples I have access to and I can't see a scope declaration anywhere. Are you able to share what flavour (Server, Cloud, Data Center) and version of Jira you're on?

GeekTieGuy commented 6 months ago

Yes, I'm on a Cloud instance.

GeekTieGuy commented 6 months ago

I'll re-download and give you an anonymized version of the node in question.

GeekTieGuy commented 6 months ago

{ "self": "https://snip/rest/api/2/status/11659", "description": "", "iconUrl": "https://snip/", "name": "Review", "untranslatedName": "Review", "id": "11659", "statusCategory": { "self": "https://snip/rest/api/2/statuscategory/2", "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" }, "scope": { "type": "PROJECT", "project": { "id": "13739" } } },

mikebowler commented 6 months ago

You can email mbowler@gargoylesoftware.com if you don't want it in a GitHub ticket btw.

GeekTieGuy commented 6 months ago

I think it's ok to have it here.

mikebowler commented 6 months ago

Was the other Review the same, only without the scope?

GeekTieGuy commented 6 months ago

Yes: { "self": "https://snip/rest/api/2/status/11923", "description": "", "iconUrl": "https://snip/images/icons/statuses/generic.png", "name": "Review", "untranslatedName": "Review", "id": "11923", "statusCategory": { "self": "https://snip/rest/api/2/statuscategory/4", "id": 4, "key": "indeterminate", "colorName": "yellow", "name": "In Progress" } },

GeekTieGuy commented 6 months ago

On the Estimate Accuracy graph (the one I'm most interested in), it says "The aging dots (if you turn them on) show the current age of items[...]" - How does one turn them on (I didn't see it mentioned on the Wiki)?

mikebowler commented 6 months ago

Just click on the heading in the legend. I see how that wouldn't be obvious. All data sets in all charts can be turned on/off this way.

GeekTieGuy commented 6 months ago

One of the reasons for the duplicate status is that the board I import from spans multiple projects, I guess.

Thank you again for helping with this. And thank you for creating these tools. They work really well and make my life a lot easier than pulling data myself and doing Excel gymnastics!

mikebowler commented 6 months ago

I'm looking at the API docs and it appears that a status can now be either global scope or project scope. No idea whether it's been this way all along and I'm only hitting it now or if it's something new. Either way, I now have to figure out how to reproduce this in my test instance. https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-status/#api-rest-api-2-statuses-get

GeekTieGuy commented 6 months ago

One more, sorry: How does one specify the project name in the config file so that --name will work?

mikebowler commented 6 months ago
project name: "some_name" do
  ...
end
mikebowler commented 6 months ago

I've been adding to the docs for all your questions above btw, so thanks for helping to improve those ;-)

mikebowler commented 6 months ago

I'm now able to reproduce this error in my test instance of Jira. It happens when there is at least one NextGen (now called team managed) project in the instance and that one redefines a status that was globally set in the Classic projects.

I've also discovered that NextGen projects don't have board ids at all, which means this doesn't work at all for them. One problem at a time though.

mikebowler commented 6 months ago

I've pushed version 1.3 of jirametrics which should allow you to do a download and export without hand-tweaking the status file. I'm going to close this ticket but if this doesn't fix it for you then let me know.

I was able to reproduce the problem locally and the fix works for me.

GeekTieGuy commented 6 months ago

I reinstalled today, got version 1.3, and ran a configuration that used to cause trouble. No trouble this time around. All good! Thank you!!!