From dbff5db95a8957778e9ec74e39e91bd6a92ff738 Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Mon, 23 Feb 2026 14:15:42 +0100 Subject: [PATCH] Include full log in error telemetry Use get_full_log (up to 120KB) to populate the error telemetry field so the API receives the full installation trace; fall back to get_error_text (last ~20 lines) if the full log is empty. Removed collection and inclusion of a separate install_log field from the JSON payloads and simplified the retry payloads/comments accordingly. The change ensures error reports contain the complete trace while avoiding duplicate large log fields and keeps graceful failure handling (get_full_log || true). --- misc/api.func | 40 ++++++++++++++-------------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/misc/api.func b/misc/api.func index 5776c750e..7944dc4d9 100644 --- a/misc/api.func +++ b/misc/api.func @@ -357,7 +357,7 @@ get_error_text() { # - Calls ensure_log_on_host() to pull container log if needed # - Strips ANSI escape codes and carriage returns # - Truncates to max_bytes (default: 120KB) to stay within API limits -# - Used for the install_log telemetry field +# - Used for the error telemetry field (full trace instead of 20 lines) # ------------------------------------------------------------------------------ get_full_log() { local max_bytes="${1:-122880}" # 120KB default @@ -830,11 +830,15 @@ post_update_to_api() { else exit_code=1 fi - # Get log lines and build structured error string - local error_text="" - error_text=$(get_error_text) + # Get full installation log for error field + local log_text="" + log_text=$(get_full_log 122880) || true # 120KB max + if [[ -z "$log_text" ]]; then + # Fallback to last 20 lines + log_text=$(get_error_text) + fi local full_error - full_error=$(build_error_string "$exit_code" "$error_text") + full_error=$(build_error_string "$exit_code" "$log_text") error=$(json_escape "$full_error") short_error=$(json_escape "$(explain_exit_code "$exit_code")") error_category=$(categorize_error "$exit_code") @@ -855,16 +859,7 @@ post_update_to_api() { local http_code="" - # Collect full installation log for telemetry (all statuses) - local install_log_raw="" - local install_log_escaped="" - local install_log_short="" - install_log_raw=$(get_full_log 122880) || true # 120KB max - if [[ -n "$install_log_raw" ]]; then - install_log_escaped=$(json_escape "$install_log_raw") - fi - - # ── Attempt 1: Full payload with complete error text + full install log ── + # ── Attempt 1: Full payload with complete error text (includes full log) ── local JSON_PAYLOAD JSON_PAYLOAD=$( cat <