fix: strip G suffix from DISK_SIZE in post_update_to_api for VMs

VMs set DISK_SIZE=32G (with G suffix), but post_update_to_api used
\ directly in JSON, producing 'disk_size: 32G' which is
invalid JSON. The server rejected these with 'invalid character G'.

Now strips the G suffix and validates numeric-only before embedding.
This commit is contained in:
CanbiZ (MickLesk)
2026-03-02 15:58:34 +01:00
parent 46d25645c2
commit cd38bc3a65

View File

@@ -946,6 +946,11 @@ post_update_to_api() {
local http_code="" local http_code=""
# Strip 'G' suffix from disk size (VMs set DISK_SIZE=32G)
local DISK_SIZE_API="${DISK_SIZE:-0}"
DISK_SIZE_API="${DISK_SIZE_API%G}"
[[ ! "$DISK_SIZE_API" =~ ^[0-9]+$ ]] && DISK_SIZE_API=0
# ── Attempt 1: Full payload with complete error text (includes full log) ── # ── Attempt 1: Full payload with complete error text (includes full log) ──
local JSON_PAYLOAD local JSON_PAYLOAD
JSON_PAYLOAD=$( JSON_PAYLOAD=$(
@@ -957,7 +962,7 @@ post_update_to_api() {
"nsapp": "${NSAPP:-unknown}", "nsapp": "${NSAPP:-unknown}",
"status": "${pb_status}", "status": "${pb_status}",
"ct_type": ${CT_TYPE:-1}, "ct_type": ${CT_TYPE:-1},
"disk_size": ${DISK_SIZE:-0}, "disk_size": ${DISK_SIZE_API},
"core_count": ${CORE_COUNT:-0}, "core_count": ${CORE_COUNT:-0},
"ram_size": ${RAM_SIZE:-0}, "ram_size": ${RAM_SIZE:-0},
"os_type": "${var_os:-}", "os_type": "${var_os:-}",
@@ -1000,7 +1005,7 @@ EOF
"nsapp": "${NSAPP:-unknown}", "nsapp": "${NSAPP:-unknown}",
"status": "${pb_status}", "status": "${pb_status}",
"ct_type": ${CT_TYPE:-1}, "ct_type": ${CT_TYPE:-1},
"disk_size": ${DISK_SIZE:-0}, "disk_size": ${DISK_SIZE_API},
"core_count": ${CORE_COUNT:-0}, "core_count": ${CORE_COUNT:-0},
"ram_size": ${RAM_SIZE:-0}, "ram_size": ${RAM_SIZE:-0},
"os_type": "${var_os:-}", "os_type": "${var_os:-}",