From c526ced23eddd29c76018ea377444032acaafe8f Mon Sep 17 00:00:00 2001 From: Abin Simon Date: Thu, 25 Jan 2024 00:20:51 +0530 Subject: [PATCH] Skip attachments without any content for events (#5110) Known issue, tracking in https://github.com/alcionai/corso/issues/4772 --- #### Does this PR need a docs update or release note? - [ ] :white_check_mark: Yes, it's included - [ ] :clock1: Yes, but in a later PR - [x] :no_entry: No #### Type of change - [ ] :sunflower: Feature - [x] :bug: Bugfix - [ ] :world_map: Documentation - [ ] :robot: Supportability/Tests - [ ] :computer: CI/Deployment - [ ] :broom: Tech Debt/Cleanup #### Issue(s) * # #### Test Plan - [ ] :muscle: Manual - [ ] :zap: Unit test - [ ] :green_heart: E2E --- src/internal/converters/eml/eml.go | 11 ++++------- src/internal/converters/ics/ics.go | 13 ++++++++++++- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/internal/converters/eml/eml.go b/src/internal/converters/eml/eml.go index 119730f2e..9b0607a4c 100644 --- a/src/internal/converters/eml/eml.go +++ b/src/internal/converters/eml/eml.go @@ -237,15 +237,12 @@ func FromJSON(ctx context.Context, body []byte) (string, error) { } if bytes == nil { - // Some attachments have an "item" field instead of - // "contentBytes". There are items like contacts, emails - // or calendar events which will not be a normal format - // and will have to be converted to a text format. - // TODO(meain): Handle custom attachments + // TODO(meain): Handle non file attachments // https://github.com/alcionai/corso/issues/4772 logger.Ctx(ctx). - With("attachment_id", ptr.Val(attachment.GetId())). - Info("unhandled attachment type") + With("attachment_id", ptr.Val(attachment.GetId()), + "attachment_type", ptr.Val(attachment.GetOdataType())). + Info("no contentBytes for attachment") continue } diff --git a/src/internal/converters/ics/ics.go b/src/internal/converters/ics/ics.go index 3e8277561..1aceccd1f 100644 --- a/src/internal/converters/ics/ics.go +++ b/src/internal/converters/ics/ics.go @@ -17,6 +17,7 @@ import ( "github.com/alcionai/corso/src/internal/common/ptr" "github.com/alcionai/corso/src/internal/common/str" "github.com/alcionai/corso/src/pkg/dttm" + "github.com/alcionai/corso/src/pkg/logger" "github.com/alcionai/corso/src/pkg/services/m365/api" ) @@ -527,7 +528,6 @@ func updateEventProperties(ctx context.Context, event models.Eventable, iCalEven } // ATTACH - https://www.rfc-editor.org/rfc/rfc5545#section-3.8.1.1 - // TODO Handle different attachment types (file, item and reference) attachments := event.GetAttachments() for _, attachment := range attachments { props := []ics.PropertyParameter{} @@ -548,6 +548,17 @@ func updateEventProperties(ctx context.Context, event models.Eventable, iCalEven return clues.WrapWC(ctx, err, "getting attachment content") } + if cb == nil { + // TODO(meain): Handle non file attachments + // https://github.com/alcionai/corso/issues/4772 + logger.Ctx(ctx). + With("attachment_id", ptr.Val(attachment.GetId()), + "attachment_type", ptr.Val(attachment.GetOdataType())). + Info("no contentBytes for attachment") + + continue + } + content, ok := cb.([]uint8) if !ok { return clues.NewWC(ctx, "getting attachment content string").