Check statusCategory instead of the resolution field for Jira issue status#14611
Conversation
296576d to
4a2fa85
Compare
|
Some Unit tests failed. I've returned the PR to draft state and will look into the failing tests. |
|
I've opened #14716 which addresses the same root cause you identified in #14347 ( |
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
|
I will have a look at the merge conflicts this week. Besides that, is there any other blocker or anything I can provide to speed things up? |
72deeed to
46214b8
Compare
* status category is mainly used to decide if a jira issue is active or not * if the category is undefined or an unknown status, fall back to resolution checking * the resolution object was compared to a string "None", this always returned False * provide unit tests for new functionality
- Remove test_issue_from_jira_is_active_with_unknown_status_and_none_resolution - Remove test_issue_from_jira_is_active_without_status_category_with_none_string_resolution These tests checked for resolution field as string 'None', which violates JIRA API spec. According to JIRA API, resolution is either an object with properties (id, name, etc) or null, never a string value. Remaining 12 tests verify correct behavior per the API spec.
46214b8 to
85cca8f
Compare
|
Conflicts have been resolved. A maintainer will review the pull request shortly. |
|
The branch is updated and merge conflicts are resolved. The ruff linter fails, but the complains are regarding files not touched by this PR and seem to be pre-existing on DEV. |
valentijnscholten
left a comment
There was a problem hiding this comment.
Can you try to organize the imports or use ruff check --fix to get rid of the violation?
|
@valentijnscholten running ruff locally passes all checks just fine. And the imports look similar to other files like It seems like the jira modules got restructured since I wrote the PR and one of the imports was broken. This should have caused the test failures and maybe also threw off ruff. |
valentijnscholten
left a comment
There was a problem hiding this comment.
With #14716 now merged we already have code looking at the status category. The only decision we make there is to check if status category == Done. Can you make sure the code in this PR here aligns / re-uses or deduplicates logic around the status category field?
|
I compared my changes to the ones in #14716. I noticed that I was far more defensive and explicit with my attribute guards, category states and the fallback to the old functionality. If it is fine to skip the fallback to the old functionality, this could drastically simplify the methods. I will provide an updated PR |
|
I aligned the changes with #14716. There is no fallback to the resolution approach anymore. This drastically simplified the function A new set of unit tests regarding the status category is introduced. Since they are pure logic tests and there is no need for database verification, they inherit from |
|
Thank you, but what I meant is that if possible we want to have only one place where we do |
|
Hi @valentijnscholten, There is one other place in dojo/jira/view.py:378 that compares the name of the statusCategory against "Done", but this was introduced like 5 years ago and seems to have nothing to do with the current changes. While it would also benefit from switching from a name-based comparison to the key, I would like to avoid extending the scope of the change at hand further and recommend to handle that improvement and it's consequences separately. |
Description
PR for #14347
When a finding is reactivated, the linked jira issue may not be reopened.
Root cause
When a finding is reactivated and before the linked jira issue is reopened,
issue_from_jira_is_activechecks whether a jira issue is active based on the resolution field. If it is considered active, the issue will not be transitioned to an active state again.The check based on resolution is not reliable in all situations:
Fix
Tests
It seems like there were no unit tests for
issue_from_jira_is_active. Several tests are provided, for the happy paths of all status categories, for the fallback checking the resolution, for conflicting category and resolution where the category takes precedence, and some edge cases of missing data.Backward compatibility
If stated, status category takes precedence. If none is stated or it is "undefined", the old behavior checking the resolution will be used. This includes a bugfix for the resolution check, since the resolution object was compared to a
"None"string in the last return statement, always returning false.Additional Information
This PR is complimentary to #14716 by @paulOsinski and addresses the same root cause.