Skip to content

Fix Jira Cloud compatibility in jira notificator#957

Merged
openshift-merge-bot[bot] merged 2 commits intoopenshift:mainfrom
rioliu-rh:fix-jira-cloud-search-api
Mar 19, 2026
Merged

Fix Jira Cloud compatibility in jira notificator#957
openshift-merge-bot[bot] merged 2 commits intoopenshift:mainfrom
rioliu-rh:fix-jira-cloud-search-api

Conversation

@rioliu-rh
Copy link
Contributor

Summary

Fixes jira notificator CI failure caused by deprecated Jira Cloud search API.

  • Replace search_issues (uses deprecated startAt pagination) with enhanced_search_issues (uses nextPageToken pagination) for Jira Cloud compatibility
  • Bump minimum jira library version from 3.4.1 to 3.8.0, which introduced enhanced_search_issues
  • Update test fixture OCPBUGS-1542 (inaccessible to bot account) with OCPBUGS-78840 (same characteristics: no assignee)

Fixes: https://redhat.atlassian.net/browse/OCPERT-339

Replace deprecated search_issues (startAt pagination) with
enhanced_search_issues (nextPageToken pagination) for Jira Cloud.
Bump jira minimum version to 3.8.0 which introduced the new API.
Update test fixture to use accessible issue OCPBUGS-78840.
@openshift-ci openshift-ci bot requested review from barboras7 and jhuttana March 19, 2026 10:23
@rioliu-rh
Copy link
Contributor Author

/cc @tomasdavidorg

@openshift-ci openshift-ci bot requested a review from tomasdavidorg March 19, 2026 10:24
@coderabbitai
Copy link

coderabbitai bot commented Mar 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d7fbf26c-0315-4189-9bab-7b70f215ee65

📥 Commits

Reviewing files that changed from the base of the PR and between 1b7fae2 and 8d9cd14.

📒 Files selected for processing (2)
  • oar/notificator/jira_notificator.py
  • tests/test_jira_notificator.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/test_jira_notificator.py

Walkthrough

Removed the search_batch_size parameter and manual pagination in the JIRA notificator, switching to enhanced_search_issues(...); CLI option --search-batch-size removed. Bumped jira dependency to >= 3.8.0 and updated related tests (fixture key and expected JQL target versions).

Changes

Cohort / File(s) Summary
JIRA Notificator
oar/notificator/jira_notificator.py
Removed search_batch_size from NotificationService.get_on_qa_issues and process_on_qa_issues signatures and callers; replaced manual paginated jira.search_issues(... startAt=..., maxResults=...) loop with self.jira.enhanced_search_issues(..., maxResults=0, expand="changelog") and materialization via list(...); CLI jira_notificator option --search-batch-size removed.
Dependency Version
pyproject.toml
Updated jira dependency constraint from >= 3.4.1 to >= 3.8.0.
Tests
tests/test_jira_notificator.py
Updated test fixture issue key from OCPBUGS-1542 to OCPBUGS-78840; adjusted tests to call get_on_qa_issues/process_on_qa_issues without numeric batch-size arg; expanded expected JQL Target Version allowlist to include 4.20.z and 4.21.z.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/test_jira_notificator.py (1)

341-356: ⚠️ Potential issue | 🟡 Minor

Test expectation is out of sync with production code.

The test expects Target Versions ending at 4.19.z, but the actual get_on_qa_filter method (line 624) includes 4.20.z and 4.21.z. This test will fail.

