@@ -2,6 +2,7 @@ package client
22
33import (
44 "context"
5+ "errors"
56 "fmt"
67 "math"
78 "math/rand"
@@ -84,7 +85,7 @@ func (rc *RetryConfig) RetryWithExponentialBackoff(
8485 operationName , delay , attempt + 1 , rc .MaxRetries + 1 ),
8586 )
8687
87- tflog .Warn (ctx , "conflict detected, retrying with exponential backoff" , map [string ]interface {} {
88+ tflog .Warn (ctx , "conflict detected, retrying with exponential backoff" , map [string ]any {
8889 "operation" : operationName ,
8990 "status_code" : resp .Response .StatusCode ,
9091 "attempt" : attempt + 1 ,
@@ -112,9 +113,10 @@ func (rc *RetryConfig) RetryWithExponentialBackoff(
112113 // If there's an error, check if it's retryable
113114 if lastErr != nil {
114115 // Check if this is a retryable error (APIError with retryable status code)
115- if apiErr , ok := lastErr .(* APIError ); ok && rc .ShouldRetry (apiErr .StatusCode ) {
116+ apiErr := & APIError {}
117+ if errors .As (lastErr , & apiErr ) && rc .ShouldRetry (apiErr .StatusCode ) {
116118 // This is a retryable error, continue the retry loop
117- tflog .Debug (ctx , "retryable error encountered, continuing retry loop" , map [string ]interface {} {
119+ tflog .Debug (ctx , "retryable error encountered, continuing retry loop" , map [string ]any {
118120 "operation" : operationName ,
119121 "status_code" : apiErr .StatusCode ,
120122 "attempt" : attempt + 1 ,
@@ -138,7 +140,7 @@ func (rc *RetryConfig) RetryWithExponentialBackoff(
138140 operationName , attempt ),
139141 )
140142
141- tflog .Info (ctx , "retry succeeded" , map [string ]interface {} {
143+ tflog .Info (ctx , "retry succeeded" , map [string ]any {
142144 "operation" : operationName ,
143145 "final_attempt" : attempt + 1 ,
144146 "total_retries" : attempt ,
@@ -162,7 +164,7 @@ func (rc *RetryConfig) RetryWithExponentialBackoff(
162164 rc .MaxRetries , operationName ),
163165 )
164166
165- tflog .Error (ctx , "retries exhausted" , map [string ]interface {} {
167+ tflog .Error (ctx , "retries exhausted" , map [string ]any {
166168 "operation" : operationName ,
167169 "max_attempts" : rc .MaxRetries + 1 ,
168170 "final_status" : resp .Response .StatusCode ,
@@ -213,9 +215,10 @@ func (rc *RetryConfig) RetryWithExponentialBackoffLegacy(
213215 // If there's an error, check if it's retryable
214216 if lastErr != nil {
215217 // Check if this is a retryable error (APIError with retryable status code)
216- if apiErr , ok := lastErr .(* APIError ); ok && rc .ShouldRetry (apiErr .StatusCode ) {
218+ apiErr := & APIError {}
219+ if errors .As (lastErr , & apiErr ) && rc .ShouldRetry (apiErr .StatusCode ) {
217220 // This is a retryable error, continue the retry loop
218- tflog .Debug (ctx , "retryable error encountered, continuing retry loop" , map [string ]interface {} {
221+ tflog .Debug (ctx , "retryable error encountered, continuing retry loop" , map [string ]any {
219222 "operation" : operationName ,
220223 "status_code" : apiErr .StatusCode ,
221224 "attempt" : attempt + 1 ,
0 commit comments