This is an automated email from the ASF dual-hosted git repository.

lynwee pushed a commit to branch release-v1.0
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/release-v1.0 by this push:
     new 8b47a7266 fix: ratelimit on GHE might be disabled (#8204)
8b47a7266 is described below

commit 8b47a72661b0f1ae4598113c616a747345f0da63
Author: Klesh Wong <[email protected]>
AuthorDate: Wed Nov 20 17:45:42 2024 +0800

    fix: ratelimit on GHE might be disabled (#8204)
---
 backend/plugins/github_graphql/impl/impl.go | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/backend/plugins/github_graphql/impl/impl.go 
b/backend/plugins/github_graphql/impl/impl.go
index a1d77d176..31fe0a9b7 100644
--- a/backend/plugins/github_graphql/impl/impl.go
+++ b/backend/plugins/github_graphql/impl/impl.go
@@ -144,7 +144,7 @@ func (p GithubGraphql) SubTaskMetas() []plugin.SubTaskMeta {
 }
 
 type GraphQueryRateLimit struct {
-       RateLimit struct {
+       RateLimit *struct {
                Limit     graphql.Int
                Remaining graphql.Int
                ResetAt   time.Time
@@ -229,6 +229,10 @@ func (p GithubGraphql) PrepareTaskData(taskCtx 
plugin.TaskContext, options map[s
                        if len(dataErrors) > 0 {
                                return 0, nil, 
errors.Default.Wrap(dataErrors[0], `query rate limit fail`)
                        }
+                       if query.RateLimit == nil {
+                               logger.Info(`github graphql rate limit are 
disabled, fallback to 5000req/hour`)
+                               return 5000, nil, nil
+                       }
                        logger.Info(`github graphql init success with remaining 
%d/%d and will reset at %s`,
                                query.RateLimit.Remaining, 
query.RateLimit.Limit, query.RateLimit.ResetAt)
                        return int(query.RateLimit.Remaining), 
&query.RateLimit.ResetAt, nil

Reply via email to