Retry signed requests on transport errors

_send_signed_request tested $? after _CACHED_NONCE="" had reset it, so a
POST that never got an answer (curl 7, 28, 35) returned success with a
stale or empty code, and callers blamed the CA ("Finalize code was not
200"). Keep the _post status and retry with backoff and a new nonce, like
a gateway error. Drop the nonce-fetch $? check, which was dead the same
way.

Fixes #7320
This commit is contained in:
neil committed 2026-10-12 16:58:32 +08:00
1 parent 0e4d75325b
commit 3e6d4835e5
1 file changed
+11 -7
+11 -7
View File
@@ -2738,10 +2738,6 @@ _send_signed_request() {
_debug2 _headers "$_headers"
_CACHED_NONCE="$(echo "$_headers" | grep -i "Replay-Nonce:" | _head_n 1 | tr -d "\r\n " | cut -d ':' -f 2)"
fi
if [ "$?" != "0" ]; then
_err "Cannot connect to $nonceurl to get nonce."
return 1
fi
else
_debug2 "Use _CACHED_NONCE" "$_CACHED_NONCE"
fi
@@ -2780,11 +2776,19 @@ _send_signed_request() {
_debug3 body "$body"
response="$(_post "$body" "$url" "$needbase64" "POST" "$__request_conent_type")"
_post_ret="$?"
_CACHED_NONCE=""
if [ "$?" != "0" ]; then
_err "Cannot make POST request to $url"
return 1
#A transport failure (curl 7, 28, 35, ...) brings no answer at all. Issue
#7320: the status was tested only after the line above had reset it, so
#such a failure went on as a success, the code read from whatever
#$HTTP_HEADER still held, and the caller blamed the CA ("Finalize code was
#not 200"). Retry it the way a gateway error is retried, with a new nonce.
if [ "$_post_ret" != "0" ]; then
_sleep_post_retry_sec="$(_retry_backoff_sec "$_request_retry_times")"
_info "Cannot make POST request to $url, let's try again. Sleeping for $_sleep_post_retry_sec seconds. ($_request_retry_times/$MAX_REQUEST_RETRY_TIMES)"
_sleep "$_sleep_post_retry_sec"
continue
fi
responseHeaders="$(cat "$HTTP_HEADER")"
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.