lima-vm/lima · error
invalid real value: %w
Error message
invalid real value: %w
What it means
<real> elements in a plist must contain a numeric value parseable by strconv.ParseFloat(…, 64). When the text (after trimming whitespace) is not a valid float, Value.UnmarshalXML (pkg/plist/plist.go:132) returns "invalid real value: %w" wrapping the strconv error.
Source
Thrown at pkg/plist/plist.go:132
return nil
case "true":
b := true
v.Boolean = &b
// consume tokens until matching end element
return dec.Skip()
case "false":
b := false
v.Boolean = &b
// consume tokens until matching end element
return dec.Skip()
case "real":
var txt string
if err := dec.DecodeElement(&txt, &start); err != nil {
return err
}
f, err := strconv.ParseFloat(strings.TrimSpace(txt), 64)
if err != nil {
return fmt.Errorf("invalid real value: %w", err)
}
v.Real = &f
return nil
case "integer":
var txt string
if err := dec.DecodeElement(&txt, &start); err != nil {
return err
}
i, err := strconv.ParseInt(strings.TrimSpace(txt), 10, 64)
if err != nil {
return fmt.Errorf("invalid integer value: %w", err)
}
v.Integer = &i
return nil
default:
return fmt.Errorf("unsupported plist type: %s", start.Name.Local)
}View on GitHub (pinned to dd909d0973)
Solutions
- Correct the <real> text to a plain Go-parsable float, e.g. <real>3.14</real> (dot decimal separator, no units)
- Check the strconv error inside %w — it says exactly which syntax/syntax-range failed (ErrSyntax vs ErrRange)
- Pre-validate with strconv.ParseFloat(strings.TrimSpace(txt), 64) before unmarshalling and report the raw text
- If the value is meant to be a string, change the element to <string>…</string>
Example fix
// before (fails) <real>3,14</real> // after <real>3.14</real>
Defensive patterns
Strategy: validation
Validate before calling
func validPlistReal(txt string) error {
_, err := strconv.ParseFloat(strings.TrimSpace(txt), 64)
return err
} Try / catch
var v plist.Value
if err := xml.Unmarshal(data, &v); err != nil {
var ne *strconv.NumError
if errors.As(err, &ne) && strings.Contains(err.Error(), "invalid real value") {
// inspect ne.Err (ErrSyntax/ErrRange) and the bad text
}
return err
} Prevention
- Use dot as decimal separator in <real> elements; never locale-formatted commas
- Do not put units, whitespace symbols, or percent signs inside <real>
- Prefer <integer> for whole numbers to avoid float parsing entirely
- Lint generated plists (plutil -lint) before handing them to the parser
When it happens
Trigger: Decoding a plist whose <real> element contains non-numeric text, a localized decimal separator (e.g. comma "3,14"), an empty element, or a value out of float64 range.
Common situations: Plists edited by hand or generated by scripts that insert strings or numbers with commas as decimal separators; empty <real></real> elements; locale-formatted output pasted into the plist.
Related errors
- invalid integer value: %w
- failed to unmarshal xml: %w
- unexpected plist format: missing root dict
- invalid date value: %w
- failed to unmarshal line %#q: %w
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/9474a4f070311a76.
Report an issue: GitHub.