Skip to content

fix: handle GitHub rate limit during governance audit#102

Open
KaranUnique wants to merge 2 commits into
AOSSIE-Org:mainfrom
KaranUnique:governance-rate-limit
Open

fix: handle GitHub rate limit during governance audit#102
KaranUnique wants to merge 2 commits into
AOSSIE-Org:mainfrom
KaranUnique:governance-rate-limit

Conversation

@KaranUnique

@KaranUnique KaranUnique commented Jul 4, 2026

Copy link
Copy Markdown

Addressed Issues:

Fixes #81

Screenshots/Recordings:

image

Additional Notes:

  1. Promise.allSettled was absorbing rejected promises silently. The audit loop now inspects each batch's results for RATE_LIMIT rejections. On detection, the loop breaks early (avoiding further doomed requests) and calls setError() with a user-friendly message — the same pattern already used by explore().

  2. error from AppContext was only rendered on HomePage. Since users are on the Governance page when the audit runs, the error was set but never shown. The page now reads error and setError from context and renders a dismissible inline banner between the page title and stat cards — scoped to where the user's attention is after clicking "Run Audit".

Partial results collected before the rate limit was hit are preserved and still displayed.

Checklist

  • My code follows the project's code style and conventions
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contributing Guidelines

⚠️ AI Notice - Important!

We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact.

@github-actions github-actions Bot added bug Something isn't working frontend Frontend changes javascript JavaScript/TypeScript changes size/S 11-50 lines changed first-time-contributor First time contributor labels Jul 4, 2026
@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@KaranUnique, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 41 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8734d950-9fd3-483e-b1e2-0f4f7b4e504f

📥 Commits

Reviewing files that changed from the base of the PR and between 74ebc4f and 0090743.

📒 Files selected for processing (3)
  • src/context/AppContext.jsx
  • src/pages/GovernancePage.jsx
  • src/pages/HomePage.jsx

Walkthrough

The runAudit function in AppContext now detects GitHub API rate-limit rejections during batched issue fetches, halts further processing, and sets an error message. GovernancePage now displays this error in a dismissible banner sourced from context state.

Changes

Audit rate-limit detection and error banner

Layer / File(s) Summary
Detect and report rate limits in runAudit
src/context/AppContext.jsx
runAudit resets error state, tracks a rateLimitHit flag, breaks batch processing early on RATE_LIMIT rejections, and sets a user-facing error message when a rate limit is hit.
Display and dismiss audit error banner
src/pages/GovernancePage.jsx
GovernancePage pulls setError from context and renders a conditional error banner with a dismiss (×) button that clears the error.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant GovernancePage
  participant AppContext
  participant GitHubAPI

  GovernancePage->>AppContext: runAudit()
  AppContext->>AppContext: reset error, rateLimitHit=false
  loop batch of repos
    AppContext->>GitHubAPI: fetchIssues(repo)
    GitHubAPI-->>AppContext: result or RATE_LIMIT rejection
    alt RATE_LIMIT detected
      AppContext->>AppContext: rateLimitHit=true, break
    end
  end
  AppContext->>AppContext: update issuesData, govLoading=false
  alt rateLimitHit
    AppContext->>GovernancePage: setError(rate-limit message)
  end
  GovernancePage->>GovernancePage: render error banner
  GovernancePage->>AppContext: setError('') on dismiss
Loading

Possibly related PRs

  • AOSSIE-Org/OrgExplorer#63: Both PRs modify the runAudit batching/error logic in src/context/AppContext.jsx and the corresponding audit UI in src/pages/GovernancePage.jsx.

Suggested labels: Typescript Lang

Suggested reviewers: bhavik-mangla, Zahnentferner

Poem

A rabbit hopped through rate-limit haze,
Caught the errors, stopped the maze,
A banner blooms with a tidy "×",
No more silent, broken checks!
Hop on, audit, clear and true. 🐇

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes stop audit processing on rate-limit hits and surface a clear warning banner, matching issue #81.
Out of Scope Changes check ✅ Passed The edits are limited to audit rate-limit handling and the governance error banner, with no unrelated changes.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: handling GitHub rate limits during the Governance audit.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@github-actions github-actions Bot added size/S 11-50 lines changed and removed size/S 11-50 lines changed labels Jul 4, 2026

@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: 4

🤖 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 `@src/context/AppContext.jsx`:
- Around line 145-161: The batch fetch logic in AppContext’s repository loop
only checks Promise.allSettled results for RATE_LIMIT and silently ignores every
other rejection, leaving missing repos with no visibility. Update the
fetchIssues batch handling to inspect all rejected results, not just RATE_LIMIT,
and surface non-rate-limit failures through the existing error/reporting path
while still allowing the rate-limit early exit in the repos loop. Use the
Promise.allSettled block, hitLimit handling, and fetchIssues call site as the
key places to adjust.
- Around line 137-169: The shared `error` state in `AppContext` is used by both
`explore()` and `runAudit()`, so an error from one flow can incorrectly appear
in the other. Split this into separate state values for Explore and Governance
(or otherwise scope the message by flow), and update `runAudit` and the
explore-related logic to set/clear only their own error. Also clear the relevant
error when changing pages so stale banners don’t persist across routes.

In `@src/pages/GovernancePage.jsx`:
- Around line 156-163: Add an accessible alert role to the GovernancePage error
banner so screen readers announce the rate-limit message when it appears. Update
the conditional error block in GovernancePage.jsx where the error `<div>` and
`<span>{error}</span>` are rendered to include `role="alert"` on the banner
container, keeping the existing behavior and styling unchanged.
- Around line 164-170: The dismiss control in GovernancePage’s error banner is
an untyped <button> that can default to submit behavior; update the button in
the error-dismiss UI to explicitly set its type to a non-submit value. Use the
existing onClick handler and aria-label on the dismiss button as the anchor, and
make the type explicit so the banner cannot trigger accidental form submission
if it is rendered inside a form.
🪄 Autofix (Beta)

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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 946c0bd1-255d-4312-bccd-f8b2621c707f

📥 Commits

Reviewing files that changed from the base of the PR and between d904719 and 74ebc4f.

📒 Files selected for processing (2)
  • src/context/AppContext.jsx
  • src/pages/GovernancePage.jsx

Comment thread src/context/AppContext.jsx
Comment thread src/context/AppContext.jsx
Comment thread src/pages/GovernancePage.jsx Outdated
Comment thread src/pages/GovernancePage.jsx
@github-actions github-actions Bot added size/M 51-200 lines changed and removed size/S 11-50 lines changed labels Jul 4, 2026
@KaranUnique

Copy link
Copy Markdown
Author

@Ri1tik Could you please take a look at this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working first-time-contributor First time contributor frontend Frontend changes javascript JavaScript/TypeScript changes size/M 51-200 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: runAudit silently swallows rate limit errors — governance page shows incomplete data without any warning

1 participant