Skip to content

Commit acd7c9b

Browse files
committed
fix: expires not cleared in state when token has no expiry
When NetBox returns a token with no expiration, the Read function skipped the d.Set call entirely, leaving any previous expires value in state. Explicitly set expires to nil when the API returns no expiration date to prevent state drift.
1 parent 817c5da commit acd7c9b

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

netbox/resource_netbox_token.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ func resourceNetboxTokenRead(ctx context.Context, d *schema.ResourceData, m inte
135135
d.Set("last_used", token.LastUsed)
136136
if token.Expires != nil {
137137
d.Set("expires", token.Expires.String())
138+
} else {
139+
d.Set("expires", nil)
138140
}
139141
d.Set("allowed_ips", token.AllowedIps)
140142
d.Set("write_enabled", token.WriteEnabled)

0 commit comments

Comments
 (0)