From 7a7933e54c7af5609095ffff0b249bad52cdc08a Mon Sep 17 00:00:00 2001 From: Abin Simon Date: Thu, 23 Mar 2023 04:23:45 +0530 Subject: [PATCH] Assume that item has no attachments if there is no body (#2911) Some response from the Graph API was returning empty body. This could be something left over from older version of the platform, but this causes issues in our codebase. --- #### Does this PR need a docs update or release note? - [x] :white_check_mark: Yes, it's included - [ ] :clock1: Yes, but in a later PR - [ ] :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 - [x] :zap: Unit test - [ ] :green_heart: E2E --- CHANGELOG.md | 3 ++- src/internal/connector/exchange/api/api.go | 4 ++++ src/internal/connector/exchange/api/api_test.go | 7 +++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 519a70083..e61c092e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,9 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] (beta) ### Fixed -- Fixed permissions restore in latest backup version +- Fixed permissions restore in latest backup version. - Incremental OneDrive backups could panic if the delta token expired and a folder was seen and deleted in the course of item enumeration for the backup. - Incorrectly moving subfolder hierarchy from a deleted folder to a new folder at the same path during OneDrive incremental backup. +- Handle calendar events with no body. ## [v0.6.1] (beta) - 2023-03-21 diff --git a/src/internal/connector/exchange/api/api.go b/src/internal/connector/exchange/api/api.go index 0d05e25b0..7c4622bdf 100644 --- a/src/internal/connector/exchange/api/api.go +++ b/src/internal/connector/exchange/api/api.go @@ -135,6 +135,10 @@ func checkIDAndName(c graph.Container) error { } func HasAttachments(body models.ItemBodyable) bool { + if body == nil { + return false + } + if ct, ok := ptr.ValOK(body.GetContentType()); !ok || ct == models.TEXT_BODYTYPE { return false } diff --git a/src/internal/connector/exchange/api/api_test.go b/src/internal/connector/exchange/api/api_test.go index d8c2c7f39..9c63f1333 100644 --- a/src/internal/connector/exchange/api/api_test.go +++ b/src/internal/connector/exchange/api/api_test.go @@ -208,6 +208,13 @@ func (suite *ExchangeServiceSuite) TestHasAttachments() { return body }, }, + { + name: "No body", + hasAttachment: assert.False, + getBodyable: func(t *testing.T) models.ItemBodyable { + return nil + }, + }, } for _, test := range tests {