Skip to content

Commit 1d0e190

Browse files
author
MB Burch
committed
Test change to connectorbuilder for rate limiting
1 parent 6b299b8 commit 1d0e190

File tree

3 files changed

+29
-40
lines changed

3 files changed

+29
-40
lines changed

pkg/linear/client.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -972,10 +972,8 @@ func (c *Client) doRequest(ctx context.Context, body interface{}, res interface{
972972

973973
resp, err := c.httpClient.Do(req, doOptions...)
974974
// Linear returns 400 when rate limited, so change it to a retryable error
975-
if err != nil && resp != nil && resp.StatusCode == http.StatusBadRequest && gqlErr.IsRateLimited() {
976-
rlData.Status = v2.RateLimitDescription_STATUS_OVERLIMIT
975+
if err != nil && resp != nil && resp.StatusCode == http.StatusBadRequest {
977976
return resp, rlData, uhttp.WrapErrorsWithRateLimitInfo(codes.Unavailable, resp, err)
978977
}
979-
980978
return resp, rlData, err
981979
}

pkg/linear/models.go

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package linear
22

3-
import (
4-
"strings"
5-
"time"
6-
)
3+
import "time"
74

85
type PageInfo struct {
96
EndCursor string `json:"endCursor"`
@@ -96,8 +93,7 @@ type Project struct {
9693
type GraphQLError struct {
9794
Error string `json:"error"`
9895
Errors []struct {
99-
Message string `json:"message"`
100-
Extensions map[string]interface{} `json:"extensions,omitempty"`
96+
Message string `json:"message"`
10197
} `json:"errors"`
10298
}
10399

@@ -111,22 +107,6 @@ func (e *GraphQLError) Message() string {
111107
return e.Errors[0].Message
112108
}
113109

114-
// IsRateLimited checks if the error contains Linear's RATELIMITED error code
115-
func (e *GraphQLError) IsRateLimited() bool {
116-
for _, err := range e.Errors {
117-
if extensions, ok := err.Extensions["code"]; ok {
118-
if code, ok := extensions.(string); ok && code == "RATELIMITED" {
119-
return true
120-
}
121-
}
122-
// Also check the message for backward compatibility
123-
if strings.Contains(strings.ToLower(err.Message), "ratelimited") {
124-
return true
125-
}
126-
}
127-
return false
128-
}
129-
130110
type ViewerPermissions struct {
131111
Guest bool `json:"guest"`
132112
Admin bool `json:"admin"`

vendor/github.com/conductorone/baton-sdk/pkg/connectorbuilder/connectorbuilder.go

Lines changed: 26 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)