Fix panic in GroupByID call (#4778)

`resp` is nil if there's an error and `getGroupFromResponse` will panic.

---

#### 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
- [x] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 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.-->
- [x] 💪 Manual
- [ ]  Unit test
- [ ] 💚 E2E
This commit is contained in:
Vaibhav Kamra 2023-12-01 11:33:19 -08:00 committed by GitHub
parent 37dcb952fb
commit 5a77db656e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -150,15 +150,15 @@ func (c Groups) GetByID(
}
resp, err := service.Client().Groups().Get(ctx, opts)
if err != nil {
if graph.IsErrResourceLocked(err) {
err = clues.Stack(graph.ErrResourceLocked, err)
}
logger.CtxErr(ctx, err).Info("finding group by email, falling back to display name")
if err == nil {
return getGroupFromResponse(ctx, resp)
}
return getGroupFromResponse(ctx, resp)
if graph.IsErrResourceLocked(err) {
err = clues.Stack(graph.ErrResourceLocked, err)
}
logger.CtxErr(ctx, err).Info("finding group by email, falling back to display name")
}
// fall back to display name