{"record":{"id":"1e99f5ba63dfa1e6","repo":"lima-vm/lima","slug":"invalid-date-value-w","errorCode":null,"errorMessage":"invalid date value: %w","messagePattern":"invalid date value: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/plist/plist.go","lineNumber":111,"sourceCode":"\t\tif err := dec.DecodeElement(&txt, &start); err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// remove all whitespace/newlines from base64 text\n\t\tb64 := strings.Join(strings.Fields(txt), \"\")\n\t\tdb, err := base64.StdEncoding.DecodeString(b64)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid base64 data: %w\", err)\n\t\t}\n\t\tv.Data = db\n\t\treturn nil\n\tcase \"date\":\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\tt, err := time.Parse(time.RFC3339, strings.TrimSpace(txt))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid date value: %w\", err)\n\t\t}\n\t\tv.Date = &t\n\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}","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/plist/plist.go#L93-L129","documentation":"The plist parser decodes <date> elements with Go's time.Parse(time.RFC3339, ...). If the element's text content is not a valid RFC3339 timestamp, UnmarshalXML (pkg/plist/plist.go:111) wraps the parse error as \"invalid date value: %w\". This surfaces from any xml.Unmarshal / DecodeElement call that decodes a plist Value containing a malformed <date>.","triggerScenarios":"xml.Unmarshal (or xml.NewDecoder.DecodeElement) on a plist document whose <date> element text does not parse as RFC3339, e.g. plist macOS-style dates like \"2026-09-01 12:00:00 +0000\" (space separator, no T), missing timezone, or \"Fri Sep  1 12:00:00 2026\".","commonSituations":"Hand-edited or tool-generated plists copied from macOS `defaults export` output, which uses a different date format than RFC3339; timestamps with a space instead of 'T'; dates missing the mandatory timezone offset; template files with placeholder dates.","solutions":["Convert the <date> text to RFC3339 before parsing, e.g. replace the space with 'T' and ensure a timezone offset like '+0000' or 'Z' is present","Pre-validate the date text with time.Parse(time.RFC3339, strings.TrimSpace(txt)) in your own code and emit a clearer error with the offending value","Fix the source plist so it uses RFC3339, e.g. <date>2026-09-01T12:00:00Z</date>","If you control the parser, parse plist dates with a dedicated layout (\"2006-01-02 15:04:05 -0700\") as a fallback before failing"],"exampleFix":"// before (fails)\n<date>2026-09-01 12:00:00 +0000</date>\n// after (RFC3339)\n<date>2026-09-01T12:00:00Z</date>","handlingStrategy":"validation","validationCode":"func validPlistDate(txt string) error {\n\t_, err := time.Parse(time.RFC3339, strings.TrimSpace(txt))\n\treturn err\n}","typeGuard":null,"tryCatchPattern":"var v plist.Value\nif err := xml.Unmarshal(data, &v); err != nil {\n\tvar perr *time.ParseError\n\tif errors.As(err, &perr) && strings.Contains(err.Error(), \"invalid date value\") {\n\t\t// handle malformed <date>: normalize to RFC3339 or skip\n\t}\n\treturn err\n}","preventionTips":["Normalize plist dates to RFC3339 (T separator, Z or ±hh:mm) at document creation time","Run plutil -lint or a schema check on plist inputs before parsing","Never paste macOS `defaults` date output directly; convert the format first","Unit-test the parser with edge-case dates (no timezone, space separator)"],"tags":["plist","date","parsing","rfc3339"],"backgroundTag":"invalid-date-format","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}