MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / isRequestInvalidError

Function isRequestInvalidError

sdk/cliproxy/auth/conductor.go:4040–4068  ·  view source on GitHub ↗

isRequestInvalidError returns true if the error represents a client request error that should not be retried. Specifically, it treats 400 responses with "invalid_request_error", request-scoped 404 item misses caused by `store=false`, and all 422 responses as request-shape failures, where switching a

(err error)

Source from the content-addressed store, hash-verified

4038// pooled upstream models will not help. Model-support errors are excluded so
4039// routing can fall through to another auth or upstream.
4040func isRequestInvalidError(err error) bool {
4041 if err == nil {
4042 return false
4043 }
4044 if isCloudflareChallengeError(err) {
4045 return false
4046 }
4047 if isModelSupportError(err) {
4048 return false
4049 }
4050 status := statusCodeFromError(err)
4051 switch status {
4052 case http.StatusBadRequest:
4053 msg := err.Error()
4054 return strings.Contains(msg, "invalid_request_error") ||
4055 strings.Contains(msg, "INVALID_ARGUMENT") ||
4056 strings.Contains(msg, "FAILED_PRECONDITION")
4057 case http.StatusNotFound:
4058 return isRequestScopedNotFoundMessage(err.Error())
4059 case http.StatusUnprocessableEntity:
4060 return true
4061 case http.StatusInternalServerError:
4062 msg := err.Error()
4063 return strings.Contains(msg, "\"status\":\"UNKNOWN\"") ||
4064 strings.Contains(msg, "\"status\": \"UNKNOWN\"")
4065 default:
4066 return false
4067 }
4068}
4069
4070func applyAuthFailureState(auth *Auth, resultErr *Error, retryAfter *time.Duration, now time.Time, disableCooling bool) {
4071 if auth == nil {

Callers 5

executeMixedOnceMethod · 0.85
executeCountMixedOnceMethod · 0.85
shouldRetryAfterErrorMethod · 0.85

Calls 5

isModelSupportErrorFunction · 0.85
statusCodeFromErrorFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected