Skip to content

[Bug]: resource.MustParse panics on invalid user input in vm.go #97

Description

@mrhillsman

Bug Description

internal/vm/vm.go uses resource.MustParse() in two places (lines 125 and 170) to parse user-supplied memory and disk-size strings. MustParse panics instead of returning an error when the input is malformed. A CLI tool should never panic on bad user input — it should return a clear error message.

Steps to Reproduce

  1. Run virtwork run --workloads cpu --memory "not-a-quantity"
  2. Observe a panic/stack trace instead of a user-friendly error

Expected Behavior

virtwork prints a clear error message like invalid memory value "not-a-quantity": ... and exits with a non-zero status code.

Actual Behavior

The process panics with an unrecoverable stack trace from resource.MustParse.

Affected Code

  • internal/vm/vm.go:125resource.MustParse(opts.Memory)
  • internal/vm/vm.go:170resource.MustParse(size) for data disk

Command

  • virtwork run

Workload Type

  • Not applicable (affects all workloads)

Proposed Fix

Replace resource.MustParse() with resource.ParseQuantity() which returns (Quantity, error). Propagate the error up through BuildVM / buildDataVolume to the caller.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.size/SDenotes a PR that changes 10-29 lines, ignoring generated files.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions