From 286e153540e9dd498df82da96dd79ba3de37b07c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Aug 2025 04:03:50 +0000 Subject: [PATCH] Bump github.com/conductorone/baton-sdk from 0.3.28 to 0.3.33 Bumps [github.com/conductorone/baton-sdk](https://github.com/conductorone/baton-sdk) from 0.3.28 to 0.3.33. - [Release notes](https://github.com/conductorone/baton-sdk/releases) - [Commits](https://github.com/conductorone/baton-sdk/compare/v0.3.28...v0.3.33) --- updated-dependencies: - dependency-name: github.com/conductorone/baton-sdk dependency-version: 0.3.33 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +- .../pkg/connectorbuilder/connectorbuilder.go | 43 +++--- .../conductorone/baton-sdk/pkg/sdk/version.go | 2 +- .../baton-sdk/pkg/sync/expand/cycle.go | 128 +++++++++++++----- .../baton-sdk/pkg/uhttp/wrapper.go | 5 + vendor/modules.txt | 2 +- 7 files changed, 130 insertions(+), 56 deletions(-) diff --git a/go.mod b/go.mod index f5ce060a..1485c622 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/conductorone/baton-sql go 1.24 require ( - github.com/conductorone/baton-sdk v0.3.28 + github.com/conductorone/baton-sdk v0.3.33 github.com/elliotchance/phpserialize v1.4.0 github.com/ennyjfrick/ruleguard-logfatal v0.0.2 github.com/go-sql-driver/mysql v1.9.2 diff --git a/go.sum b/go.sum index 98c4d5ad..cb687e94 100644 --- a/go.sum +++ b/go.sum @@ -74,8 +74,8 @@ github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyY github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/conductorone/baton-sdk v0.3.28 h1:tvOpgWr9MjBaG/eXj17oGl9EGGe1/yC5MMQTCcfQPhI= -github.com/conductorone/baton-sdk v0.3.28/go.mod h1:L55WO3ERMx1mfpjDgwK3jWNRGRF2E76WrQHmW6ev8VY= +github.com/conductorone/baton-sdk v0.3.33 h1:N8KAk8d7qpWrIU4BKualH5vyjxyCL4yDSsW4EFw0+mg= +github.com/conductorone/baton-sdk v0.3.33/go.mod h1:L55WO3ERMx1mfpjDgwK3jWNRGRF2E76WrQHmW6ev8VY= github.com/conductorone/dpop v0.2.4 h1:PaiDOX1gAIXtOJPxXf08GsGkpCuT/iECEjSJzLpi0zU= github.com/conductorone/dpop v0.2.4/go.mod h1:gyo8TtzB9SCFCsjsICH4IaLZ7y64CcrDXMOPBwfq/3s= github.com/conductorone/dpop/integrations/dpop_grpc v0.2.4 h1:lYxYi9/WTSL9sE96CO0QF2BY3kehs8dTTApI134TGCA= diff --git a/vendor/github.com/conductorone/baton-sdk/pkg/connectorbuilder/connectorbuilder.go b/vendor/github.com/conductorone/baton-sdk/pkg/connectorbuilder/connectorbuilder.go index f1037104..df60a97f 100644 --- a/vendor/github.com/conductorone/baton-sdk/pkg/connectorbuilder/connectorbuilder.go +++ b/vendor/github.com/conductorone/baton-sdk/pkg/connectorbuilder/connectorbuilder.go @@ -325,25 +325,36 @@ func (b *builderImpl) ListTicketSchemas(ctx context.Context, request *v2.Tickets return nil, fmt.Errorf("error: ticket manager not implemented") } - out, nextPageToken, annos, err := b.ticketManager.ListTicketSchemas(ctx, &pagination.Token{ - Size: int(request.PageSize), - Token: request.PageToken, + retryer := retry.NewRetryer(ctx, retry.RetryConfig{ + MaxAttempts: 10, + InitialDelay: 15 * time.Second, + MaxDelay: 0, }) - if err != nil { + + for { + out, nextPageToken, annos, err := b.ticketManager.ListTicketSchemas(ctx, &pagination.Token{ + Size: int(request.PageSize), + Token: request.PageToken, + }) + if err == nil { + if request.PageToken != "" && request.PageToken == nextPageToken { + b.m.RecordTaskFailure(ctx, tt, b.nowFunc().Sub(start)) + return nil, fmt.Errorf("error: listing ticket schemas failed: next page token is the same as the current page token. this is most likely a connector bug") + } + + b.m.RecordTaskSuccess(ctx, tt, b.nowFunc().Sub(start)) + return &v2.TicketsServiceListTicketSchemasResponse{ + List: out, + NextPageToken: nextPageToken, + Annotations: annos, + }, nil + } + if retryer.ShouldWaitAndRetry(ctx, err) { + continue + } b.m.RecordTaskFailure(ctx, tt, b.nowFunc().Sub(start)) return nil, fmt.Errorf("error: listing ticket schemas failed: %w", err) } - if request.PageToken != "" && request.PageToken == nextPageToken { - b.m.RecordTaskFailure(ctx, tt, b.nowFunc().Sub(start)) - return nil, fmt.Errorf("error: listing ticket schemas failed: next page token is the same as the current page token. this is most likely a connector bug") - } - - b.m.RecordTaskSuccess(ctx, tt, b.nowFunc().Sub(start)) - return &v2.TicketsServiceListTicketSchemasResponse{ - List: out, - NextPageToken: nextPageToken, - Annotations: annos, - }, nil } func (b *builderImpl) CreateTicket(ctx context.Context, request *v2.TicketsServiceCreateTicketRequest) (*v2.TicketsServiceCreateTicketResponse, error) { @@ -978,7 +989,7 @@ func (b *builderImpl) Validate(ctx context.Context, request *v2.ConnectorService defer span.End() retryer := retry.NewRetryer(ctx, retry.RetryConfig{ - MaxAttempts: 0, // 0 means no limit - retry indefinitely + MaxAttempts: 5, InitialDelay: 1 * time.Second, MaxDelay: 0, }) diff --git a/vendor/github.com/conductorone/baton-sdk/pkg/sdk/version.go b/vendor/github.com/conductorone/baton-sdk/pkg/sdk/version.go index d2c0142c..038ee11d 100644 --- a/vendor/github.com/conductorone/baton-sdk/pkg/sdk/version.go +++ b/vendor/github.com/conductorone/baton-sdk/pkg/sdk/version.go @@ -1,3 +1,3 @@ package sdk -const Version = "v0.3.27" +const Version = "v0.3.32" diff --git a/vendor/github.com/conductorone/baton-sdk/pkg/sync/expand/cycle.go b/vendor/github.com/conductorone/baton-sdk/pkg/sync/expand/cycle.go index 867cd6fb..292d0261 100644 --- a/vendor/github.com/conductorone/baton-sdk/pkg/sync/expand/cycle.go +++ b/vendor/github.com/conductorone/baton-sdk/pkg/sync/expand/cycle.go @@ -4,6 +4,92 @@ import ( mapset "github.com/deckarep/golang-set/v2" ) +const ( + colorWhite uint8 = iota + colorGray + colorBlack +) + +// cycleDetector encapsulates coloring state for cycle detection on an +// EntitlementGraph. Node IDs are dense (1..NextNodeID), so slices are used for +// O(1) access and zero per-op allocations. +type cycleDetector struct { + g *EntitlementGraph + state []uint8 + parent []int +} + +func newCycleDetector(g *EntitlementGraph) *cycleDetector { + cd := &cycleDetector{ + g: g, + state: make([]uint8, g.NextNodeID+1), + parent: make([]int, g.NextNodeID+1), + } + for i := range cd.parent { + cd.parent[i] = -1 + } + return cd +} + +// dfs performs a coloring-based DFS from u, returning the first detected cycle +// as a slice of node IDs or nil if no cycle is reachable from u. +func (cd *cycleDetector) dfs(u int) ([]int, bool) { + // Self-loop fast path. + if nbrs, ok := cd.g.SourcesToDestinations[u]; ok { + if _, ok := nbrs[u]; ok { + return []int{u}, true + } + } + + cd.state[u] = colorGray + if nbrs, ok := cd.g.SourcesToDestinations[u]; ok { + for v := range nbrs { + switch cd.state[v] { + case colorWhite: + cd.parent[v] = u + if cyc, ok := cd.dfs(v); ok { + return cyc, true + } + case colorGray: + // Back-edge to a node on the current recursion stack. + // Reconstruct cycle by walking parents from u back to v (inclusive), then reverse. + cycle := make([]int, 0, 8) + for x := u; ; x = cd.parent[x] { + cycle = append(cycle, x) + if x == v || cd.parent[x] == -1 { + break + } + } + for i, j := 0, len(cycle)-1; i < j; i, j = i+1, j-1 { + cycle[i], cycle[j] = cycle[j], cycle[i] + } + return cycle, true + } + } + } + cd.state[u] = colorBlack + return nil, false +} + +// FindAny scans all nodes and returns the first detected cycle or nil if none exist. +func (cd *cycleDetector) FindAny() []int { + for nodeID := range cd.g.Nodes { + if cd.state[nodeID] != colorWhite { + continue + } + if cyc, ok := cd.dfs(nodeID); ok { + return cyc + } + } + return nil +} + +// FindFrom starts cycle detection from a specific node and returns the first +// cycle reachable from that node, or nil,false if none. +func (cd *cycleDetector) FindFrom(start int) ([]int, bool) { + return cd.dfs(start) +} + // GetFirstCycle given an entitlements graph, return a cycle by node ID if it // exists. Returns nil if no cycle exists. If there is a single // node pointing to itself, that will count as a cycle. @@ -11,46 +97,18 @@ func (g *EntitlementGraph) GetFirstCycle() []int { if g.HasNoCycles { return nil } - visited := mapset.NewSet[int]() - for nodeID := range g.Nodes { - cycle, hasCycle := g.cycleDetectionHelper(nodeID, visited, []int{}) - if hasCycle { - return cycle - } - } - - return nil + cd := newCycleDetector(g) + return cd.FindAny() } func (g *EntitlementGraph) cycleDetectionHelper( nodeID int, - visited mapset.Set[int], - currentCycle []int, ) ([]int, bool) { - visited.Add(nodeID) - if destinations, ok := g.SourcesToDestinations[nodeID]; ok { - for destinationID := range destinations { - nextCycle := make([]int, len(currentCycle)) - copy(nextCycle, currentCycle) - nextCycle = append(nextCycle, nodeID) - - if !visited.Contains(destinationID) { - if cycle, hasCycle := g.cycleDetectionHelper(destinationID, visited, nextCycle); hasCycle { - return cycle, true - } - } else { - // Make sure to not include part of the start before the cycle. - outputCycle := make([]int, 0) - for i := len(nextCycle) - 1; i >= 0; i-- { - outputCycle = append(outputCycle, nextCycle[i]) - if nextCycle[i] == destinationID { - return outputCycle, true - } - } - } - } - } - return nil, false + // Thin wrapper around the coloring-based DFS, starting from a specific node. + // The provided visited/currentCycle are ignored here; coloring provides the + // necessary state for correctness and performance. + cd := newCycleDetector(g) + return cd.FindFrom(nodeID) } // removeNode obliterates a node and all incoming/outgoing edges. diff --git a/vendor/github.com/conductorone/baton-sdk/pkg/uhttp/wrapper.go b/vendor/github.com/conductorone/baton-sdk/pkg/uhttp/wrapper.go index 1a368cac..3d3075e0 100644 --- a/vendor/github.com/conductorone/baton-sdk/pkg/uhttp/wrapper.go +++ b/vendor/github.com/conductorone/baton-sdk/pkg/uhttp/wrapper.go @@ -271,6 +271,11 @@ func WithGenericResponse(response *map[string]any) DoOption { if response == nil { return status.Error(codes.InvalidArgument, "response is nil") } + + if resp.StatusCode == http.StatusNoContent { + return nil + } + var v any var err error diff --git a/vendor/modules.txt b/vendor/modules.txt index 6185519d..06c802f6 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -162,7 +162,7 @@ github.com/benbjohnson/clock # github.com/cenkalti/backoff/v4 v4.3.0 ## explicit; go 1.18 github.com/cenkalti/backoff/v4 -# github.com/conductorone/baton-sdk v0.3.28 +# github.com/conductorone/baton-sdk v0.3.33 ## explicit; go 1.23.4 github.com/conductorone/baton-sdk/internal/connector github.com/conductorone/baton-sdk/pb/c1/c1z/v1