Skip to content

Commit 416b3cc

Browse files
author
MB Burch
committed
Remove unneeded rate limit check
1 parent 23133c1 commit 416b3cc

File tree

2 files changed

+3
-65
lines changed

2 files changed

+3
-65
lines changed

pkg/linear/client.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -974,34 +974,23 @@ func (c *Client) doRequest(ctx context.Context, body interface{}, res interface{
974974

975975
// Add logging for troubleshooting
976976
l := ctxzap.Extract(ctx)
977-
isRateLimited := gqlErr.IsRateLimited(ctx)
978977
l.Info("doRequest completed",
979978
zap.Error(err),
980979
zap.Int("status_code", func() int {
981980
if resp != nil {
982981
return resp.StatusCode
983982
}
984983
return 0
985-
}()),
986-
zap.Any("rate_limit_data", rlData),
987-
zap.Bool("gql_err_is_rate_limited", isRateLimited))
984+
}()))
988985

989986
// Linear returns 400 when rate limited, so change it to a retryable error
990-
if err != nil && resp != nil && (resp.StatusCode == http.StatusBadRequest || isRateLimited) {
987+
if err != nil && resp != nil && (resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusTooManyRequests) {
991988
l.Info("rate limiting detected", zap.Int("status_code", resp.StatusCode))
992989

993990
rlData.Status = v2.RateLimitDescription_STATUS_OVERLIMIT
994991
return resp, rlData, uhttp.WrapErrorsWithRateLimitInfo(codes.Unavailable, resp, err)
995992
}
996993

997-
// Ensure error is wrapped with rate limit info when using WithRatelimitData
998-
if err != nil && resp != nil {
999-
l.Info("wrapping error with rate limit info",
1000-
zap.Int("status_code", resp.StatusCode),
1001-
zap.Error(err))
1002-
return resp, rlData, uhttp.WrapErrorsWithRateLimitInfo(codes.Unavailable, resp, err)
1003-
}
1004-
1005994
l.Info("returning without rate limit wrapping")
1006995
return resp, rlData, err
1007996
}

pkg/linear/models.go

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
package linear
22

3-
import (
4-
"context"
5-
"fmt"
6-
"strings"
7-
"time"
8-
9-
"github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap"
10-
"go.uber.org/zap"
11-
)
3+
import "time"
124

135
type PageInfo struct {
146
EndCursor string `json:"endCursor"`
@@ -116,49 +108,6 @@ func (e *GraphQLError) Message() string {
116108
return e.Errors[0].Message
117109
}
118110

119-
// IsRateLimited checks if the error contains Linear's RATELIMITED error code.
120-
func (e *GraphQLError) IsRateLimited(ctx context.Context) bool {
121-
// Get logger from context if available, otherwise use a default logger
122-
l := ctxzap.Extract(ctx)
123-
124-
for _, err := range e.Errors {
125-
// Log the error message and extensions for debugging
126-
l.Info("checking GraphQL error for rate limiting",
127-
zap.String("message", err.Message),
128-
zap.Any("extensions", err.Extensions))
129-
130-
if extensions, ok := err.Extensions["code"]; ok {
131-
l.Info("found 'code' extension",
132-
zap.Any("code_value", extensions),
133-
zap.String("code_type", fmt.Sprintf("%T", extensions)))
134-
135-
if code, ok := extensions.(string); ok && code == "RATELIMITED" {
136-
l.Info("rate limited detected via code extension",
137-
zap.String("code", code))
138-
return true
139-
} else {
140-
l.Info("code extension is not 'RATELIMITED'",
141-
zap.Any("got_value", extensions),
142-
zap.String("got_type", fmt.Sprintf("%T", extensions)))
143-
}
144-
} else {
145-
l.Info("no 'code' extension found")
146-
}
147-
148-
// Also check the message for backward compatibility
149-
if strings.Contains(strings.ToLower(err.Message), "ratelimited") {
150-
l.Info("rate limited detected via message",
151-
zap.String("message", err.Message))
152-
return true
153-
} else {
154-
l.Info("message does not contain 'ratelimited'",
155-
zap.String("message", err.Message))
156-
}
157-
}
158-
l.Info("no rate limiting detected in any GraphQL errors")
159-
return false
160-
}
161-
162111
type ViewerPermissions struct {
163112
Guest bool `json:"guest"`
164113
Admin bool `json:"admin"`

0 commit comments

Comments
 (0)