nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: google/go-containerregistry
Pull request #901 (2021-01-07 14:03:20)

Retry registry access on some server errors.
Sometimes the error is on proxy level, but it still will be beneficial to retry it.


Patch:
diff --git a/pkg/v1/remote/transport/error.go b/pkg/v1/remote/transport/error.go
index dba7d841..23f44ad7 100644
--- a/pkg/v1/remote/transport/error.go
+++ b/pkg/v1/remote/transport/error.go
@@ -89,7 +89,8 @@ func (e *Error) responseErr() string {
 // Temporary returns whether the request that preceded the error is temporary.
 func (e *Error) Temporary() bool {
 	if len(e.Errors) == 0 {
-		return false
+		_, ok := temporaryStatusCodes[e.StatusCode]
+		return ok
 	}
 	for _, d := range e.Errors {
 		if _, ok := temporaryErrorCodes[d.Code]; !ok {
@@ -161,6 +162,12 @@ var temporaryErrorCodes = map[ErrorCode]struct{}{
 	TooManyRequestsErrorCode:   {},
 }
 
+var temporaryStatusCodes = map[int]struct{}{
+	http.StatusInternalServerError: {},
+	http.StatusBadGateway:          {},
+	http.StatusServiceUnavailable:  {},
+}
+
 // CheckError returns a structured error if the response status is not in codes.
 func CheckError(resp *http.Response, codes ...int) error {
 	for _, code := range codes {


Test patch:
diff --git a/pkg/v1/remote/transport/error_test.go b/pkg/v1/remote/transport/error_test.go
index a7ff77e5..19d0beef 100644
--- a/pkg/v1/remote/transport/error_test.go
+++ b/pkg/v1/remote/transport/error_test.go
@@ -57,6 +57,11 @@ func TestTemporary(t *testing.T) {
 			}},
 		},
 		retry: true,
+	}, {
+		error: &Error{
+			StatusCode: http.StatusInternalServerError,
+		},
+		retry: true,
 	}}
 
 	for _, test := range tests {