Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

GTFalcao
Copy link
Collaborator

@GTFalcao GTFalcao commented Sep 22, 2025

(reported by a customer)

Component did not have pagination, only max results, limiting the amount of responses that could be retrieved.

I've increased the max page size (1000, or less if maxResults is less) and added pagination, raising the max maxResults to 5000. While technically we can allow larger values, I think at this point the user should improve their query to narrow down the results, as the execution time can skyrocket.

Summary by CodeRabbit

  • New Features

    • JQL search now supports pagination and returns a consolidated issues list.
    • Increased maxResults limit from 100 to 5000 for larger queries.
    • Response shape updated to return { issues } for easier consumption.
    • Pagination helpers exposed to control page size and total results.
  • Documentation

    • Clarified descriptions for JQL and maxResults, including updated limits and behavior.
  • Chores

    • Version bumps: action API to 0.1.0 and Jira component package to 1.1.0.

Copy link

vercel bot commented Sep 22, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
pipedream-docs Ignored Ignored Sep 22, 2025 7:41pm
pipedream-docs-redirect-do-not-edit Ignored Ignored Sep 22, 2025 7:41pm

Copy link
Contributor

coderabbitai bot commented Sep 22, 2025

Walkthrough

Implements pagination for Jira JQL search, adds helper methods, increases per-page cap, changes run to aggregate and return { issues }, updates field descriptions and handling, and bumps versions: action 0.0.4→0.1.0 and package 1.0.4→1.1.0.

Changes

Cohort / File(s) Summary
Jira JQL search action
components/jira/actions/search-issues-with-jql/search-issues-with-jql.mjs
Added getMaxResultsPerPage() and paginate({ params, maxResults, ... }); introduced pagination logic and per-page calculation; increased maxResults cap to 5000 and updated field descriptions; adjusted expand handling; run now aggregates pages and returns { issues }; version 0.0.4→0.1.0; updated summary export.
Package metadata
components/jira/package.json
Bumped package version 1.0.4→1.1.0; no other changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Client
  participant Action as search-issues-with-jql
  participant Paginator as paginate()
  participant Jira as Jira API

  Client->>Action: run({ jql, fields, maxResults, expand, ... })
  Action->>Action: perPage = getMaxResultsPerPage()
  Action->>Paginator: paginate({ params, maxResults, perPage })
  loop page-by-page until maxResults or isLast
    Paginator->>Jira: search({ jql, fields, startAt, maxResults: perPage, expand? })
    Jira-->>Paginator: { issues[], isLast, nextPageToken? }
    Paginator->>Paginator: accumulate issues
  end
  Paginator-->>Action: issues[]
  Action-->>Client: { issues }
  note right of Client: Return shape changed from raw response to { issues }
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I hop through pages, nibbling bytes,
From JQL burrows into data lights.
Five-thousand fields of clover found,
I bundle issues, neat and sound.
Version drums thump 1.1’s tune—
Paginated moon, I’ll fetch them soon! 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The repository's template requires a "## WHY" section but the PR description does not follow the template and is missing that heading; although the description explains the customer report and the pagination change, it is not structured per the required template and therefore does not meet the repository's description requirements. Because the mandatory template section is absent and the description is not clearly organized against the template, this check fails. Please update the PR description to use the repository template and add the required "## WHY" section explaining the motivation and user impact; also include brief notes on public API changes (version bump, return-shape change), testing/verification performed, and any rollout or rollback considerations.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title "Jira - adding pagination to search-issues-with-jql" succinctly and accurately captures the primary change in this PR — adding pagination to the search-issues-with-jql action; it is specific and relevant to the changes in the diff. The phrasing is clear and concise, making it easy for teammates scanning history to understand the main intent of the change.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jira-pagination-addition

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Contributor

@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.

Actionable comments posted: 2

Caution

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

⚠️ Outside diff range comments (2)
components/jira/actions/search-issues-with-jql/search-issues-with-jql.mjs (2)

86-91: failFast is not a supported parameter for JQL search. Replace with validateQuery.

Jira search uses validateQuery (“strict” | “warn”) instead of failFast. Passing failFast risks 400s or being ignored.

-    failFast: {
-      type: "boolean",
-      label: "Fail Fast",
-      description: "Fail this request early if we can't retrieve all field data",
-      optional: true,
-    },
+    validateQuery: {
+      type: "string",
+      label: "Validate Query",
+      description: "Validation strictness for the JQL query. Use 'warn' to allow unknown fields/functions.",
+      optional: true,
+      options: [
+        { label: "Strict", value: "strict" },
+        { label: "Warn", value: "warn" },
+      ],
+      default: "strict",
+    },

