Skip to content

Commit

Permalink
Error if connector returns same pagination as previous list call. (#107)
Browse files Browse the repository at this point in the history
If this ever happens, the connector will be stuck in an infinitel loop, fetching the same page over and over.
  • Loading branch information
ggreer authored Feb 26, 2024
1 parent 5cced7c commit a42541c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/connectorbuilder/connectorbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ func (b *builderImpl) ListResources(ctx context.Context, request *v2.ResourcesSe
if err != nil {
return nil, fmt.Errorf("error: listing resources failed: %w", err)
}
if request.PageToken != "" && request.PageToken == nextPageToken {
return nil, fmt.Errorf("error: listing resources failed: next page token is the same as the current page token. this is most likely a connector bug")
}

return &v2.ResourcesServiceListResourcesResponse{
List: out,
Expand All @@ -210,6 +213,9 @@ func (b *builderImpl) ListEntitlements(ctx context.Context, request *v2.Entitlem
if err != nil {
return nil, fmt.Errorf("error: listing entitlements failed: %w", err)
}
if request.PageToken != "" && request.PageToken == nextPageToken {
return nil, fmt.Errorf("error: listing entitlements failed: next page token is the same as the current page token. this is most likely a connector bug")
}

return &v2.EntitlementsServiceListEntitlementsResponse{
List: out,
Expand All @@ -232,6 +238,9 @@ func (b *builderImpl) ListGrants(ctx context.Context, request *v2.GrantsServiceL
if err != nil {
return nil, fmt.Errorf("error: listing grants failed: %w", err)
}
if request.PageToken != "" && request.PageToken == nextPageToken {
return nil, fmt.Errorf("error: listing grants failed: next page token is the same as the current page token. this is most likely a connector bug")
}

return &v2.GrantsServiceListGrantsResponse{
List: out,
Expand Down

0 comments on commit a42541c

Please sign in to comment.