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

  1. Correct the <real> text to a plain Go-parsable float, e.g. <real>3.14</real> (dot decimal separator, no units)
  2. Check the strconv error inside %w — it says exactly which syntax/syntax-range failed (ErrSyntax vs ErrRange)
  3. Pre-validate with strconv.ParseFloat(strings.TrimSpace(txt), 64) before unmarshalling and report the raw text
  4. 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

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


AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01). Data as JSON: /api/errors/9474a4f070311a76. Report an issue: GitHub.