Skip to content

Commit 3901673

Browse files
committed
Remove resource from state when not found on server during Read
When a publisher or rule is deleted externally, the Read method now removes it from state instead of returning an error, allowing Terraform to plan a recreation. https://claude.ai/code/session_019ocavNKpCndi448shsGs4Q
1 parent 5a64a9b commit 3901673

2 files changed

Lines changed: 2 additions & 8 deletions

File tree

internal/provider/notification_publisher_resource.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,7 @@ func (r *notificationPublisherResource) Read(ctx context.Context, req resource.R
154154

155155
publisher, err := r.findPublisher(ctx, publisherID)
156156
if err != nil {
157-
resp.Diagnostics.AddError(
158-
"Unable to read notification publisher",
159-
"Error from: "+err.Error(),
160-
)
157+
resp.State.RemoveResource(ctx)
161158
return
162159
}
163160

internal/provider/notification_rule_resource.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,7 @@ func (r *notificationRuleResource) Read(ctx context.Context, req resource.ReadRe
272272

273273
rule, err := r.findRule(ctx, ruleID)
274274
if err != nil {
275-
resp.Diagnostics.AddError(
276-
"Unable to read notification rule",
277-
"Error from: "+err.Error(),
278-
)
275+
resp.State.RemoveResource(ctx)
279276
return
280277
}
281278

0 commit comments

Comments
 (0)