🐛 Proposed fix
     def test_get_on_qa_filter(self):
         self.assertEqual(
             self.ns.get_on_qa_filter(None),
             (
                 "project = OCPBUGS AND issuetype in (Bug, Vulnerability) "
-                "AND status = ON_QA AND 'Target Version' in (4.12.z, 4.13.z, 4.14.z, 4.15.z, 4.16.z, 4.17.z, 4.18.z, 4.19.z)"
+                "AND status = ON_QA AND 'Target Version' in (4.12.z, 4.13.z, 4.14.z, 4.15.z, 4.16.z, 4.17.z, 4.18.z, 4.19.z, 4.20.z, 4.21.z)"
             )
         )
         self.assertEqual(
             self.ns.get_on_qa_filter(datetime(2025, 7, 17, tzinfo=timezone.utc)),
             (
                 "project = OCPBUGS AND issuetype in (Bug, Vulnerability) "
-                "AND status = ON_QA AND 'Target Version' in (4.12.z, 4.13.z, 4.14.z, 4.15.z, 4.16.z, 4.17.z, 4.18.z, 4.19.z)"
+                "AND status = ON_QA AND 'Target Version' in (4.12.z, 4.13.z, 4.14.z, 4.15.z, 4.16.z, 4.17.z, 4.18.z, 4.19.z, 4.20.z, 4.21.z)"
                 " AND status changed to ON_QA after 2025-07-17"
             )
         )
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/test_jira_notificator.py` around lines 341 - 356, The test expectation
in test_get_on_qa_filter is stale: update the expected JQL strings used in
self.assertEqual calls for ns.get_on_qa_filter (both the None case and the
datetime case) to include the additional Target Versions 4.20.z and 4.21.z so
they match the production get_on_qa_filter implementation; ensure the datetime
branch still appends " AND status changed to ON_QA after YYYY-MM-DD" exactly as
returned by get_on_qa_filter.
🧹 Nitpick comments (2)
oar/notificator/jira_notificator.py (2)

684-684: CLI option --search-batch-size is now ineffective.

This option no longer controls pagination behavior since enhanced_search_issues handles it internally. Consider deprecating or removing this option to avoid user confusion.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oar/notificator/jira_notificator.py` at line 684, The CLI option
--search-batch-size is now ineffective because pagination is handled inside
enhanced_search_issues; remove or deprecate this option by deleting the
click.option("--search-batch-size", ...) declaration (or replace it with a no-op
deprecated flag) and any references to it so users are not misled. Update the
command's help text and any documentation strings to reflect that
enhanced_search_issues controls pagination internally and, if you choose
deprecation instead of removal, log a warning in the CLI entrypoint (the
function decorated with `@click.command` that consumes the option) indicating the
flag is ignored and will be removed in a future release.

631-652: search_batch_size parameter is unused and docstring is misleading.

The search_batch_size parameter is accepted but no longer used in the method body since enhanced_search_issues handles pagination internally with maxResults=0. The docstring claiming it specifies "Number of issues to fetch per batch" is now inaccurate. Consider removing this parameter from the method signature and updating the docstring, along with callers in process_on_qa_issues and the CLI option.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oar/notificator/jira_notificator.py` around lines 631 - 652, The
get_on_qa_issues method still accepts a now-unused parameter search_batch_size
and contains an inaccurate docstring; remove the search_batch_size parameter
from get_on_qa_issues, update its docstring to reflect that
enhanced_search_issues handles pagination (no batch size), and update all
callers (e.g., process_on_qa_issues) and any CLI option that passes a batch size
so they no longer supply this argument; keep the method name get_on_qa_issues
and ensure calls use the single from_date argument instead.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@tests/test_jira_notificator.py`:
- Around line 341-356: The test expectation in test_get_on_qa_filter is stale:
update the expected JQL strings used in self.assertEqual calls for
ns.get_on_qa_filter (both the None case and the datetime case) to include the
additional Target Versions 4.20.z and 4.21.z so they match the production
get_on_qa_filter implementation; ensure the datetime branch still appends " AND
status changed to ON_QA after YYYY-MM-DD" exactly as returned by
get_on_qa_filter.

---

Nitpick comments:
In `@oar/notificator/jira_notificator.py`:
- Line 684: The CLI option --search-batch-size is now ineffective because
pagination is handled inside enhanced_search_issues; remove or deprecate this
option by deleting the click.option("--search-batch-size", ...) declaration (or
replace it with a no-op deprecated flag) and any references to it so users are
not misled. Update the command's help text and any documentation strings to
reflect that enhanced_search_issues controls pagination internally and, if you
choose deprecation instead of removal, log a warning in the CLI entrypoint (the
function decorated with `@click.command` that consumes the option) indicating the
flag is ignored and will be removed in a future release.
- Around line 631-652: The get_on_qa_issues method still accepts a now-unused
parameter search_batch_size and contains an inaccurate docstring; remove the
search_batch_size parameter from get_on_qa_issues, update its docstring to
reflect that enhanced_search_issues handles pagination (no batch size), and
update all callers (e.g., process_on_qa_issues) and any CLI option that passes a
batch size so they no longer supply this argument; keep the method name
get_on_qa_issues and ensure calls use the single from_date argument instead.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3c4e9e45-83e8-4e3a-9b59-d2913fdbcc2e

