Log more clues for export operations (#5068)
<!-- PR description--> --- #### Does this PR need a docs update or release note? - [ ] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [x] ⛔ No #### Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [x] 🤖 Supportability/Tests - [ ] 💻 CI/Deployment - [ ] 🧹 Tech Debt/Cleanup #### Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * #<issue> #### Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [ ] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
89a6a76630
commit
6d2d9c0099
@ -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 {
|
||||
|
||||
@ -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{}
|
||||
|
||||
@ -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{
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user