143-158: Align request params with JQL search API; remove failFast, add validateQuery, and ensure per‑page limit is respected.

Also safe‑guard expand join and pass startAt.

       const issues = await this.paginate({
         $,
         cloudId: this.cloudId,
         params: {
           jql: this.jql,
           maxResults: this.getMaxResultsPerPage(),
-          fields: this.fields,
-          expand: this.expand
-            ? this.expand.join(",")
-            : undefined,
+          fields: this.fields,
+          expand: Array.isArray(this.expand) && this.expand.length
+            ? this.expand.join(",")
+            : undefined,
           properties: this.properties,
           fieldsByKeys: this.fieldsByKeys,
-          failFast: this.failFast,
+          validateQuery: this.validateQuery,
+          startAt: 0,
         },
         maxResults: this.maxResults,
       });
🧹 Nitpick comments (5)
components/jira/actions/search-issues-with-jql/search-issues-with-jql.mjs (5)

20-21: Typo: duplicated word in description.

“The JQL query query…” → “The JQL query…”

-      description: "The JQL query query to search for issues. [See the documentation for syntax and examples](https://support.atlassian.com/jira-software-cloud/docs/what-is-advanced-search-in-jira-cloud/)",
+      description: "The JQL query to search for issues. [See the documentation for syntax and examples](https://support.atlassian.com/jira-software-cloud/docs/what-is-advanced-search-in-jira-cloud/)",

25-30: Clarify “Max Results” semantics (total vs per‑page).

You set UI max to 5000 but per‑page to 1000. Consider clarifying label/desc to “Total results to retrieve (paginated, up to 1000 per page)”.

-      label: "Max Results",
-      description: "Maximum number of issues to return (default: 50)",
+      label: "Max Results (Total)",
+      description: "Total number of issues to return across pages (default: 50, fetched in pages of up to 1000)",

31-37: Optional: consider a lighter default for fields.

*all can be heavy; consider a curated default (e.g., *all,-comment) or documenting tradeoffs.


39-73: Optional: warn about changelog expand cost.

expand=changelog on search can explode payload size. Consider a help text note.


93-140: Add basic rate‑limit/backoff handling in pagination.

Jira Cloud can 429; add minimal retry with exponential backoff to harden the action.

I can add a small wrapper with jittered retries if you want.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 78ebe2f and 3c3509e.

📒 Files selected for processing (2)
  • components/jira/actions/search-issues-with-jql/search-issues-with-jql.mjs (4 hunks)
  • components/jira/package.json (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
components/jira/actions/search-issues-with-jql/search-issues-with-jql.mjs (2)
components/jira/jira.app.mjs (2)
  • params (242-253)
  • params (288-299)
components/jira/actions/common/issue.mjs (2)
  • maxResults (54-54)
  • maxResults (82-82)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Lint Code Base
🔇 Additional comments (4)
components/jira/package.json (1)

3-3: Version bump looks good.

Package version aligns with the action’s 0.1.0 change. No issues.

components/jira/actions/search-issues-with-jql/search-issues-with-jql.mjs (3)

7-7: Action version bump is appropriate.

Breaking return shape justifies 0.1.0. Good.


159-163: Return shape change is fine; update docs and examples.

Since you now return { issues } and set $summary, ensure README/action description and any example workflows are updated accordingly.


93-140: Unit/integration coverage for pagination.

Add tests for: exact page boundary, partial last page, maxResults < page size, empty results.

Copy link
Contributor

@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.

Actionable comments posted: 1

🧹 Nitpick comments (2)
components/jira/actions/search-issues-with-jql/search-issues-with-jql.mjs (2)

148-149: Minor: per-page value could be decoupled from total limit.

Using this.maxResults to derive per-page can make pages unnecessarily small for low totals. Consider a fixed per-page default (e.g., 100) independent from the total cap, still bounded by the API max.

Example:

-          maxResults: this.getMaxResultsPerPage(),
+          maxResults: Math.min(100, this.getMaxResultsPerPage()),

163-165: Improve error context surfaced to users.

Include HTTP status and response data when available.

-    } catch (error) {
-      throw new Error(`Failed to search issues: ${error.message}`);
-    }
+    } catch (error) {
+      const status = error?.response?.status;
+      const statusText = error?.response?.statusText;
+      const details = error?.response?.data?.errorMessages?.join("; ")
+        || error?.response?.data?.message
+        || error.message;
+      throw new Error(`Failed to search issues${status ? ` (${status}${statusText ? ` ${statusText}` : ""})` : ""}: ${details}`);
+    }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3c3509e and 344369c.

