@@ -2,8 +2,11 @@ package connector
22
33import (
44 "context"
5+ "errors"
56 "fmt"
7+ "net/http"
68 "strconv"
9+ "strings"
710
811 "github.com/conductorone/baton-databricks/pkg/databricks"
912 v2 "github.com/conductorone/baton-sdk/pb/c1/connector/v2"
@@ -162,6 +165,28 @@ func (w *workspaceBuilder) Grants(ctx context.Context, resource *v2.Resource, pT
162165 workspace := strconv .Itoa (int (workspaceId ))
163166 assignments , _ , err := w .client .ListWorkspaceMembers (ctx , workspace )
164167 if err != nil {
168+ // Check if this is the specific error for workspaces without permissions API
169+ var apiErr * databricks.APIError
170+ if errors .As (err , & apiErr ) && apiErr .StatusCode == http .StatusBadRequest {
171+ // Check for the specific error message that indicates permissions API is not available
172+ if strings .Contains (apiErr .Message , "Permission assignment APIs are not available for this workspace" ) {
173+ l := ctxzap .Extract (ctx )
174+ l .Info ("Workspace does not have permissions API available - skipping" ,
175+ zap .String ("workspace_id" , workspace ),
176+ zap .String ("workspace_name" , resource .DisplayName ),
177+ )
178+ // Return empty grants for workspaces without permissions API
179+ return []* v2.Grant {}, "" , nil , nil
180+ }
181+ // If it's a 400 but not the specific permissions API error, log it and return error
182+ l := ctxzap .Extract (ctx )
183+ l .Warn ("Received 400 error from workspace API, but not the expected permissions API error" ,
184+ zap .String ("workspace_id" , workspace ),
185+ zap .String ("workspace_name" , resource .DisplayName ),
186+ zap .String ("error_message" , apiErr .Message ),
187+ zap .String ("error_detail" , apiErr .Detail ),
188+ )
189+ }
165190 return nil , "" , nil , fmt .Errorf ("databricks-connector: failed to list workspace members: %w" , err )
166191 }
167192
0 commit comments