diff --git a/misc/api.func b/misc/api.func index fe01924c8..55a4d6889 100644 --- a/misc/api.func +++ b/misc/api.func @@ -323,15 +323,30 @@ EOF # - Never blocks or fails script execution # ------------------------------------------------------------------------------ post_update_to_api() { + # DEBUG: Show function entry + echo "[DEBUG] post_update_to_api() called with status=$1 exit_code=$2" >&2 + # Silent fail - telemetry should never break scripts - command -v curl &>/dev/null || return 0 + command -v curl &>/dev/null || { + echo "[DEBUG] curl not found, skipping" >&2 + return 0 + } # Prevent duplicate submissions POST_UPDATE_DONE=${POST_UPDATE_DONE:-false} - [[ "$POST_UPDATE_DONE" == "true" ]] && return 0 + [[ "$POST_UPDATE_DONE" == "true" ]] && { + echo "[DEBUG] Already sent update, skipping" >&2 + return 0 + } - [[ "${DIAGNOSTICS:-no}" == "no" ]] && return 0 - [[ -z "${RANDOM_UUID:-}" ]] && return 0 + [[ "${DIAGNOSTICS:-no}" == "no" ]] && { + echo "[DEBUG] DIAGNOSTICS=no, skipping" >&2 + return 0 + } + [[ -z "${RANDOM_UUID:-}" ]] && { + echo "[DEBUG] RANDOM_UUID empty, skipping" >&2 + return 0 + } local status="${1:-failed}" local raw_exit_code="${2:-1}" @@ -377,10 +392,16 @@ post_update_to_api() { EOF ) + echo "[DEBUG] Sending update to: $TELEMETRY_URL" >&2 + echo "[DEBUG] Update payload: $JSON_PAYLOAD" >&2 + # Fire-and-forget: never block, never fail - curl -fsS -m "${TELEMETRY_TIMEOUT}" -X POST "${TELEMETRY_URL}" \ + local http_code + http_code=$(curl -sS -w "%{http_code}" -m "${TELEMETRY_TIMEOUT}" -X POST "${TELEMETRY_URL}" \ -H "Content-Type: application/json" \ - -d "$JSON_PAYLOAD" &>/dev/null || true + -d "$JSON_PAYLOAD" -o /dev/stderr 2>&1) || true + + echo "[DEBUG] HTTP response code: $http_code" >&2 POST_UPDATE_DONE=true } diff --git a/misc/build.func b/misc/build.func index c719e1fdb..6649b7e3d 100644 --- a/misc/build.func +++ b/misc/build.func @@ -1882,7 +1882,7 @@ advanced_settings() { fi ;; - # ══════════════���════════════════════════════════════════════════════════════ + # ══════════════����════════════════════════════════════════════════════════════ # STEP 3: Container ID # ═══════════════════════════════════════════════════════════════════════════ 3) @@ -4014,6 +4014,9 @@ EOF' if [[ $install_exit_code -ne 0 ]]; then msg_error "Installation failed in container ${CTID} (exit code: ${install_exit_code})" + # Report failure to telemetry API + post_update_to_api "failed" "$install_exit_code" + # Copy both logs from container before potential deletion local build_log_copied=false local install_log_copied=false