Improve error handling during backup persistence (#4320)

<!-- PR description-->

We were not catching missing snapshot ID sooner. Fixed it.


---

#### 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
- [ ] 🤖 Supportability/Tests
- [ ] 💻 CI/Deployment
- [x] 🧹 Tech Debt/Cleanup

#### Issue(s)

<!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. -->
* https://github.com/alcionai/corso/issues/4305

#### Test Plan

<!-- How will this be tested prior to merging.-->
- [x] 💪 Manual
- [ ]  Unit test
- [ ] 💚 E2E
This commit is contained in:
Abhishek Pandey 2023-09-21 11:22:48 +05:30 committed by GitHub
parent a28f57a6de
commit 7050b0c9d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -856,12 +856,23 @@ func (op *BackupOperation) createBackupModels(
// are generated during the serialization process.
errs := fault.New(true)
// We don't persist a backup if there were non-recoverable errors seen
// during the operation, regardless of the failure policy. Unlikely we'd
// hit this here as the preceding code should already take care of it.
if op.Errors.Failure() != nil {
return clues.Wrap(op.Errors.Failure(), "non-recoverable failure").WithClues(ctx)
}
if deets == nil {
return clues.New("no backup details to record").WithClues(ctx)
}
ctx = clues.Add(ctx, "details_entry_count", len(deets.Entries))
if len(snapID) == 0 {
return clues.New("no snapshot ID to record").WithClues(ctx)
}
err := sscw.Collect(ctx, streamstore.DetailsCollector(deets))
if err != nil {
return clues.Wrap(err, "collecting details for persistence").WithClues(ctx)