Skip to content

Commit cd38bc3

Browse files
committed
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.
1 parent 46d2564 commit cd38bc3

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

misc/api.func

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,11 @@ post_update_to_api() {
946946

947947
local http_code=""
948948

949+
# Strip 'G' suffix from disk size (VMs set DISK_SIZE=32G)
950+
local DISK_SIZE_API="${DISK_SIZE:-0}"
951+
DISK_SIZE_API="${DISK_SIZE_API%G}"
952+
[[ ! "$DISK_SIZE_API" =~ ^[0-9]+$ ]] && DISK_SIZE_API=0
953+
949954
# ── Attempt 1: Full payload with complete error text (includes full log) ──
950955
local JSON_PAYLOAD
951956
JSON_PAYLOAD=$(
@@ -957,7 +962,7 @@ post_update_to_api() {
957962
"nsapp": "${NSAPP:-unknown}",
958963
"status": "${pb_status}",
959964
"ct_type": ${CT_TYPE:-1},
960-
"disk_size": ${DISK_SIZE:-0},
965+
"disk_size": ${DISK_SIZE_API},
961966
"core_count": ${CORE_COUNT:-0},
962967
"ram_size": ${RAM_SIZE:-0},
963968
"os_type": "${var_os:-}",
@@ -1000,7 +1005,7 @@ EOF
10001005
"nsapp": "${NSAPP:-unknown}",
10011006
"status": "${pb_status}",
10021007
"ct_type": ${CT_TYPE:-1},
1003-
"disk_size": ${DISK_SIZE:-0},
1008+
"disk_size": ${DISK_SIZE_API},
10041009
"core_count": ${CORE_COUNT:-0},
10051010
"ram_size": ${RAM_SIZE:-0},
10061011
"os_type": "${var_os:-}",

0 commit comments

Comments
 (0)