diff --git a/core/core.func b/core/core.func index 4f71369..5be2adc 100644 --- a/core/core.func +++ b/core/core.func @@ -928,6 +928,8 @@ log_section() { # - Temporarily disables error trap to capture exit code correctly # ------------------------------------------------------------------------------ silent() { + # A failure the caller handled (a retry loop) must not be reported for a later, unrelated error. + unset _SILENT_FAILED_RC _SILENT_FAILED_CMD _SILENT_FAILED_LINE _SILENT_FAILED_LOG local cmd="$*" local caller_line="${BASH_LINENO[0]:-unknown}" local logfile="$(get_active_logfile)" diff --git a/lib/forge.func b/lib/forge.func index 0f36081..dfe1659 100644 --- a/lib/forge.func +++ b/lib/forge.func @@ -1473,7 +1473,7 @@ _forge_release_json() { fi local -a timeouts=(60 120 240) - local raw attempt=1 delay=2 code ok=false + local raw attempt=1 delay=2 code ok=false curl_rc raw="$(mktemp /tmp/tools-forge-rel-XXXXXX)" || return 73 local -a headers=() @@ -1485,13 +1485,18 @@ _forge_release_json() { [[ -n "$auth" ]] && headers+=(-H "$auth") while ((attempt <= ${#timeouts[@]})); do + curl_rc=0 code="$(curl -sSL -w "%{http_code}" -o "$raw" \ --max-time "${timeouts[$((attempt - 1))]}" \ - "${headers[@]}" "$api_url" 2>/dev/null)" || true + "${headers[@]}" "$api_url" 2>/dev/null)" || curl_rc=$? if [[ "$code" == "200" ]]; then - ok=true - break + # A body cut short still reports 200, and jq then finds no release at all. + if ((curl_rc == 0)) && jq -e 'type == "array" or type == "object"' "$raw" >/dev/null 2>&1; then + ok=true + break + fi + code="000" fi if [[ "$forge" == "github" && "$code" == "401" ]]; then