Skip to content

Commit a91fae0

Browse files
author
MB Burch
authored
Merge pull request #33 from ConductorOne/mbburch/test-ticket-schema-rate-limits
Updates for ticket schema rate limits
2 parents 3fc3c19 + e1cd577 commit a91fae0

File tree

7 files changed

+48
-22
lines changed

7 files changed

+48
-22
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.23.4
55
toolchain go1.24.0
66

77
require (
8-
github.com/conductorone/baton-sdk v0.3.28
8+
github.com/conductorone/baton-sdk v0.3.29
99
github.com/ennyjfrick/ruleguard-logfatal v0.0.2
1010
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
1111
github.com/quasilyte/go-ruleguard/dsl v0.3.22

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyY
5858
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
5959
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
6060
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
61-
github.com/conductorone/baton-sdk v0.3.28 h1:tvOpgWr9MjBaG/eXj17oGl9EGGe1/yC5MMQTCcfQPhI=
62-
github.com/conductorone/baton-sdk v0.3.28/go.mod h1:L55WO3ERMx1mfpjDgwK3jWNRGRF2E76WrQHmW6ev8VY=
61+
github.com/conductorone/baton-sdk v0.3.29 h1:HcWmyd28bi9vYLziiVUEWx+ODXaqPHsETcS4E1BQE80=
62+
github.com/conductorone/baton-sdk v0.3.29/go.mod h1:L55WO3ERMx1mfpjDgwK3jWNRGRF2E76WrQHmW6ev8VY=
6363
github.com/conductorone/dpop v0.2.3 h1:s91U3845GHQ6P6FWrdNr2SEOy1ES/jcFs1JtKSl2S+o=
6464
github.com/conductorone/dpop v0.2.3/go.mod h1:gyo8TtzB9SCFCsjsICH4IaLZ7y64CcrDXMOPBwfq/3s=
6565
github.com/conductorone/dpop/integrations/dpop_grpc v0.2.3 h1:kLMCNIh0Mo2vbvvkCmJ3ixsPbXEJ6HPcW53Ku9yje3s=

pkg/connector/tickets.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,12 @@ func (ln *Linear) ListTicketSchemas(ctx context.Context, p *pagination.Token) ([
152152
if err != nil {
153153
return nil, "", nil, err
154154
}
155+
l := ctxzap.Extract(ctx)
155156

156157
teams, nextToken, _, rlData, err := ln.client.ListTeamWorkflowStates(ctx, linear.GetTeamsVars{After: bag.PageToken(), First: resourcePageSize})
157158
annotations.WithRateLimiting(rlData)
158159
if err != nil {
160+
l.Debug("teams failed", zap.Error(err), zap.Any("rlData", rlData))
159161
return nil, "", annotations, fmt.Errorf("baton-linear: failed to list teams: %w", err)
160162
}
161163

@@ -164,8 +166,10 @@ func (ln *Linear) ListTicketSchemas(ctx context.Context, p *pagination.Token) ([
164166
return nil, "", annotations, err
165167
}
166168

167-
fields, _, _, _, err := ln.client.ListIssueFields(ctx)
169+
fields, _, _, rlData, err := ln.client.ListIssueFields(ctx)
170+
annotations.WithRateLimiting(rlData)
168171
if err != nil {
172+
l.Debug("fields failed", zap.Error(err), zap.Any("rlData", rlData))
169173
return nil, "", annotations, fmt.Errorf("baton-linear: failed to list issue fields: %w", err)
170174
}
171175

pkg/linear/client.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,9 +971,20 @@ func (c *Client) doRequest(ctx context.Context, body interface{}, res interface{
971971
}
972972

973973
resp, err := c.httpClient.Do(req, doOptions...)
974+
975+
l := ctxzap.Extract(ctx)
974976
// Linear returns 400 when rate limited, so change it to a retryable error
975-
if err != nil && resp != nil && resp.StatusCode == http.StatusBadRequest {
977+
if err != nil && resp != nil && (resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusTooManyRequests) {
978+
l.Debug("rate limiting detected", zap.Int("status_code", resp.StatusCode))
979+
980+
rlData.Status = v2.RateLimitDescription_STATUS_OVERLIMIT
976981
return resp, rlData, uhttp.WrapErrorsWithRateLimitInfo(codes.Unavailable, resp, err)
977982
}
983+
984+
if resp != nil {
985+
l.Debug("returning without rate limit wrapping", zap.Int("status_code", resp.StatusCode))
986+
} else {
987+
l.Debug("returning without rate limit wrapping", zap.String("status_code", "nil response"))
988+
}
978989
return resp, rlData, err
979990
}

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.

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

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ github.com/benbjohnson/clock
156156
# github.com/cenkalti/backoff/v4 v4.3.0
157157
## explicit; go 1.18
158158
github.com/cenkalti/backoff/v4
159-
# github.com/conductorone/baton-sdk v0.3.28
159+
# github.com/conductorone/baton-sdk v0.3.29
160160
## explicit; go 1.23.4
161161
github.com/conductorone/baton-sdk/internal/connector
162162
github.com/conductorone/baton-sdk/pb/c1/c1z/v1

0 commit comments

Comments
 (0)