Skip to content

feat: add GitHub API rate limit awareness#54

Open
Jiya3177 wants to merge 1 commit into
Hell1213:mainfrom
Jiya3177:feat/github-rate-limit-awareness-37
Open

feat: add GitHub API rate limit awareness#54
Jiya3177 wants to merge 1 commit into
Hell1213:mainfrom
Jiya3177:feat/github-rate-limit-awareness-37

Conversation

@Jiya3177
Copy link
Copy Markdown

Summary

Add rate-limit awareness to GitHubCLIProvider before GitHub API calls.

Related Issue

Fixes #37

Type of Change

  • Bug fix
  • New feature
  • Documentation
  • Refactoring
  • Test changes
  • CI/Chore

Testing

  • uv run ruff check passes
  • uv run mypy passes
  • uv run pytest passes
  • Manual testing done

Manual testing:

  • PYTHONPATH=src python3 -m pytest tests/oss/test_github_cli_provider.py
  • python3 -m ruff check src/oss_dev/providers/github/client.py tests/oss/test_github_cli_provider.py

Description

Added rate-limit checks before gh api calls in GitHubCLIProvider.

This change:

  • Parses gh api rate_limit output.
  • Blocks API calls when remaining quota is exhausted.
  • Warns on low remaining quota.
  • Handles malformed rate-limit responses gracefully.
  • Handles rate-limit CLI errors with clearer ProviderError messages.
  • Avoids recursive checks for gh api rate_limit.

Added focused tests with mocked subprocess.run so no real GitHub API calls are made.

@Hell1213
Copy link
Copy Markdown
Owner

Hell1213 commented Jun 1, 2026

@Jiya3177 Thanks for you contribution , I'm on it will review it shortly

Copy link
Copy Markdown
Owner

@Hell1213 Hell1213 left a comment

Choose a reason for hiding this comment

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

Review: GitHub API rate limit awareness

Hi @Jiya3177, thanks for this PR! The rate limit awareness is well-implemented.

Verified: Tests pass (77/77), ruff checks clean.

Suggestion: _get_rate_limit() calls subprocess.run directly without checking if gh is available. If gh is not installed, the error message from subprocess wont be user-friendly. Consider adding self._require_gh() or self._check_gh() at the start of _get_rate_limit() to give a clear error message.

Important: PR #50 by @Achiever199 also modifies src/oss_dev/providers/github/client.py (adds caching layer). Both PRs touch _run_gh and the class methods. There will be merge conflicts – whoever merges second will need to rebase and reconcile changes to _run_gh, fetch_issue, list_issues, create_pr, etc.

Copy link
Copy Markdown
Owner

@Hell1213 Hell1213 left a comment

Choose a reason for hiding this comment

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

Rate limit logic looks solid. The tests cover the key cases (zero quota, low quota, malformed response, no recursion on rate_limit endpoint). One small thing - _get_rate_limit() uses subprocess.run directly instead of going through _run_gh, so if gh is not installed the error wont be as clear. Not a blocker though.

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.

Add rate limit awareness for GitHub API calls

2 participants