test(github): pagination, 51-check, rate-limit backoff, and run-id tests#123
Conversation
- Memoize `_get_repo_info` per cwd in GitHubClient to eliminate duplicate `gh repo view` calls; each unique working directory gets its own cache entry - Cache branch protection rules once per CI wait in WorkflowStageHandler instead of re-fetching on every 10-second poll iteration - Route all direct `subprocess.run(["gh", ...])` calls in PRContextManager through `self.github_client._run_gh_command()` to gain timeout support and consistent error handling (GitHubError instead of CalledProcessError) - Add `timeout=` to all git subprocess calls in fix_pr.py and workflow_stages.py with TimeoutExpired handlers to prevent indefinite hangs - Update tests in test_client.py, test_client_merge.py, test_pr_context.py, and test_ci_comments_combined.py to reflect the new routing Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- client_pr.py + pr_context.py: use --jq '.[]' with --paginate → parse NDJSON (one object per line) instead of json.loads on concatenated pages - ci_logs.py: paginate /jobs with --jq '.jobs[]'; parse NDJSON output - pr_context.py: paginate GraphQL reviewThreads/contexts via pageInfo; clear CI/comment dirs only AFTER successful fetch (not before), so stale data is preserved on API failure - pr_context.py: collect distinct run IDs from failing checks only; refuse "0 unresolved" when reviewThreads hasNextPage is true - client_ci.py: scope _find_failed_run_id to current git branch; remove green-run fallback (only return ID for genuinely failed runs) - ci_logs.py: anchor _is_error_line with word-bounded regex (FAILED/Failed, ##[error]) to eliminate false positives from substrings like FAILSAFE - Tests: update all mocks to NDJSON format; add preserve-on-failure and clear-after-success tests for both CI and comments paths Co-Authored-By: Claude <noreply@anthropic.com>
- client.py _run_gh_command: detect 403/429 (primary/secondary/abuse),
honor Retry-After, exponential backoff + equal jitter, bounded retries.
- pr_context: batch aliased resolveReviewThread mutations (per-thread
fallback) in post_comment_replies + resolve_addressed_threads.
- resolve_addressed_threads: only auto-resolve bot-last threads; prune
human-reopened threads from the addressed set so feedback re-surfaces.
- save_pr_comments: fetch /issues/{n}/comments conversation feedback that
was previously invisible to the pipeline.
- state_pr: add unmark_threads_addressed for pruning.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- TestGetCommentResolvedMapPagination: 6 tests covering 2-page cursor pagination in _get_comment_resolved_map (including integration with get_pr_comments and graceful error handling) - TestPRStatusContextsPagination: 4 tests for get_pr_status with hasNextPage=True on CI contexts (51 checks warning, count correctness, mixed conclusions) - TestFindFailedRunIdMixedRuns: 8 tests for _find_failed_run_id with mixed green/red/cancelled/in-progress runs; verifies no green fallback and branch scoping - TestRunGhCommandRateLimit +4: abuse detection, too-many-requests, exponential delay growth, and check=False retry coverage Co-Authored-By: Claude <noreply@anthropic.com>
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 11 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (17)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
This comment has been minimized.
This comment has been minimized.
CI failures were all stale test mocks not matching this PR's new GitHubClient behavior: - get_pr_comments tests: emit NDJSON (as `gh api --paginate --jq '.[]'` does) instead of a single JSON array, which parsed to `[[...]]`. - get_failed_run_logs tests: mock the `git rev-parse` branch-detection call added by branch-scoped run lookup; no-failed case now reports "No workflow runs found" (green fallback removed). - rate-limit test: patch time.sleep/console.warning so the backoff retry loop runs instantly instead of hitting the pytest timeout. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Summary
TestGetCommentResolvedMapPagination(6 tests) — verifies_get_comment_resolved_mapfetches a second page using the cursor frompageInfo.endCursor, merges both pages' resolved maps, and degrades gracefully on GraphQL errorsTestPRStatusContextsPagination(4 tests) — verifiesget_pr_statuslogs a warning whencontexts.pageInfo.hasNextPage=True, counts all visible checks correctly, and handles mixed conclusionsTestRunGhCommandRateLimit— abuse-detection marker, too-many-requests/HTTP 429, exponential delay growth across attempts, andcheck=Falsestill retriesTestFindFailedRunIdMixedRuns(8 tests) — verifies_find_failed_run_idpicks the first failed run (not green), returnsNonefor all-green or empty lists, treatscancelledas failed, ignores in-progress runs, and passes the current branch name toget_workflow_runsAll 28 new tests pass; 13 pre-existing failures are unchanged.