From f0b8041c3fd49e157cbea60ad2413bc7327ea0d7 Mon Sep 17 00:00:00 2001 From: Abin Simon Date: Sat, 10 Feb 2024 13:27:57 +0530 Subject: [PATCH] Fix possible panic in contacts fetch (#5205) We were not checking for the error returned by the Get method before trying to use the result to get contact info. --- #### 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 - [x] :muscle: Manual - [ ] :zap: Unit test - [ ] :green_heart: E2E --- src/pkg/services/m365/api/contacts.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pkg/services/m365/api/contacts.go b/src/pkg/services/m365/api/contacts.go index 1eb343581..92494eed8 100644 --- a/src/pkg/services/m365/api/contacts.go +++ b/src/pkg/services/m365/api/contacts.go @@ -186,8 +186,11 @@ func (c Contacts) GetItem( Contacts(). ByContactId(itemID). Get(ctx, options) + if err != nil { + return nil, nil, clues.Stack(err) + } - return cont, ContactInfo(cont), clues.Stack(err).OrNil() + return cont, ContactInfo(cont), nil } func (c Contacts) PostItem(