From cb743992fa68ff5fde5d819b12c38ce75b7550d7 Mon Sep 17 00:00:00 2001 From: Bela Vizi Date: Thu, 13 Aug 2026 12:01:24 +0200 Subject: [PATCH] Fix close_reconciliation_bugs crash when all target versions are filtered out _query() returns None when every configured target-release version is missing from the JIRA project (e.g. a new OCP release whose Target Version values haven't been created yet), and every other caller (search, blocker_search, cve_tracker_search) already checks for that and short-circuits to []. close_reconciliation_bugs skipped that check and passed None straight to _search(), which sent JIRA a query with no real restriction and got rejected with "Unbounded JQL queries are not allowed here", failing the whole find-bugs:qe step. rh-pre-commit.version: 2.4.0 rh-pre-commit.check-secrets: ENABLED --- elliott/elliottlib/cli/find_bugs_qe_cli.py | 7 ++++++- elliott/tests/test_find_bugs_qe_cli.py | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) 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()