Skip to content

Add is_rate_limit_low method#970

Merged
centosinfra-prod-github-app[bot] merged 1 commit intopackit:mainfrom
majamassarini:check-rate-limit
Jan 14, 2026
Merged

Add is_rate_limit_low method#970
centosinfra-prod-github-app[bot] merged 1 commit intopackit:mainfrom
majamassarini:check-rate-limit

Conversation

@majamassarini
Copy link
Copy Markdown
Member

RELEASE NOTES BEGIN

Calls to check the rate limit threshold have been added to the Service API and implemented where possible.

RELEASE NOTES END

@majamassarini majamassarini requested a review from a team as a code owner January 13, 2026 11:15
@majamassarini majamassarini requested review from lbarcziova and removed request for a team January 13, 2026 11:15
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @majamassarini, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the Service API by introducing a new method, is_rate_limit_low, which allows applications to proactively check if they are approaching API rate limits on various Git platforms. This addition aims to improve the robustness and reliability of integrations by enabling better management of API call frequency, thereby preventing service interruptions due to rate limit exhaustion.

Highlights

  • New Abstract Method: Introduced an abstract is_rate_limit_low method in ogr/abstract/git_service.py to provide a standardized way to check API rate limits across different Git services.
  • GitHub Service Implementation: Implemented is_rate_limit_low for GitHub in ogr/services/github/service.py, leveraging the github library to check the remaining core rate limit.
  • GitLab Service Implementation: Implemented is_rate_limit_low for GitLab in ogr/services/gitlab/service.py. Since python-gitlab lacks a direct rate limit method, a HEAD request to the /api/v4/user endpoint is used to extract ratelimit-remaining from response headers. The requests library was imported for this purpose.
  • Pagure Service Implementation: Implemented is_rate_limit_low for Pagure in ogr/services/pagure/service.py, which always returns False as the Pagure API does not expose rate limit information.
  • Integration Tests: Added comprehensive integration tests for the is_rate_limit_low method across GitHub, GitLab, and Pagure services, including new test data files to ensure proper functionality and API interaction.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new method, is_rate_limit_low, to the GitService abstract class and provides implementations for GitHub, GitLab, and Pagure. This is a useful addition for clients of this library to proactively handle API rate limiting. The changes are well-implemented and include corresponding tests. My main feedback is on the GitLab implementation, where the exception handling can be improved to be more specific and to include logging, which will make the code more robust and easier to debug.

Comment thread ogr/services/gitlab/service.py Outdated
@centosinfra-prod-github-app
Copy link
Copy Markdown
Contributor

@centosinfra-prod-github-app
Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Member

@lbarcziova lbarcziova left a comment

Choose a reason for hiding this comment

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

one question about design, otherwise this looks like a good direction!

Comment thread ogr/abstract/git_service.py Outdated
Comment on lines +149 to +150
Returns:
True if the rate limit remaining is less than 100, False otherwise.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what do you think about having the method in ogr to just return the number of remaining API calls, and we would check/control based on that the behaviour on packit-service?

@centosinfra-prod-github-app
Copy link
Copy Markdown
Contributor

Comment thread ogr/services/pagure/service.py Outdated
Comment thread ogr/services/pagure/service.py Outdated
Comment thread ogr/services/gitlab/service.py Outdated
@majamassarini majamassarini force-pushed the check-rate-limit branch 2 times, most recently from b8cc427 to c41b01b Compare January 13, 2026 14:36
Comment thread ogr/services/gitlab/service.py Outdated
@centosinfra-prod-github-app
Copy link
Copy Markdown
Contributor

Comment thread ogr/services/gitlab/service.py
Comment thread ogr/abstract/git_service.py Outdated
@majamassarini majamassarini force-pushed the check-rate-limit branch 2 times, most recently from 5ef359e to 59a0f78 Compare January 14, 2026 09:02
Comment thread ogr/services/github/service.py Outdated
@centosinfra-prod-github-app
Copy link
Copy Markdown
Contributor

@centosinfra-prod-github-app
Copy link
Copy Markdown
Contributor

Comment thread ogr/services/gitlab/service.py
Comment thread ogr/services/pagure/service.py Outdated
Co-authored-by: Nikola Forró <nforro@redhat.com>
@centosinfra-prod-github-app
Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Member

@lbarcziova lbarcziova left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@majamassarini majamassarini added the mergeit Merge via Zuul label Jan 14, 2026
@centosinfra-prod-github-app
Copy link
Copy Markdown
Contributor

@centosinfra-prod-github-app centosinfra-prod-github-app Bot merged commit f15b4bc into packit:main Jan 14, 2026
36 of 38 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in Packit pull requests Jan 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mergeit Merge via Zuul

Projects

Development

Successfully merging this pull request may close these issues.

5 participants