Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

Fix Set PATCH request

f-trycuaf0016d3e24e6
diff --git a/libs/lume/src/Utils/Utils.swift b/libs/lume/src/Utils/Utils.swift
index a04e3b0c0d..96f512bdc7 100644
--- a/libs/lume/src/Utils/Utils.swift
+++ b/libs/lume/src/Utils/Utils.swift
@@ -27,7 +27,7 @@ func resolveBinaryPath(_ name: String) -> URL? {
// Helper function to parse size strings
func parseSize(_ input: String) throws -> UInt64 {
let lowercased = input.trimmingCharacters(in: .whitespacesAndNewlines).lowercased()
- let multiplier: UInt64
+ let multiplier: Double
let valueString: String
if lowercased.hasSuffix("tb") {
@@ -43,15 +43,21 @@ func parseSize(_ input: String) throws -> UInt64 {
multiplier = 1024
valueString = String(lowercased.dropLast(2))
} else {
- multiplier = 1024 * 1024 // Default to MB
+ multiplier = 1024 * 1024
valueString = lowercased
}
- guard let value = UInt64(valueString.trimmingCharacters(in: .whitespacesAndNewlines)) else {
- throw ValidationError("Malformed size input: \(input)") // Throw ad-hoc error for invalid input
+ guard let value = Double(valueString.trimmingCharacters(in: .whitespacesAndNewlines)) else {
+ throw ValidationError("Malformed size input: \(input). Could not parse numeric value.")
+ }
+
+ let bytesAsDouble = (value * multiplier).rounded()
+
+ guard bytesAsDouble >= 0 && bytesAsDouble <= Double(UInt64.max) else {
+ throw ValidationError("Calculated size out of bounds for UInt64: \(input)")
}
- let val = value * multiplier
+ let val = UInt64(bytesAsDouble)
return val
}