Skip to content

fix(instances): accept decimal values in memory and disk strings - #56

Merged
laolusrael merged 1 commit into
developfrom
fix/parse-memory-float
Apr 23, 2026
Merged

fix(instances): accept decimal values in memory and disk strings#56
laolusrael merged 1 commit into
developfrom
fix/parse-memory-float

Conversation

@laolusrael

Copy link
Copy Markdown
Owner

Summary

Fixes PUT /api/instances/{name}/resources rejecting valid decimal memory/disk values like "4.0G" and "25.0G".

Problem

parseMemoryString used strconv.ParseInt, which fails on strings containing decimal points (e.g., "4.0"). When the frontend sent "memory": "4.0G", the endpoint returned:

{"error":"invalid_request","message":"invalid memory format"}

Fix

  • Changed strconv.ParseInt to strconv.ParseFloat in parseMemoryString
  • Result is cast to int64 after multiplying by the unit multiplier

Tests Added

  • TestUpdateResources_DecimalMemoryFormat — verifies "4.0G" is accepted
  • TestParseMemoryString — unit tests for parsing: 1G, 4.0G, 25.0G, 512M, 2.5G, 1024, empty string

Test Results

  • go test -tags ci ./... — Pass

@laolusrael
laolusrael merged commit 03d1457 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