Skip to content

fix(instances): accept decimals and improve SetInstanceResources error handling - #57

Merged
laolusrael merged 3 commits into
developfrom
fix/set-instance-resources
Apr 23, 2026
Merged

fix(instances): accept decimals and improve SetInstanceResources error handling#57
laolusrael merged 3 commits into
developfrom
fix/set-instance-resources

Conversation

@laolusrael

Copy link
Copy Markdown
Owner

Summary

Fixes PUT /api/instances/{name}/resources failing with generic errors and rejecting valid decimal memory/disk values.

Changes

  1. Accept decimal values in memory/disk strings

    • parseMemoryString now uses strconv.ParseFloat instead of strconv.ParseInt
    • Allows values like "4.0G", "25.0G", "2.5G" that multipass accepts
  2. Capture stderr from multipass commands

    • SetInstanceResources now uses cmd.CombinedOutput() instead of cmd.Output()
    • Returns actual multipass error messages (e.g., "setting must be a positive integer") instead of generic "exit status 1"
  3. Skip unchanged values

    • Only calls multipass set for values that actually changed
    • Prevents unnecessary errors when partial updates are sent

Test Results

  • go test -tags ci ./... -- Pass
  • gofmt -d . -- Clean

Fixes

  • Resolves {"error":"invalid_request","message":"invalid memory format"} for "4.0G"
  • Resolves {"error":"multipass_error","message":"failed to set CPU: exit status 1"} by surfacing real errors

@laolusrael
laolusrael merged commit 97b61fb into develop Apr 23, 2026
5 checks passed
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.

1 participant