Skip to content

Commit

Permalink
Gracefully handle 404 in team member resource (#447)
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-z authored Jun 10, 2024
1 parent 6f16d7c commit fe1f589
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/provider/resource_team_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"fmt"
"slices"
"strings"
"sync"

"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
Expand Down Expand Up @@ -275,8 +276,11 @@ func (r *TeamMemberResource) Read(ctx context.Context, req resource.ReadRequest,

effectiveRole, err := r.getEffectiveTeamRole(ctx, data.Organization.ValueString(), data.MemberId.ValueString(), data.Team.ValueString())
if err != nil {
resp.Diagnostics.AddError("Client Error", err.Error())
resp.State.RemoveResource(ctx)
if strings.Contains(err.Error(), "404 The requested resource does not exist") {
resp.State.RemoveResource(ctx)
} else {
resp.Diagnostics.AddError("Client Error", err.Error())
}
return
}

Expand Down

0 comments on commit fe1f589

Please sign in to comment.