📒 Files selected for processing (1)
  • components/jira/actions/search-issues-with-jql/search-issues-with-jql.mjs (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
components/jira/actions/search-issues-with-jql/search-issues-with-jql.mjs (2)
components/jira/jira.app.mjs (3)
  • response (341-354)
  • params (242-253)
  • params (288-299)
components/jira/actions/common/issue.mjs (2)
  • maxResults (54-54)
  • maxResults (82-82)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Lint Code Base
  • GitHub Check: pnpm publish
🔇 Additional comments (2)
components/jira/actions/search-issues-with-jql/search-issues-with-jql.mjs (2)

7-7: Output shape change: verify downstream usage and versioning.

Returning { issues } (vs a raw response) can break consumers. Ensure callers and docs are updated; version bump to 0.1.0 is appropriate if this is breaking.

If you need to preserve compatibility, consider returning both:

-      return {
-        issues,
-      };
+      return {
+        issues,
+        // total, startAt could be exposed in the future if needed
+      };

Also applies to: 159-162


97-139: Fix pagination: Jira JQL search uses startAt/maxResults/total, not nextPageToken/isLast.

Current loop will only fetch the first page. Replace cursor-style pagination with offset pagination.

Apply this diff:

   methods: {
     getMaxResultsPerPage() {
       return Math.min(this.maxResults, 1000);
     },
     async paginate({
-      params, maxResults, ...otherArgs
+      params, maxResults, ...otherArgs
     }) {
-      const results = [];
-      let nextPageToken;
-      let response;
-
-      do {
-        response = await this.jira.searchIssues({
-          ...otherArgs,
-          params: {
-            ...params,
-            ...(nextPageToken && {
-              nextPageToken,
-            }),
-          },
-        });
-
-        const pageResults = response.issues;
-        const pageLength = pageResults?.length;
-        if (!pageLength) {
-          break;
-        }
-
-        // If maxResults is specified, only add what we need
-        if (maxResults && results.length + pageLength > maxResults) {
-          const remainingSlots = maxResults - results.length;
-          results.push(...pageResults.slice(0, remainingSlots));
-          break;
-        } else {
-          results.push(...pageResults);
-        }
-
-        // Also break if we've reached maxResults exactly
-        if (maxResults && results.length >= maxResults) {
-          break;
-        }
-
-        nextPageToken = response.nextPageToken;
-      } while (nextPageToken && !response.isLast);
-
-      return results;
+      const results = [];
+      let startAt = Number(params?.startAt || 0);
+      const perPage = Number(params?.maxResults) || this.getMaxResultsPerPage();
+      const pageSize = Math.min(perPage, 1000);
+
+      for (;;) {
+        const { issues: page = [], total = 0 } = await this.jira.searchIssues({
+          ...otherArgs,
+          params: {
+            ...params,
+            startAt,
+            maxResults: pageSize,
+          },
+        });
+
+        const pageLen = page.length;
+        if (pageLen === 0) break;
+
+        if (maxResults && results.length + pageLen > maxResults) {
+          results.push(...page.slice(0, maxResults - results.length));
+          break;
+        }
+        results.push(...page);
+
+        if ((maxResults && results.length >= maxResults) ||
+            startAt + pageLen >= total) {
+          break;
+        }
+        startAt += pageLen;
+      }
+      return results;
     },
   },

Copy link
Collaborator

@michelle0927 michelle0927 left a comment

Choose a reason for hiding this comment

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

LGTM!

@michelle0927 michelle0927 moved this from Ready for PR Review to Ready for QA in Component (Source and Action) Backlog Sep 22, 2025
@GTFalcao GTFalcao merged commit 9d2da73 into master Sep 22, 2025
10 checks passed
@GTFalcao GTFalcao deleted the jira-pagination-addition branch September 22, 2025 20:33
@GTFalcao GTFalcao moved this from Done to Ready for QA in Component (Source and Action) Backlog Sep 22, 2025
@vunguyenhung vunguyenhung moved this from Ready for QA to Done in Component (Source and Action) Backlog Sep 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants