{"record":{"id":"66ab126e7af2f61d","repo":"lima-vm/lima","slug":"invalid-integer-value-w","errorCode":null,"errorMessage":"invalid integer value: %w","messagePattern":"invalid integer value: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/plist/plist.go","lineNumber":143,"sourceCode":"\tcase \"real\":\n\t\tvar txt string\n\t\tif err := dec.DecodeElement(&txt, &start); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tf, err := strconv.ParseFloat(strings.TrimSpace(txt), 64)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid real value: %w\", err)\n\t\t}\n\t\tv.Real = &f\n\t\treturn nil\n\tcase \"integer\":\n\t\tvar txt string\n\t\tif err := dec.DecodeElement(&txt, &start); err != nil {\n\t\t\treturn err\n\t\t}\n\t\ti, err := strconv.ParseInt(strings.TrimSpace(txt), 10, 64)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid integer value: %w\", err)\n\t\t}\n\t\tv.Integer = &i\n\t\treturn nil\n\n\tdefault:\n\t\treturn fmt.Errorf(\"unsupported plist type: %s\", start.Name.Local)\n\t}\n}\n\nfunc (a *Array) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error {\n\tvar vals []Value\n\tfor {\n\t\ttok, err := dec.Token()\n\t\tif err != nil {\n\t\t\tif errors.Is(err, io.EOF) {\n\t\t\t\t*a = vals\n\t\t\t\treturn nil\n\t\t\t}","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/plist/plist.go#L125-L161","documentation":"<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).","triggerScenarios":"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.","commonSituations":"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>.","solutions":["Make the <integer> text a plain base-10 integer within int64 range, e.g. <integer>42</integer>","Inspect the wrapped strconv error: strconv.ErrSyntax means bad characters, ErrRange means the number exceeds int64","Move fractional values to <real> and oversized/hex values to <string> with manual handling","Pre-validate with strconv.ParseInt(strings.TrimSpace(txt), 10, 64) before unmarshalling"],"exampleFix":"// before (fails)\n<integer>0x1F</integer>\n// after\n<integer>31</integer>","handlingStrategy":"validation","validationCode":"func validPlistInteger(txt string) error {\n\t_, err := strconv.ParseInt(strings.TrimSpace(txt), 10, 64)\n\treturn err\n}","typeGuard":null,"tryCatchPattern":"var v plist.Value\nif err := xml.Unmarshal(data, &v); err != nil {\n\tvar ne *strconv.NumError\n\tif errors.As(err, &ne) && strings.Contains(err.Error(), \"invalid integer value\") {\n\t\tswitch ne.Err {\n\t\tcase strconv.ErrRange: // exceeds int64: use big.Int on the raw string\n\t\tcase strconv.ErrSyntax: // non-numeric text\n\t\t}\n\t}\n\treturn err\n}","preventionTips":["Write integers as plain base-10 decimal; no 0x prefixes or underscores","Keep values within int64 range (-9223372036854775808..9223372036854775807); store larger as string","Use <real> for fractional values instead of <integer>","Validate generated plists with plutil -lint before parsing"],"tags":["plist","integer","parsing","strconv"],"backgroundTag":"invalid-numeric-format","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}