Skip to content

Fetch protected staging branches via GraphQL instead of REST. - #55

Merged
cb-jarunmadhesh merged 2 commits into
masterfrom
fix/fetch-protected-branches-via-graphql
Aug 12, 2026
Merged

Fetch protected staging branches via GraphQL instead of REST.#55
cb-jarunmadhesh merged 2 commits into
masterfrom
fix/fetch-protected-branches-via-graphql

Conversation

@cb-anomitromunshi

@cb-anomitromunshi cb-anomitromunshi commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Avoids GitHub 504s on large repos where GET /branches?protected=true times out while evaluating protection across thousands of branches.

Updated fetchProtectedBranchNames to use paginated GitHub GraphQL queries. It now returns protected staging/ branches covered by classic branch protection rules or active repository and organization rulesets. This avoids REST API 504 timeouts in large repositories.

Avoids GitHub 504s on large repos where GET /branches?protected=true times out while evaluating protection across thousands of branches.

Co-authored-by: Cursor <cursoragent@cursor.com>
@snyk-io

snyk-io Bot commented Aug 12, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues
Secrets 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 7444db8f-e3b9-496b-95f0-041fcad89ae4

📥 Commits

Reviewing files that changed from the base of the PR and between b4564f4 and 51ff54b.

⛔ Files ignored due to path filters (1)
  • dist/index.js is excluded by !**/dist/**
📒 Files selected for processing (1)
  • apps/github.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/github.js

Walkthrough

fetchProtectedBranchNames now uses paginated GraphQL queries to scan staging/ refs. It returns refs with classic branch protection or an applicable repository or organization ruleset.

Changes

Protected branch lookup

Layer / File(s) Summary
Paginated protected-ref lookup
apps/github.js
Replaces the REST listBranches request with paginated GraphQL queries. The function checks classic branch protection and applicable repository or organization rulesets before returning branch names.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/github.js`:
- Around line 20-32: Update the GraphQL query used by the repository refs lookup
to request each Ref’s rules in addition to branchProtectionRule, then update the
branch filtering in the refs iteration to include refs with at least one
applicable rule. Preserve inclusion of classic branchProtectionRule-protected
refs while adding ruleset-protected branches.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: da28a3a9-b856-45de-ba50-ea589952723d

📥 Commits

Reviewing files that changed from the base of the PR and between 5ef6f51 and b4564f4.

⛔ Files ignored due to path filters (1)
  • dist/index.js is excluded by !**/dist/**
📒 Files selected for processing (1)
  • apps/github.js

Comment thread apps/github.js
branchProtectionRule only covers classic protection; Ref.rules also picks up active repository and organization rulesets.

Co-authored-by: Cursor <cursoragent@cursor.com>
@cb-jarunmadhesh
cb-jarunmadhesh merged commit 9d083cf into master Aug 12, 2026
5 checks passed
@cb-jarunmadhesh
cb-jarunmadhesh deleted the fix/fetch-protected-branches-via-graphql branch August 12, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants