diff --git a/src/internal/converters/eml/eml.go b/src/internal/converters/eml/eml.go index 41e737d2a..f8edeac4b 100644 --- a/src/internal/converters/eml/eml.go +++ b/src/internal/converters/eml/eml.go @@ -52,6 +52,8 @@ func formatAddress(entry models.EmailAddressable) string { // FromJSON converts a Messageable (as json) to .eml format func FromJSON(ctx context.Context, body []byte) (string, error) { + ctx = clues.Add(ctx, "body_len", len(body)) + data, err := api.BytesToMessageable(body) if err != nil { return "", clues.WrapWC(ctx, err, "converting to messageble") @@ -137,7 +139,8 @@ func FromJSON(ctx context.Context, body []byte) (string, error) { bytes, err := attachment.GetBackingStore().Get("contentBytes") if err != nil { - return "", clues.WrapWC(ctx, err, "failed to get attachment bytes") + return "", clues.WrapWC(ctx, err, "failed to get attachment bytes"). + With("kind", kind) } if bytes == nil { @@ -156,14 +159,17 @@ func FromJSON(ctx context.Context, body []byte) (string, error) { bts, ok := bytes.([]byte) if !ok { - return "", clues.WrapWC(ctx, err, "invalid content bytes") + return "", clues.WrapWC(ctx, err, "invalid content bytes"). + With("kind", kind). + With("interface_type", fmt.Sprintf("%T", bytes)) } name := ptr.Val(attachment.GetName()) contentID, err := attachment.GetBackingStore().Get("contentId") if err != nil { - return "", clues.WrapWC(ctx, err, "getting content id for attachment") + return "", clues.WrapWC(ctx, err, "getting content id for attachment"). + With("kind", kind) } if contentID != nil { diff --git a/src/internal/converters/ics/ics.go b/src/internal/converters/ics/ics.go index 7c1d1a760..a9d13d6bb 100644 --- a/src/internal/converters/ics/ics.go +++ b/src/internal/converters/ics/ics.go @@ -77,17 +77,18 @@ func getUTCTime(ts, tz string) (time.Time, error) { // timezone everywhere according to the spec. it, err := dttm.ParseTime(ts) if err != nil { - return time.Now(), clues.Wrap(err, "parsing time") + return time.Time{}, clues.Wrap(err, "parsing time").With("given_time_string", ts) } timezone, ok := GraphTimeZoneToTZ[tz] if !ok { - return it, clues.New("unknown timezone") + return it, clues.New("unknown timezone").With("timezone", tz) } loc, err := time.LoadLocation(timezone) if err != nil { - return time.Now(), clues.Wrap(err, "loading timezone") + return time.Time{}, clues.Wrap(err, "loading timezone"). + With("converted_timezone", timezone) } // embed timezone @@ -170,7 +171,7 @@ func getRecurrencePattern( if end != nil { parsedTime, err := dttm.ParseTime(end.String()) if err != nil { - return "", clues.Wrap(err, "parsing recurrence end date") + return "", clues.Wrap(err, "parsing recurrence end date").With("recur_end_date", end.String()) } // end date is always computed as end of the day and @@ -203,7 +204,8 @@ func getRecurrencePattern( func FromJSON(ctx context.Context, body []byte) (string, error) { event, err := api.BytesToEventable(body) if err != nil { - return "", clues.WrapWC(ctx, err, "converting to eventable") + return "", clues.WrapWC(ctx, err, "converting to eventable"). + With("body_len", len(body)) } cal := ics.NewCalendar() @@ -231,7 +233,8 @@ func FromJSON(ctx context.Context, body []byte) (string, error) { exBody, err := json.Marshal(instance) if err != nil { - return "", clues.WrapWC(ctx, err, "marshalling exception instance") + return "", clues.WrapWC(ctx, err, "marshalling exception instance"). + With("instance_id", instance["id"]) } exception, err := api.BytesToEventable(exBody) @@ -363,7 +366,8 @@ func updateEventProperties(ctx context.Context, event models.Eventable, iCalEven } else { stripped, err := html2text.FromString(description, html2text.Options{PrettyTables: true}) if err != nil { - return clues.Wrap(err, "converting html to text") + return clues.Wrap(err, "converting html to text"). + With("description_length", len(description)) } iCalEvent.SetDescription(stripped) @@ -534,7 +538,8 @@ func updateEventProperties(ctx context.Context, event models.Eventable, iCalEven content, ok := cb.([]uint8) if !ok { - return clues.NewWC(ctx, "getting attachment content string") + return clues.NewWC(ctx, "getting attachment content string"). + With("interface_type", fmt.Sprintf("%T", cb)) } props = append(props, ics.WithEncoding("base64"), ics.WithValue("BINARY")) @@ -553,7 +558,8 @@ func updateEventProperties(ctx context.Context, event models.Eventable, iCalEven cid, err := str.AnyToString(cidv) if err != nil { - return clues.WrapWC(ctx, err, "getting attachment content id string") + return clues.WrapWC(ctx, err, "getting attachment content id string"). + With("interface_type", fmt.Sprintf("%T", cidv)) } props = append(props, keyValues("CID", cid)) @@ -565,7 +571,8 @@ func updateEventProperties(ctx context.Context, event models.Eventable, iCalEven // EXDATE - https://www.rfc-editor.org/rfc/rfc5545#section-3.8.5.1 cancelledDates, err := getCancelledDates(ctx, event) if err != nil { - return clues.Wrap(err, "getting cancelled dates") + return clues.Wrap(err, "getting cancelled dates"). + With("event_id", event.GetId()) } dateStrings := []string{} diff --git a/src/internal/converters/vcf/vcf.go b/src/internal/converters/vcf/vcf.go index aa0785cf9..0a6a44b2a 100644 --- a/src/internal/converters/vcf/vcf.go +++ b/src/internal/converters/vcf/vcf.go @@ -86,7 +86,8 @@ func FromJSON(ctx context.Context, body []byte) (string, error) { data, err := api.BytesToContactable(body) if err != nil { - return "", clues.Wrap(err, "converting to contactable") + return "", clues.Wrap(err, "converting to contactable"). + With("body_length", len(body)) } name := vcard.Name{ diff --git a/src/pkg/services/m365/api/events.go b/src/pkg/services/m365/api/events.go index 8f36051f5..6f197e93c 100644 --- a/src/pkg/services/m365/api/events.go +++ b/src/pkg/services/m365/api/events.go @@ -338,7 +338,9 @@ func GetCancelledEventDateStrings(event models.Eventable) ([]string, error) { _, err = dttm.ParseTime(startStr) if err != nil { - return nil, clues.Wrap(err, "parsing cancelled event date") + return nil, clues.Wrap(err, "parsing cancelled event date"). + With("instance", instance). + With("start_string", startStr) } dates = append(dates, startStr)