Skip to content

Commit

Permalink
specs: handle deletion when reading version
Browse files Browse the repository at this point in the history
If a version isn't found when reading an API spec, don't fail but throw
a warning and let the user recover (create a new resource or remove
from state)
  • Loading branch information
joshbeard committed Aug 23, 2024
1 parent d93b515 commit 828c150
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion readme/api_specification_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func (r *apiSpecResource) Read(ctx context.Context, req resource.ReadRequest, re
version: version,
})
if err != nil {
if strings.Contains(err.Error(), "API specification not found") {
if strings.Contains(err.Error(), "API specification not found") || strings.Contains(err.Error(), "no match for version ID") {
tflog.Warn(ctx, fmt.Sprintf("API specification %s not found. Removing from state.", state.ID.ValueString()))
resp.State.RemoveResource(ctx)

Expand Down

0 comments on commit 828c150

Please sign in to comment.