mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-03-03 16:15:54 +00:00
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:
@@ -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:-}",
|
||||||
|
|||||||
Reference in New Issue
Block a user