From 2d7e707a00332697f5f5ee475ab92f5cac1e90c6 Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Mon, 16 Feb 2026 18:35:33 +0100 Subject: [PATCH] fix(build): preserve exit code in ERR trap to prevent false exit_code=0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ERR trap called ensure_log_on_host before post_update_to_api, which reset \True to 0 (success). This caused ~15-20 records/day to be reported as 'failed' with exit_code=0 instead of the actual error code. Root cause chain: 1. Command fails with exit code N → ERR trap fires (\True = N) 2. ensure_log_on_host succeeds → \True becomes 0 3. post_update_to_api 'failed' '\True' → sends 'failed/0' (wrong!) 4. POST_UPDATE_DONE=true → EXIT trap skips the correct code Fix: capture \True into _ERR_CODE before ensure_log_on_host runs. --- misc/build.func | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/build.func b/misc/build.func index 123000f4c..98c89e78d 100644 --- a/misc/build.func +++ b/misc/build.func @@ -5570,7 +5570,7 @@ api_exit_script() { if command -v pveversion >/dev/null 2>&1; then trap 'api_exit_script' EXIT fi -trap 'ensure_log_on_host; post_update_to_api "failed" "$?"' ERR +trap '_ERR_CODE=$?; ensure_log_on_host; post_update_to_api "failed" "$_ERR_CODE"' ERR trap 'ensure_log_on_host; post_update_to_api "failed" "129"; exit 129' SIGHUP trap 'ensure_log_on_host; post_update_to_api "failed" "130"; exit 130' SIGINT trap 'ensure_log_on_host; post_update_to_api "failed" "143"; exit 143' SIGTERM