mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-05-15 13:04:56 +02:00
refactor(api): eliminate duplicate traps, harden error handling & telemetry
Phase 1 - Structural: - Remove api_exit_script() and 5 inline traps from build.func - error_handler.func is now the sole trap owner via catch_errors() - Update api.func comment reference (api_exit_script -> on_exit) Phase 2 - Quality: - Add stop_spinner() + cursor restore to error_handler(), on_interrupt(), on_terminate(), on_hangup() to prevent spinner/cursor artifacts - Enhance _send_abort_telemetry() with error text (last 20 log lines), duration calculation, and 2 retry attempts (was fire-and-forget) - Harden json_escape() to also strip DEL (0x7F) character
This commit is contained in:
@@ -312,7 +312,8 @@ json_escape() {
|
||||
s=${s//$'\r'/}
|
||||
s=${s//$'\t'/\\t}
|
||||
# Remove any remaining control characters (0x00-0x1F except those already handled)
|
||||
s=$(printf '%s' "$s" | tr -d '\000-\010\013\014\016-\037')
|
||||
# Also remove DEL (0x7F) and invalid high bytes that break JSON parsers
|
||||
s=$(printf '%s' "$s" | tr -d '\000-\010\013\014\016-\037\177')
|
||||
printf '%s' "$s"
|
||||
}
|
||||
|
||||
@@ -982,7 +983,7 @@ EOF
|
||||
fi
|
||||
|
||||
# All 3 attempts failed — do NOT set POST_UPDATE_DONE=true.
|
||||
# This allows the EXIT trap (api_exit_script) to retry with 3 fresh attempts.
|
||||
# This allows the EXIT trap (on_exit in error_handler.func) to retry.
|
||||
# No infinite loop risk: EXIT trap fires exactly once.
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user