Skip to content

fix(instances): a new VM's vCPUs, memory and disk size are at least 1 - #179

Merged
catborise merged 1 commit into
masterfrom
create-form-minimums
Oct 24, 2026
Merged

catborise merged 1 commit into
masterfrom
create-form-minimums

Conversation

@catborise

Copy link
Copy Markdown
Owner

Closes #175.

The create form and the API accepted 0 or a negative number for vCPUs, memory and a new disk's size:

  • The API queued the job (202), which then failed later in libvirt. The test reproduced the 202 before the fix.
  • The page did the same. It posts with formnovalidate, so the browser's min=1 was skipped.

The fix

  • The CreateInstance model's vcpu, memory and hdd_size fields refuse values below 1 (MinValueValidator(1)). Both the form and the API serializer are built on this model, so both check it. No migration is needed (makemigrations --check is clean).
  • NewVMForm checks the MAC addresses with nic_macs, as the API and the job already do. A bad MAC is now an error on the form instead of a job that fails.

Verification

  • New tests, red before the fix and green after it:
    • the page shows each size error beside its field and queues nothing;
    • a bad MAC is a form error;
    • the API answers 400 naming the field and queues nothing.
  • The full suite passes on SQLite and on PostgreSQL 16: 1391 tests each, OK (32 skipped).

🤖 Generated with Claude Code

The create form and the API took 0 or a negative number for vCPUs,
memory and a new disk's size: the API queued the job (202) and it
failed later in libvirt; the page did the same, its formnovalidate
skipping the browser's min. The create model's fields now refuse
values below 1, so the form shows the error beside its field and the
API answers 400 naming it.

The form also checks the MAC addresses as the API and the job do (one
per NIC at most, each a MAC address), so a bad one is an error on the
form instead of a job that fails.

Closes #175
@catborise
catborise merged commit 9994803 into master Oct 24, 2026
18 checks passed
@catborise
catborise deleted the create-form-minimums branch October 24, 2026 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The create form accepts zero or negative vCPUs and memory

1 participant