Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f9bf9bc1aa |
@ -52,7 +52,8 @@ const (
|
|||||||
// This error occurs when an attempt is made to create a folder that has
|
// This error occurs when an attempt is made to create a folder that has
|
||||||
// the same name as another folder in the same parent. Such duplicate folder
|
// the same name as another folder in the same parent. Such duplicate folder
|
||||||
// names are not allowed by graph.
|
// names are not allowed by graph.
|
||||||
folderExists errorCode = "ErrorFolderExists"
|
folderExists errorCode = "ErrorFolderExists"
|
||||||
|
invalidRequest errorCode = "invalidRequest"
|
||||||
// Some datacenters are returning this when we try to get the inbox of a user
|
// Some datacenters are returning this when we try to get the inbox of a user
|
||||||
// that doesn't exist.
|
// that doesn't exist.
|
||||||
invalidUser errorCode = "ErrorInvalidUser"
|
invalidUser errorCode = "ErrorInvalidUser"
|
||||||
@ -140,6 +141,14 @@ var (
|
|||||||
ErrTokenExpired = clues.New("jwt token expired")
|
ErrTokenExpired = clues.New("jwt token expired")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// IsErrInvalidRequest is to retry transient graph 400 errors with odata error code
|
||||||
|
// set to invalidRequest.
|
||||||
|
func IsErrInvalidRequest(err error, resp *http.Response) bool {
|
||||||
|
return resp != nil &&
|
||||||
|
resp.StatusCode == http.StatusBadRequest &&
|
||||||
|
parseODataErr(err).hasErrorCode(err, invalidRequest)
|
||||||
|
}
|
||||||
|
|
||||||
func IsErrApplicationThrottled(err error) bool {
|
func IsErrApplicationThrottled(err error) bool {
|
||||||
return errors.Is(err, ErrApplicationThrottled) ||
|
return errors.Is(err, ErrApplicationThrottled) ||
|
||||||
parseODataErr(err).hasErrorCode(err, applicationThrottled)
|
parseODataErr(err).hasErrorCode(err, applicationThrottled)
|
||||||
|
|||||||
@ -161,7 +161,8 @@ func (mw RetryMiddleware) Intercept(
|
|||||||
|
|
||||||
retriable := IsErrTimeout(err) ||
|
retriable := IsErrTimeout(err) ||
|
||||||
IsErrConnectionReset(err) ||
|
IsErrConnectionReset(err) ||
|
||||||
mw.isRetriableRespCode(ctx, resp)
|
mw.isRetriableRespCode(ctx, resp) ||
|
||||||
|
IsErrInvalidRequest(err, resp)
|
||||||
|
|
||||||
if !retriable {
|
if !retriable {
|
||||||
return resp, stackReq(ctx, req, resp, err).OrNil()
|
return resp, stackReq(ctx, req, resp, err).OrNil()
|
||||||
@ -206,7 +207,7 @@ func (mw RetryMiddleware) retryRequest(
|
|||||||
// 1, there was a prior error OR the status code match retriable conditions.
|
// 1, there was a prior error OR the status code match retriable conditions.
|
||||||
// 3, the request method is retriable.
|
// 3, the request method is retriable.
|
||||||
// 4, we haven't already hit maximum retries.
|
// 4, we haven't already hit maximum retries.
|
||||||
shouldRetry := (priorErr != nil || mw.isRetriableRespCode(ctx, resp)) &&
|
shouldRetry := (priorErr != nil || mw.isRetriableRespCode(ctx, resp) || IsErrInvalidRequest(priorErr, resp)) &&
|
||||||
mw.isRetriableRequest(req) &&
|
mw.isRetriableRequest(req) &&
|
||||||
executionCount < mw.MaxRetries
|
executionCount < mw.MaxRetries
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user