lima-vm/lima · error

invalid integer value: %w

Error message

invalid integer value: %w

What it means

<integer> elements are parsed with strconv.ParseInt(text, 10, 64). If the trimmed text is not a valid base-10 int64, Value.UnmarshalXML (pkg/plist/plist.go:143) returns "invalid integer value: %w" wrapping the strconv error (syntax or range).

Source

Thrown at pkg/plist/plist.go:143

	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)
	}
}

func (a *Array) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error {
	var vals []Value
	for {
		tok, err := dec.Token()
		if err != nil {
			if errors.Is(err, io.EOF) {
				*a = vals
				return nil
			}

View on GitHub (pinned to dd909d0973)

Solutions

  1. Make the <integer> text a plain base-10 integer within int64 range, e.g. <integer>42</integer>
  2. Inspect the wrapped strconv error: strconv.ErrSyntax means bad characters, ErrRange means the number exceeds int64
  3. Move fractional values to <real> and oversized/hex values to <string> with manual handling
  4. Pre-validate with strconv.ParseInt(strings.TrimSpace(txt), 10, 64) before unmarshalling

Example fix

// before (fails)
<integer>0x1F</integer>
// after
<integer>31</integer>
Defensive patterns

Strategy: validation

Validate before calling

func validPlistInteger(txt string) error {
	_, err := strconv.ParseInt(strings.TrimSpace(txt), 10, 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 integer value") {
		switch ne.Err {
		case strconv.ErrRange: // exceeds int64: use big.Int on the raw string
		case strconv.ErrSyntax: // non-numeric text
		}
	}
	return err
}

Prevention

When it happens

Trigger: Decoding a plist whose <integer> element holds non-numeric text, a hex value like 0x1F (no 0x support here), a value exceeding int64 range, a fractional number, or an empty element.

Common situations: Values larger than 9.2e18 (e.g. file sizes or timestamps in nanoseconds overflowing), hex literals copied from other tools, negative numbers written as (123) style, decimals like 1.5 placed in <integer> instead of <real>.

Related errors


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