diff --git a/elliott/elliottlib/cli/find_bugs_qe_cli.py b/elliott/elliottlib/cli/find_bugs_qe_cli.py index b040ca9f16..b1cd7e3a2d 100644 --- a/elliott/elliottlib/cli/find_bugs_qe_cli.py +++ b/elliott/elliottlib/cli/find_bugs_qe_cli.py @@ -79,7 +79,12 @@ def close_reconciliation_bugs(runtime, noop: bool, bug_tracker): status=statuses, include_labels=['art:reconciliation'], ) - bugs = bug_tracker._search(query, verbose=runtime.debug) + if query is None: + # All configured target versions were filtered out (e.g. not yet defined in JIRA + # for a new release). _query() already logged why; nothing to search for. + bugs = [] + else: + bugs = bug_tracker._search(query, verbose=runtime.debug) LOGGER.info(f"Found {len(bugs)} bugs to close: {', '.join(sorted(str(b.id) for b in bugs))}") close_comment = ( diff --git a/elliott/tests/test_find_bugs_qe_cli.py b/elliott/tests/test_find_bugs_qe_cli.py index 41160a1bb1..3570e36b78 100644 --- a/elliott/tests/test_find_bugs_qe_cli.py +++ b/elliott/tests/test_find_bugs_qe_cli.py @@ -128,6 +128,25 @@ def test_close_reconciliation_bugs_noop(self): close_reconciliation_bugs(runtime, True, bug_tracker) + def test_close_reconciliation_bugs_no_valid_target_versions(self): + """_query returns None when all configured target versions are filtered out + (e.g. not yet defined in JIRA for a new release). close_reconciliation_bugs + must treat that as "no bugs found" instead of searching with a None query, + which JIRA rejects as an unbounded query.""" + runtime = flexmock(debug=False) + client = flexmock() + bug_tracker = flexmock(type='jira', _client=client) + flexmock(bug_tracker).should_receive("target_release").and_return(["5.1.0", "5.1.z", "5.1"]) + flexmock(bug_tracker).should_receive("_query").with_args( + status=RECONCILIATION_STATUSES, + include_labels=['art:reconciliation'], + ).and_return(None).once() + flexmock(bug_tracker).should_receive("_search").never() + flexmock(client).should_receive("transition_issue").never() + flexmock(bug_tracker).should_receive("add_comment").never() + + close_reconciliation_bugs(runtime, False, bug_tracker) + if __name__ == '__main__': unittest.main()