@@ -12,9 +12,11 @@ import (
1212 "github.com/conductorone/baton-sdk/pkg/types/entitlement"
1313 "github.com/conductorone/baton-sdk/pkg/types/grant"
1414 rType "github.com/conductorone/baton-sdk/pkg/types/resource"
15+ "github.com/conductorone/baton-sdk/pkg/uhttp"
1516 "github.com/google/go-github/v63/github"
1617 "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap"
1718 "go.uber.org/zap"
19+ "google.golang.org/grpc/codes"
1820)
1921
2022const (
@@ -102,8 +104,11 @@ func (o *teamResourceType) List(ctx context.Context, parentID *v2.ResourceId, pt
102104 }
103105
104106 for _ , team := range teams {
105- fullTeam , _ , err := o .client .Teams .GetTeamByID (ctx , orgID , team .GetID ())
107+ fullTeam , resp , err := o .client .Teams .GetTeamByID (ctx , orgID , team .GetID ())
106108 if err != nil {
109+ if isNotFoundError (resp ) {
110+ return nil , "" , nil , uhttp .WrapErrors (codes .NotFound , fmt .Sprintf ("team: %d not found" , team .GetID ()))
111+ }
107112 return nil , "" , nil , err
108113 }
109114
@@ -178,6 +183,9 @@ func (o *teamResourceType) Grants(ctx context.Context, resource *v2.Resource, pT
178183
179184 users , resp , err := o .client .Teams .ListTeamMembersByID (ctx , org .GetID (), githubID , & opts )
180185 if err != nil {
186+ if isNotFoundError (resp ) {
187+ return nil , "" , nil , uhttp .WrapErrors (codes .NotFound , fmt .Sprintf ("org: %d not found" , org .GetID ()))
188+ }
181189 return nil , "" , nil , fmt .Errorf ("github-connectorv2: failed to fetch team members: %w" , err )
182190 }
183191
@@ -195,6 +203,9 @@ func (o *teamResourceType) Grants(ctx context.Context, resource *v2.Resource, pT
195203 for _ , user := range users {
196204 membership , _ , err := o .client .Teams .GetTeamMembershipByID (ctx , org .GetID (), githubID , user .GetLogin ())
197205 if err != nil {
206+ if isNotFoundError (resp ) {
207+ return nil , "" , nil , uhttp .WrapErrors (codes .NotFound , fmt .Sprintf ("user: %s not found" , user .GetLogin ()))
208+ }
198209 return nil , "" , nil , fmt .Errorf ("github-connectorv2: failed to get team membership for user: %w" , err )
199210 }
200211
0 commit comments