Skip to content

CodeRabbit レートリミット対応#49

Merged
HappyOnigiri merged 3 commits intomainfrom
cursor/coderabbit-a8af
Mar 11, 2026
Merged

CodeRabbit レートリミット対応#49
HappyOnigiri merged 3 commits intomainfrom
cursor/coderabbit-a8af

Conversation

@HappyOnigiri
Copy link
Owner

@HappyOnigiri HappyOnigiri commented Mar 11, 2026

Summary

  • Implemented handling for CodeRabbit rate limits to prevent premature completion (refix:done) and auto-merging.
  • Introduced an optional feature to automatically post @coderabbitai resume comments after the rate limit waiting period.

Related issues

  • N/A (Referenced CodeRabbit rate limit message from https://github.com/HappyOnigiri/PixelRefiner/pull/4#issuecomment-4039292941)

Changes

  • Modified CodeRabbit status detection to identify rate limit messages and parse the waiting time.
  • When CodeRabbit is rate-limited:
    • The PR remains in a refix:running state (removes refix:done if present, adds refix:running).
    • review-fix and auto-merge processes are skipped.
    • CI failure resolution and merge base operations still proceed.
  • Added a new configuration option coderabbit_auto_resume (default false) to enable automatic @coderabbitai resume comments.
  • Updated README.md, README.ja.md, and .refix.yaml.sample to document the new feature and configuration.

Testing

  • make test passed (113 tests).
  • make ci passed.
  • Extended existing pytest suite with new test cases covering rate limit detection, automatic resume posting, and conditional skipping of review-fix steps.

Checklist

  • I verified the change locally or in CI as appropriate.
  • I added or updated tests when needed.
  • I updated documentation for user-facing changes.
  • I confirmed there are no unintended breaking changes, or documented them clearly.
Open in Web Open in Cursor 

Summary by CodeRabbit

  • 新機能

    • CodeRabbitのレート制限検出と自動再開(coderabbit_auto_resumeで有効化)を追加
    • auto_merge、process_draft_prs の新設定を追加
  • ドキュメント

    • README/日本語版に新オプションとレート制限時の挙動(再開コメントや重複防止、処理スキップ)を追記
  • テスト

    • レート制限検出・再開・コメント処理・設定検証を含むテストを追加・拡充

Co-authored-by: HappyOnigiri <nodemeld+happy-onigiri@gmail.com>
@cursor
Copy link

cursor bot commented Mar 11, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 11, 2026

📝 Walkthrough

Walkthrough

CodeRabbitのレート制限検出と自動リジューム機能を追加。設定キー coderabbit_auto_resume を導入し、Issueコメントから待機期間を解析して再開判定・再開コメント投稿ロジック、関連ユーティリティ、テストおよびドキュメントを実装。

Changes

Cohort / File(s) Summary
設定ファイル・ドキュメント
\.refix\.yaml\.sample, README\.ja\.md, README\.md
coderabbit_auto_resume 設定を追加して挙動を記述。auto_mergeprocess_draft_prs の説明追記とレート制限時の挙動注記を追加。
コア実装(自動修正)
src/auto_fixer.py
Rate-limit検出・待機時間解析・最新活動判定・再開判定・再開コメント投稿のオートリジュームロジックを追加。複数のユーティリティ関数と関数シグネチャ変更(issue_comments 受け渡し等)を導入。既存フローへレート制限状態の伝播と早期分岐を追加。
GitHub コメント取得ユーティリティ
src/pr_reviewer.py
fetch_issue_comments(repo: str, pr_number: int) -> list[dict[str, Any]] を追加し、Issueコメントをページネーション対応で取得・フラット化する機能を提供。
テスト追加・拡張
tests/test_auto_fixer.py, tests/test_pr_reviewer.py
coderabbit_auto_resume の設定検証テスト、レート制限関連ヘルパーとオートリジューム動作の単体テスト、及び Issue コメントのページネーションを検証するテストを追加・拡張。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~35 minutes

Suggested labels

refix:running

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed タイトル「CodeRabbit レートリミット対応」はプルリクエストの主要な変更であるCodeRabbitのレート制限対応機能を明確に要約している。
Description check ✅ Passed プルリクエストの説明はテンプレートの全セクション(Summary、Related issues、Changes、Testing、Checklist)を完備し、変更内容を詳細に記述している。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cursor/coderabbit-a8af

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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/pr_reviewer.py`:
- Around line 132-140: The block that calls subprocess.run and parses
result.stdout must not treat failures as "no comments" by returning []; instead
propagate the error so callers (which set active_rate_limit) can treat failures
safely. Change the handling around subprocess.run/result.returncode and the
json.loads JSONDecodeError: either raise a descriptive exception (e.g.,
RuntimeError) including result.stderr or the JSON error, or return a distinct
sentinel (not []) that callers can detect; update the code that calls this
function (which currently assumes [] means "no comments" and sets
active_rate_limit to None) to handle the new error/sentinel path safely. Ensure
references to subprocess.run, result.returncode, result.stderr, result.stdout,
and json.loads are updated accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2ff2247d-11ec-4f28-8163-122d45eda8e0

📥 Commits

Reviewing files that changed from the base of the PR and between 9304a3d and f71116f.

📒 Files selected for processing (7)
  • .refix.yaml.sample
  • README.ja.md
  • README.md
  • src/auto_fixer.py
  • src/pr_reviewer.py
  • tests/test_auto_fixer.py
  • tests/test_pr_reviewer.py

@HappyOnigiri HappyOnigiri marked this pull request as ready for review March 11, 2026 15:06
結果の取得失敗やJSON解析エラー時に[]ではなくRuntimeErrorを投げるように変更し、呼び出し側(auto_fixer.py)でエラーを正しく検知・スキップできるようにした。
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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/auto_fixer.py`:
- Around line 1311-1327: 現在の認証は関数 _is_coderabbit_login() が
login.startswith("coderabbitai") を使っており "coderabbitai-foo"
のような任意ユーザーも通してしまうため、レート制限判定で悪用されうるので、_is_coderabbit_login()
を厳密一致で判定するよう修正してください(受け入れる値は "coderabbitai" と "coderabbitai[bot]"
のような正確なログイン文字列に限定し、startswith を使わない)。ループ内で使われる該当関数(for comment in
issue_comments: ... if not _is_coderabbit_login(login):
continue)をそのまま使い、関数本体だけを修正して正確な比較ロジックに置き換えてください。

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a399056c-059c-4293-868d-53add9094027

📥 Commits

Reviewing files that changed from the base of the PR and between f71116f and d448b80.

📒 Files selected for processing (2)
  • src/auto_fixer.py
  • src/pr_reviewer.py

…変更し完全一致判定に対応

startswith による判定から、完全一致のみを受け付けるロジック (`coderabbitai`, `coderabbitai[bot]`) へ修正。これに伴い定数名も PREFIX から正確な名前にリネームした。
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.

🧹 Nitpick comments (1)
src/auto_fixer.py (1)

1614-1623: 広範な例外キャッチは最小限に留めることを検討してください。

RuntimeError の後に Exception をキャッチしていますが、これにより予期しないバグが隠れる可能性があります。ただし、ファイル内の他の箇所(例:lines 1604-1607)と一貫したパターンであり、PR 処理の継続性を確保するための防御的プログラミングとして許容範囲です。

将来的には、fetch_issue_comments が発生させうる具体的な例外タイプを特定し、それらを明示的にキャッチすることを検討してください。

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

In `@src/auto_fixer.py` around lines 1614 - 1623, The current try/except around
fetch_issue_comments catches RuntimeError then a broad Exception, which can mask
unexpected bugs; update the try/except in the block around fetch_issue_comments
to catch only the specific exceptions that fetch_issue_comments can raise (e.g.,
network errors, HTTPError, JSONDecodeError or a custom FetchError) instead of
Exception, keep the same error logging to stderr and set pr_fetch_failed =
True/continue for those specific cases, and if unknown exceptions are still
desired to be surfaced during development consider re-raising them or logging
them separately so they are not silently swallowed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/auto_fixer.py`:
- Around line 1614-1623: The current try/except around fetch_issue_comments
catches RuntimeError then a broad Exception, which can mask unexpected bugs;
update the try/except in the block around fetch_issue_comments to catch only the
specific exceptions that fetch_issue_comments can raise (e.g., network errors,
HTTPError, JSONDecodeError or a custom FetchError) instead of Exception, keep
the same error logging to stderr and set pr_fetch_failed = True/continue for
those specific cases, and if unknown exceptions are still desired to be surfaced
during development consider re-raising them or logging them separately so they
are not silently swallowed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 643b92a1-ff6f-4341-9e50-5fa1decf70de

📥 Commits

Reviewing files that changed from the base of the PR and between d448b80 and ac1b5cd.

📒 Files selected for processing (1)
  • src/auto_fixer.py

@HappyOnigiri
Copy link
Owner Author

@coderabbitai

1614-1623: 広範な例外キャッチは最小限に留めることを検討してください。
RuntimeError の後に Exception をキャッチしていますが、これにより予期しないバグが隠れる可能性があります。ただし、ファイル内の他の箇所(例:lines 1604-1607)と一貫したパターンであり、PR 処理の継続性を確保するための防御的プログラミングとして許容範囲です。
将来的には、fetch_issue_comments が発生させうる具体的な例外タイプを特定し、それらを明示的にキャッチすることを検討してください。

許容範囲で将来的には対応した方が良い水準の指摘は不要です。

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 11, 2026

Tip

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

@HappyOnigiri ご指摘ありがとうございます。「現時点では許容範囲だが将来的に改善を検討してほしい」という水準のコメントは今後お伝えしないよう気をつけます。実際に問題のある箇所のみ指摘するよう調整します。


✏️ Learnings added
Learnt from: HappyOnigiri
URL: https://github.com/HappyOnigiri/Refix/pull/49

Timestamp: 2026-03-11T15:23:39.989Z
Learning: In the HappyOnigiri/Refix repository, do not post review comments that are framed as "acceptable for now, but worth addressing in the future." Only flag issues that are genuinely problematic and require attention. Avoid advisory or low-priority suggestions about future improvements.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@HappyOnigiri HappyOnigiri merged commit d03a8d9 into main Mar 11, 2026
2 checks passed
@HappyOnigiri HappyOnigiri deleted the cursor/coderabbit-a8af branch March 11, 2026 15:47
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.

2 participants