📥 Commits

Reviewing files that changed from the base of the PR and between 97f45e4 and 1b7fae2.

📒 Files selected for processing (3)
  • oar/notificator/jira_notificator.py
  • pyproject.toml
  • tests/test_jira_notificator.py

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

search_batch_size is unused if we use maxResults=0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this is a problem, I'm investigating how to support this option with pagination pattern

Copy link
Contributor Author

@rioliu-rh rioliu-rh Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. This has been addressed in the latest commit - search_batch_size is now removed from get_on_qa_issues, process_on_qa_issues, and the CLI.

Here's the reasoning behind the design:

The Jira Cloud search API (/rest/api/2/search/jql) has a hard limit of 100 results per page regardless of the maxResults value you pass - see Jira Cloud REST API docs. This is a Jira Cloud vs Jira Server distinction, not a v2 vs v3 API distinction - the search/jql endpoint with nextPageToken pagination is a Cloud-specific extension available in both v2 and v3.

The enhanced_search_issues(maxResults=0) call instructs the jira library to automatically paginate through all pages (100 items per request) using nextPageToken until all results are fetched.

The old search_batch_size was controlling the startAt-based pagination page size on Jira Server - a concept that no longer applies on Jira Cloud where:

  • maxResults > 0 → fetches one page (capped at 100), then stops
  • maxResults = 0 → fetches all pages automatically, 100 per request

So search_batch_size was effectively a no-op on Cloud for values > 100, and for values ≤ 100 it only limited results to a single partial page. Removing it is the correct approach.

Remove search_batch_size parameter from get_on_qa_issues and
process_on_qa_issues since Jira Cloud pagination is handled internally
by enhanced_search_issues. Update CLI to drop --search-batch-size option.
Fix test_get_on_qa_filter to include 4.20.z and 4.21.z target versions.
@rioliu-rh
Copy link
Contributor Author

@coderabbitai please double check latest commit and other review comments, is it ok to merge

@coderabbitai
Copy link

coderabbitai bot commented Mar 19, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

Let me check the current state of the PR, files, and any outstanding review comments.


🏁 Script executed:

#!/bin/bash
# Get the current PR status and review comments
gh pr view 957 --repo openshift/release-tests --json state,reviews,reviewDecision,mergeable,title,body

echo "=== PR REVIEW COMMENTS ==="
gh api repos/openshift/release-tests/pulls/957/reviews --jq '.[] | {id, user: .user.login, state, submitted_at, body}'

echo "=== PR INLINE COMMENTS ==="
gh api repos/openshift/release-tests/pulls/957/comments --jq '.[] | {id, user: .user.login, path, line, body, created_at}'

echo "=== ISSUE COMMENTS ==="
gh api repos/openshift/release-tests/issues/957/comments --jq '.[] | {id, user: .user.login, body, created_at}'

Length of output: 30811


@rioliu-rh: Here's a summary of the review status:

✅ All code review issues are addressed

Issue Status
⚠️ test_get_on_qa_filter expected JQL missing 4.20.z, 4.21.z ✅ Fixed in latest commit
🧹 search_batch_size param unused + misleading docstring ✅ Removed from get_on_qa_issues & process_on_qa_issues
🧹 --search-batch-size CLI option ineffective ✅ CLI option removed
tomasdavidorg's inline comment on unused search_batch_size ✅ Addressed & explained in latest commit

✅ CI: All tests passed

⏳ Pending: Formal approval

My second automated review on the latest commit (8d9cd14) had no actionable comments. The code is technically sound. The only remaining step is a formal /approve from @tomasdavidorg (or another approver listed in OWNERS) before merging.

@rioliu-rh
Copy link
Contributor Author

@tomasdavidorg can you review again. openshift/release#76321 needs to be updated based latest change for cli

@openshift-ci
Copy link

openshift-ci bot commented Mar 19, 2026

@rioliu-rh: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@tomasdavidorg
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 19, 2026
@openshift-ci
Copy link

openshift-ci bot commented Mar 19, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tomasdavidorg

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 19, 2026
@openshift-merge-bot openshift-merge-bot bot merged commit 8886a64 into openshift:main Mar 19, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants