{"record":{"id":"9474a4f070311a76","repo":"lima-vm/lima","slug":"invalid-real-value-w","errorCode":null,"errorMessage":"invalid real value: %w","messagePattern":"invalid real value: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/plist/plist.go","lineNumber":132,"sourceCode":"\t\treturn nil\n\tcase \"true\":\n\t\tb := true\n\t\tv.Boolean = &b\n\t\t// consume tokens until matching end element\n\t\treturn dec.Skip()\n\tcase \"false\":\n\t\tb := false\n\t\tv.Boolean = &b\n\t\t// consume tokens until matching end element\n\t\treturn dec.Skip()\n\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}","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/plist/plist.go#L114-L150","documentation":"<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.","triggerScenarios":"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.","commonSituations":"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.","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>"],"exampleFix":"// before (fails)\n<real>3,14</real>\n// after\n<real>3.14</real>","handlingStrategy":"validation","validationCode":"func validPlistReal(txt string) error {\n\t_, err := strconv.ParseFloat(strings.TrimSpace(txt), 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 real value\") {\n\t\t// inspect ne.Err (ErrSyntax/ErrRange) and the bad text\n\t}\n\treturn err\n}","preventionTips":["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"],"tags":["plist","float","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"}