Skip to content

fix(vm): replace resource.MustParse with ParseQuantity to prevent panics#98

Merged
mrhillsman merged 4 commits into
mainfrom
fix/must-parse-panic
May 28, 2026
Merged

fix(vm): replace resource.MustParse with ParseQuantity to prevent panics#98
mrhillsman merged 4 commits into
mainfrom
fix/must-parse-panic

Conversation

@mrhillsman

Copy link
Copy Markdown
Contributor

Summary

resource.MustParse() panics on invalid input

internal/vm/vm.go resource.MustParse(opts.Memory) will panic (not error) if a user passes an invalid memory string like 2G instead of 2Gi

A CLI tool should never panic on bad user input

Resolves #97

MustParse panics on invalid input, which crashes the process when users
provide malformed memory or disk-size values. Use ParseQuantity and
propagate errors to callers instead.

Resolves #97

Signed-off-by: Melvin Hillsman <mhillsma@redhat.com>
…Templates

Update all callers of BuildVMSpec and DataVolumeTemplates to handle the
(value, error) return pattern introduced in dfd2617. This includes
production code (cmd/virtwork/main.go, workload implementations),
unit tests, and integration tests.

Signed-off-by: Melvin Hillsman <mhillsma@redhat.com>
Replace terse "parsing memory" / "parsing disk size" prefixes with
messages that show valid examples (e.g. 512Mi, 2Gi), so users don't
have to decipher the Kubernetes quantity regex.

Signed-off-by: Melvin Hillsman <mhillsma@redhat.com>
Signed-off-by: Melvin Hillsman <mhillsma@redhat.com>
@exe-prow-github-app
exe-prow-github-app Bot requested a review from OchiengEd May 28, 2026 05:14
@exe-prow-github-app

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mrhillsman

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@exe-prow-github-app exe-prow-github-app Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 28, 2026
@mrhillsman
mrhillsman merged commit a464901 into main May 28, 2026
3 of 4 checks passed
@mrhillsman
mrhillsman deleted the fix/must-parse-panic branch May 28, 2026 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant