-
Notifications
You must be signed in to change notification settings - Fork 247
Open
Description
Summary
When creating a VM with an invalid brand value (e.g., "smartos"), vmadm crashes with a JavaScript TypeError and core dump instead of providing a helpful validation error message.
Steps to Reproduce
# Create a payload with an invalid brand
cat > test.json <<EOF2
{
"brand": "smartos",
"alias": "test",
"image_uuid": "2f1dc911-6401-4fa4-8e9d-67ea2e39c271",
"max_physical_memory": 512,
"quota": 10
}
EOF2
vmadm create -f test.jsonActual Behavior
Uncaught TypeError: Cannot read property 'features' of undefined
FROM
fixPayloadMemory (/usr/vm/node_modules/VM.js:4626:29)
applyZoneDefaults (/usr/vm/node_modules/VM.js:4908:5)
normalizePayload (/usr/vm/node_modules/VM.js:10005:9)
...
Abort (core dumped)
Expected Behavior
A clear validation error such as:
vmadm create: error: invalid brand "smartos". Valid brands are: joyent, joyent-minimal, lx, kvm, bhyve
Root Cause
In src/vm/node_modules/VM.js:4626, the code accesses BRAND_OPTIONS[brand].features without first checking if BRAND_OPTIONS[brand] exists:
if (BRAND_OPTIONS[brand].features.default_memory_overheadWhen brand is not a valid key in BRAND_OPTIONS, this returns undefined, causing the TypeError.
References
- Original report: https://pastebin.com/wU1cjJMx
- Reported by: mamalacation (Discord)
Metadata
Metadata
Assignees
Labels
No labels