From daad056d7e4f775eb0b777a410beb6b18ce73801 Mon Sep 17 00:00:00 2001 From: Vaibhav Kamra Date: Fri, 17 Feb 2023 13:24:06 -0800 Subject: [PATCH] Pull in fix for concurrent map updates in clues (#2562) ## Description Pulls in fix for a panic caused by concurrent map updates in the clues pkg ## 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: Test - [ ] :computer: CI/Deployment - [ ] :broom: Tech Debt/Cleanup ## Test Plan - [ ] :muscle: Manual - [x] :zap: Unit test - [x] :green_heart: E2E --- src/go.mod | 4 +-- src/go.sum | 8 ++--- src/internal/connector/discovery/api/users.go | 12 +++---- .../connector/exchange/api/contacts.go | 36 +++++++++---------- src/internal/connector/exchange/api/events.go | 36 +++++++++---------- src/internal/connector/exchange/api/mail.go | 36 +++++++++---------- src/internal/connector/exchange/api/shared.go | 4 +-- src/internal/connector/exchange/attachment.go | 2 +- .../exchange/attachment_uploadable.go | 8 ++--- .../connector/exchange/service_restore.go | 8 ++--- src/internal/connector/graph/service.go | 4 +-- src/internal/connector/graph_connector.go | 6 ++-- .../connector/onedrive/collections.go | 4 +-- .../connector/uploadsession/uploadsession.go | 2 +- src/internal/kopia/model_store.go | 8 ++--- src/internal/kopia/upload.go | 4 +-- src/internal/operations/backup.go | 4 +-- src/internal/operations/manifests.go | 2 +- src/internal/operations/restore.go | 4 +-- src/pkg/path/resource_path.go | 2 +- src/pkg/repository/repository.go | 4 +-- 21 files changed, 99 insertions(+), 99 deletions(-) diff --git a/src/go.mod b/src/go.mod index 3c856feb4..a36afeec1 100644 --- a/src/go.mod +++ b/src/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0 - github.com/alcionai/clues v0.0.0-20230202001016-cbda58c9de9e + github.com/alcionai/clues v0.0.0-20230217203352-c3714e5e9013 github.com/aws/aws-sdk-go v1.44.202 github.com/aws/aws-xray-sdk-go v1.8.0 github.com/cenkalti/backoff/v4 v4.2.0 @@ -29,7 +29,7 @@ require ( github.com/tomlazar/table v0.1.2 github.com/vbauerster/mpb/v8 v8.1.6 go.uber.org/zap v1.24.0 - golang.org/x/exp v0.0.0-20221217163422-3c43f8badb15 + golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb golang.org/x/tools v0.6.0 gopkg.in/resty.v1 v1.12.0 ) diff --git a/src/go.sum b/src/go.sum index ab7e44971..2b7931114 100644 --- a/src/go.sum +++ b/src/go.sum @@ -52,8 +52,8 @@ github.com/VividCortex/ewma v1.2.0 h1:f58SaIzcDXrSy3kWaHNvuJgJ3Nmz59Zji6XoJR/q1o github.com/VividCortex/ewma v1.2.0/go.mod h1:nz4BbCtbLyFDeC9SUHbtcT5644juEuWfUAUnGx7j5l4= github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8= github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo= -github.com/alcionai/clues v0.0.0-20230202001016-cbda58c9de9e h1:KMRGDB9lh0wC/WYVmQ28MJ07qiHszCSH2PRwkw2YElM= -github.com/alcionai/clues v0.0.0-20230202001016-cbda58c9de9e/go.mod h1:UlAs8jkWIpsOMakiC8NxPgQQVQRdvyf1hYMszlYYLb4= +github.com/alcionai/clues v0.0.0-20230217203352-c3714e5e9013 h1:WWQ6E8hnoITmc/adlEySSVo3SOVvo1xhJKO08A1YPYY= +github.com/alcionai/clues v0.0.0-20230217203352-c3714e5e9013/go.mod h1:DeaMbAwDvYM6ZfPMR/GUl3hceqI5C8jIQ1lstjB2IW8= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -463,8 +463,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20221217163422-3c43f8badb15 h1:5oN1Pz/eDhCpbMbLstvIPa0b/BEQo6g6nwV3pLjfM6w= -golang.org/x/exp v0.0.0-20221217163422-3c43f8badb15/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb h1:PaBZQdo+iSDyHT053FjUCgZQ/9uqVwPOcl7KSWhKn6w= +golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= diff --git a/src/internal/connector/discovery/api/users.go b/src/internal/connector/discovery/api/users.go index 78962a7d2..3006c178b 100644 --- a/src/internal/connector/discovery/api/users.go +++ b/src/internal/connector/discovery/api/users.go @@ -97,7 +97,7 @@ func (c Users) GetAll(ctx context.Context, errs *fault.Errors) ([]models.Userabl resp, err = service.Client().Users().Get(ctx, userOptions(&userFilterNoGuests)) if err != nil { - return nil, clues.Wrap(err, "getting all users").WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Wrap(err, "getting all users").WithClues(ctx).With(graph.ErrData(err)...) } iter, err := msgraphgocore.NewPageIterator( @@ -105,7 +105,7 @@ func (c Users) GetAll(ctx context.Context, errs *fault.Errors) ([]models.Userabl service.Adapter(), models.CreateUserCollectionResponseFromDiscriminatorValue) if err != nil { - return nil, clues.Wrap(err, "creating users iterator").WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Wrap(err, "creating users iterator").WithClues(ctx).With(graph.ErrData(err)...) } us := make([]models.Userable, 0) @@ -117,7 +117,7 @@ func (c Users) GetAll(ctx context.Context, errs *fault.Errors) ([]models.Userabl u, err := validateUser(item) if err != nil { - errs.Add(clues.Wrap(err, "validating user").WithClues(ctx).WithAll(graph.ErrData(err)...)) + errs.Add(clues.Wrap(err, "validating user").WithClues(ctx).With(graph.ErrData(err)...)) } else { us = append(us, u) } @@ -126,7 +126,7 @@ func (c Users) GetAll(ctx context.Context, errs *fault.Errors) ([]models.Userabl } if err := iter.Iterate(ctx, iterator); err != nil { - return nil, clues.Wrap(err, "iterating all users").WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Wrap(err, "iterating all users").WithClues(ctx).With(graph.ErrData(err)...) } return us, errs.Err() @@ -141,7 +141,7 @@ func (c Users) GetByID(ctx context.Context, userID string) (models.Userable, err resp, err = c.stable.Client().UsersById(userID).Get(ctx, nil) if err != nil { - return nil, clues.Wrap(err, "getting user").WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Wrap(err, "getting user").WithClues(ctx).With(graph.ErrData(err)...) } return resp, err @@ -160,7 +160,7 @@ func (c Users) GetInfo(ctx context.Context, userID string) (*UserInfo, error) { if err != nil { if !graph.IsErrExchangeMailFolderNotFound(err) { - return nil, clues.Wrap(err, "getting user's mail folder").WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Wrap(err, "getting user's mail folder").WithClues(ctx).With(graph.ErrData(err)...) } delete(userInfo.DiscoveredServices, path.ExchangeService) diff --git a/src/internal/connector/exchange/api/contacts.go b/src/internal/connector/exchange/api/contacts.go index 4bb85927e..05b517468 100644 --- a/src/internal/connector/exchange/api/contacts.go +++ b/src/internal/connector/exchange/api/contacts.go @@ -49,7 +49,7 @@ func (c Contacts) CreateContactFolder( mdl, err := c.stable.Client().UsersById(user).ContactFolders().Post(ctx, requestBody, nil) if err != nil { - return nil, clues.Wrap(err, "creating contact folder").WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Wrap(err, "creating contact folder").WithClues(ctx).With(graph.ErrData(err)...) } return mdl, nil @@ -62,7 +62,7 @@ func (c Contacts) DeleteContainer( ) error { err := c.stable.Client().UsersById(user).ContactFoldersById(folderID).Delete(ctx, nil) if err != nil { - return clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } return nil @@ -76,7 +76,7 @@ func (c Contacts) GetItem( ) (serialization.Parsable, *details.ExchangeInfo, error) { cont, err := c.stable.Client().UsersById(user).ContactsById(itemID).Get(ctx, nil) if err != nil { - return nil, nil, clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, nil, clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } return cont, ContactInfo(cont), nil @@ -88,12 +88,12 @@ func (c Contacts) GetContainerByID( ) (graph.Container, error) { ofcf, err := optionsForContactFolderByID([]string{"displayName", "parentFolderId"}) if err != nil { - return nil, clues.Wrap(err, "setting contact folder options").WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Wrap(err, "setting contact folder options").WithClues(ctx).With(graph.ErrData(err)...) } resp, err := c.stable.Client().UsersById(userID).ContactFoldersById(dirID).Get(ctx, ofcf) if err != nil { - return nil, clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } return resp, nil @@ -113,7 +113,7 @@ func (c Contacts) EnumerateContainers( ) error { service, err := c.service() if err != nil { - return clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } fields := []string{"displayName", "parentFolderId"} @@ -122,7 +122,7 @@ func (c Contacts) EnumerateContainers( if err != nil { return clues.Wrap(err, "setting contact child folder options"). WithClues(ctx). - WithAll(graph.ErrData(err)...). + With(graph.ErrData(err)...). With("options_fields", fields) } @@ -134,7 +134,7 @@ func (c Contacts) EnumerateContainers( for { resp, err := builder.Get(ctx, ofcf) if err != nil { - return clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } for _, fold := range resp.GetValue() { @@ -143,18 +143,18 @@ func (c Contacts) EnumerateContainers( } if err := checkIDAndName(fold); err != nil { - errs.Add(clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...)) + errs.Add(clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...)) continue } - fctx := clues.AddAll( + fctx := clues.Add( ctx, "container_id", ptr.Val(fold.GetId()), "container_display_name", ptr.Val(fold.GetDisplayName())) temp := graph.NewCacheFolder(fold, nil, nil) if err := fn(temp); err != nil { - errs.Add(clues.Stack(err).WithClues(fctx).WithAll(graph.ErrData(err)...)) + errs.Add(clues.Stack(err).WithClues(fctx).With(graph.ErrData(err)...)) continue } } @@ -185,7 +185,7 @@ type contactPager struct { func (p *contactPager) getPage(ctx context.Context) (api.DeltaPageLinker, error) { resp, err := p.builder.Get(ctx, p.options) if err != nil { - return nil, clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } return resp, nil @@ -205,12 +205,12 @@ func (c Contacts) GetAddedAndRemovedItemIDs( ) ([]string, []string, DeltaUpdate, error) { service, err := c.service() if err != nil { - return nil, nil, DeltaUpdate{}, clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, nil, DeltaUpdate{}, clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } var resetDelta bool - ctx = clues.AddAll( + ctx = clues.Add( ctx, "category", selectors.ExchangeContact, "container_id", directoryID) @@ -220,7 +220,7 @@ func (c Contacts) GetAddedAndRemovedItemIDs( return nil, nil, DeltaUpdate{}, - clues.Wrap(err, "setting contact folder options").WithClues(ctx).WithAll(graph.ErrData(err)...) + clues.Wrap(err, "setting contact folder options").WithClues(ctx).With(graph.ErrData(err)...) } if len(oldDelta) > 0 { @@ -238,7 +238,7 @@ func (c Contacts) GetAddedAndRemovedItemIDs( // only return on error if it is NOT a delta issue. // on bad deltas we retry the call with the regular builder if !graph.IsErrInvalidDelta(err) { - return nil, nil, DeltaUpdate{}, clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, nil, DeltaUpdate{}, clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } resetDelta = true @@ -294,12 +294,12 @@ func (c Contacts) Serialize( defer writer.Close() if err = writer.WriteObjectValue("", contact); err != nil { - return nil, clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } bs, err := writer.GetSerializedContent() if err != nil { - return nil, clues.Wrap(err, "serializing contact").WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Wrap(err, "serializing contact").WithClues(ctx).With(graph.ErrData(err)...) } return bs, nil diff --git a/src/internal/connector/exchange/api/events.go b/src/internal/connector/exchange/api/events.go index 6b6eb7ad3..e3be3e85f 100644 --- a/src/internal/connector/exchange/api/events.go +++ b/src/internal/connector/exchange/api/events.go @@ -50,7 +50,7 @@ func (c Events) CreateCalendar( mdl, err := c.stable.Client().UsersById(user).Calendars().Post(ctx, requestbody, nil) if err != nil { - return nil, clues.Wrap(err, "creating calendar").WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Wrap(err, "creating calendar").WithClues(ctx).With(graph.ErrData(err)...) } return mdl, nil @@ -64,7 +64,7 @@ func (c Events) DeleteContainer( ) error { err := c.stable.Client().UsersById(user).CalendarsById(calendarID).Delete(ctx, nil) if err != nil { - return clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } return nil @@ -76,17 +76,17 @@ func (c Events) GetContainerByID( ) (graph.Container, error) { service, err := c.service() if err != nil { - return nil, clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } ofc, err := optionsForCalendarsByID([]string{"name", "owner"}) if err != nil { - return nil, clues.Wrap(err, "setting event calendar options").WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Wrap(err, "setting event calendar options").WithClues(ctx).With(graph.ErrData(err)...) } cal, err := service.Client().UsersById(userID).CalendarsById(containerID).Get(ctx, ofc) if err != nil { - return nil, clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } return graph.CalendarDisplayable{Calendarable: cal}, nil @@ -105,7 +105,7 @@ func (c Events) GetItem( event, err = c.stable.Client().UsersById(user).EventsById(itemID).Get(ctx, nil) if err != nil { - return nil, nil, clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, nil, clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } if *event.GetHasAttachments() || HasAttachments(event.GetBody()) { @@ -122,7 +122,7 @@ func (c Events) GetItem( Attachments(). Get(ctx, options) if err != nil { - return nil, nil, clues.Wrap(err, "event attachment download").WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, nil, clues.Wrap(err, "event attachment download").WithClues(ctx).With(graph.ErrData(err)...) } event.SetAttachments(attached.GetValue()) @@ -145,12 +145,12 @@ func (c Events) EnumerateContainers( ) error { service, err := c.service() if err != nil { - return clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } ofc, err := optionsForCalendars([]string{"name"}) if err != nil { - return clues.Wrap(err, "setting calendar options").WithClues(ctx).WithAll(graph.ErrData(err)...) + return clues.Wrap(err, "setting calendar options").WithClues(ctx).With(graph.ErrData(err)...) } builder := service.Client().UsersById(userID).Calendars() @@ -158,17 +158,17 @@ func (c Events) EnumerateContainers( for { resp, err := builder.Get(ctx, ofc) if err != nil { - return clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } for _, cal := range resp.GetValue() { cd := CalendarDisplayable{Calendarable: cal} if err := checkIDAndName(cd); err != nil { - errs.Add(clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...)) + errs.Add(clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...)) continue } - fctx := clues.AddAll( + fctx := clues.Add( ctx, "container_id", ptr.Val(cal.GetId()), "container_name", ptr.Val(cal.GetName())) @@ -178,7 +178,7 @@ func (c Events) EnumerateContainers( path.Builder{}.Append(ptr.Val(cd.GetId())), // storage path path.Builder{}.Append(ptr.Val(cd.GetDisplayName()))) // display location if err := fn(temp); err != nil { - errs.Add(clues.Stack(err).WithClues(fctx).WithAll(graph.ErrData(err)...)) + errs.Add(clues.Stack(err).WithClues(fctx).With(graph.ErrData(err)...)) continue } } @@ -213,7 +213,7 @@ type eventPager struct { func (p *eventPager) getPage(ctx context.Context) (api.DeltaPageLinker, error) { resp, err := p.builder.Get(ctx, p.options) if err != nil { - return nil, clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } return resp, nil @@ -238,7 +238,7 @@ func (c Events) GetAddedAndRemovedItemIDs( var resetDelta bool - ctx = clues.AddAll( + ctx = clues.Add( ctx, "container_id", calendarID) @@ -256,7 +256,7 @@ func (c Events) GetAddedAndRemovedItemIDs( // only return on error if it is NOT a delta issue. // on bad deltas we retry the call with the regular builder if !graph.IsErrInvalidDelta(err) { - return nil, nil, DeltaUpdate{}, clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, nil, DeltaUpdate{}, clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } resetDelta = true @@ -322,12 +322,12 @@ func (c Events) Serialize( defer writer.Close() if err = writer.WriteObjectValue("", event); err != nil { - return nil, clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } bs, err := writer.GetSerializedContent() if err != nil { - return nil, clues.Wrap(err, "serializing event").WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Wrap(err, "serializing event").WithClues(ctx).With(graph.ErrData(err)...) } return bs, nil diff --git a/src/internal/connector/exchange/api/mail.go b/src/internal/connector/exchange/api/mail.go index 8102b776f..ff6afea6b 100644 --- a/src/internal/connector/exchange/api/mail.go +++ b/src/internal/connector/exchange/api/mail.go @@ -50,7 +50,7 @@ func (c Mail) CreateMailFolder( mdl, err := c.stable.Client().UsersById(user).MailFolders().Post(ctx, requestBody, nil) if err != nil { - return nil, clues.Wrap(err, "creating mail folder").WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Wrap(err, "creating mail folder").WithClues(ctx).With(graph.ErrData(err)...) } return mdl, nil @@ -62,7 +62,7 @@ func (c Mail) CreateMailFolderWithParent( ) (models.MailFolderable, error) { service, err := c.service() if err != nil { - return nil, clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } isHidden := false @@ -77,7 +77,7 @@ func (c Mail) CreateMailFolderWithParent( ChildFolders(). Post(ctx, requestBody, nil) if err != nil { - return nil, clues.Wrap(err, "creating nested mail folder").WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Wrap(err, "creating nested mail folder").WithClues(ctx).With(graph.ErrData(err)...) } return mdl, nil @@ -91,7 +91,7 @@ func (c Mail) DeleteContainer( ) error { err := c.stable.Client().UsersById(user).MailFoldersById(folderID).Delete(ctx, nil) if err != nil { - return clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } return nil @@ -103,17 +103,17 @@ func (c Mail) GetContainerByID( ) (graph.Container, error) { service, err := c.service() if err != nil { - return nil, clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } ofmf, err := optionsForMailFoldersItem([]string{"displayName", "parentFolderId"}) if err != nil { - return nil, clues.Wrap(err, "setting mail folder options").WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Wrap(err, "setting mail folder options").WithClues(ctx).With(graph.ErrData(err)...) } resp, err := service.Client().UsersById(userID).MailFoldersById(dirID).Get(ctx, ofmf) if err != nil { - return nil, clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } return resp, nil @@ -128,7 +128,7 @@ func (c Mail) GetItem( ) (serialization.Parsable, *details.ExchangeInfo, error) { mail, err := c.stable.Client().UsersById(user).MessagesById(itemID).Get(ctx, nil) if err != nil { - return nil, nil, clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, nil, clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } if *mail.GetHasAttachments() || HasAttachments(mail.GetBody()) { @@ -145,7 +145,7 @@ func (c Mail) GetItem( Attachments(). Get(ctx, options) if err != nil { - return nil, nil, clues.Wrap(err, "mail attachment download").WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, nil, clues.Wrap(err, "mail attachment download").WithClues(ctx).With(graph.ErrData(err)...) } mail.SetAttachments(attached.GetValue()) @@ -168,7 +168,7 @@ func (c Mail) EnumerateContainers( ) error { service, err := c.service() if err != nil { - return clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } builder := service.Client(). @@ -179,18 +179,18 @@ func (c Mail) EnumerateContainers( for { resp, err := builder.Get(ctx, nil) if err != nil { - return clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } for _, v := range resp.GetValue() { - fctx := clues.AddAll( + fctx := clues.Add( ctx, "container_id", ptr.Val(v.GetId()), "container_name", ptr.Val(v.GetDisplayName())) temp := graph.NewCacheFolder(v, nil, nil) if err := fn(temp); err != nil { - errs.Add(clues.Stack(err).WithClues(fctx).WithAll(graph.ErrData(err)...)) + errs.Add(clues.Stack(err).WithClues(fctx).With(graph.ErrData(err)...)) continue } } @@ -221,7 +221,7 @@ type mailPager struct { func (p *mailPager) getPage(ctx context.Context) (api.DeltaPageLinker, error) { page, err := p.builder.Get(ctx, p.options) if err != nil { - return nil, clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } return page, nil @@ -249,7 +249,7 @@ func (c Mail) GetAddedAndRemovedItemIDs( resetDelta bool ) - ctx = clues.AddAll( + ctx = clues.Add( ctx, "category", selectors.ExchangeMail, "container_id", directoryID) @@ -259,7 +259,7 @@ func (c Mail) GetAddedAndRemovedItemIDs( return nil, nil, DeltaUpdate{}, - clues.Wrap(err, "setting contact folder options").WithClues(ctx).WithAll(graph.ErrData(err)...) + clues.Wrap(err, "setting contact folder options").WithClues(ctx).With(graph.ErrData(err)...) } if len(oldDelta) > 0 { @@ -332,12 +332,12 @@ func (c Mail) Serialize( defer writer.Close() if err = writer.WriteObjectValue("", msg); err != nil { - return nil, clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } bs, err := writer.GetSerializedContent() if err != nil { - return nil, clues.Wrap(err, "serializing email").WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Wrap(err, "serializing email").WithClues(ctx).With(graph.ErrData(err)...) } return bs, nil diff --git a/src/internal/connector/exchange/api/shared.go b/src/internal/connector/exchange/api/shared.go index 5db8a481f..b5f9a7466 100644 --- a/src/internal/connector/exchange/api/shared.go +++ b/src/internal/connector/exchange/api/shared.go @@ -74,14 +74,14 @@ func getItemsAddedAndRemovedFromContainer( // get the next page of data, check for standard errors resp, err := pager.getPage(ctx) if err != nil { - return nil, nil, deltaURL, clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, nil, deltaURL, clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } // each category type responds with a different interface, but all // of them comply with GetValue, which is where we'll get our item data. items, err := pager.valuesIn(resp) if err != nil { - return nil, nil, "", clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, nil, "", clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } itemCount += len(items) diff --git a/src/internal/connector/exchange/attachment.go b/src/internal/connector/exchange/attachment.go index bb8756bbe..e21d739bb 100644 --- a/src/internal/connector/exchange/attachment.go +++ b/src/internal/connector/exchange/attachment.go @@ -48,7 +48,7 @@ func uploadAttachment( ) error { attachmentType := attachmentType(attachment) - ctx = clues.AddAll( + ctx = clues.Add( ctx, "attachment_size", ptr.Val(attachment.GetSize()), "attachment_id", ptr.Val(attachment.GetId()), diff --git a/src/internal/connector/exchange/attachment_uploadable.go b/src/internal/connector/exchange/attachment_uploadable.go index 4bc96f58e..cd7d2710d 100644 --- a/src/internal/connector/exchange/attachment_uploadable.go +++ b/src/internal/connector/exchange/attachment_uploadable.go @@ -44,7 +44,7 @@ func (mau *mailAttachmentUploader) uploadSmallAttachment(ctx context.Context, at Attachments(). Post(ctx, attach, nil) if err != nil { - return clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } return nil @@ -68,7 +68,7 @@ func (mau *mailAttachmentUploader) uploadSession( CreateUploadSession(). Post(ctx, session, nil) if err != nil { - return nil, clues.Wrap(err, "uploading mail attachment").WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Wrap(err, "uploading mail attachment").WithClues(ctx).With(graph.ErrData(err)...) } return r, nil @@ -94,7 +94,7 @@ func (eau *eventAttachmentUploader) uploadSmallAttachment(ctx context.Context, a Attachments(). Post(ctx, attach, nil) if err != nil { - return clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } return nil @@ -116,7 +116,7 @@ func (eau *eventAttachmentUploader) uploadSession( CreateUploadSession(). Post(ctx, session, nil) if err != nil { - return nil, clues.Wrap(err, "uploading event attachment").WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Wrap(err, "uploading event attachment").WithClues(ctx).With(graph.ErrData(err)...) } return r, nil diff --git a/src/internal/connector/exchange/service_restore.go b/src/internal/connector/exchange/service_restore.go index 67c9494fb..52dc80977 100644 --- a/src/internal/connector/exchange/service_restore.go +++ b/src/internal/connector/exchange/service_restore.go @@ -77,7 +77,7 @@ func RestoreExchangeContact( response, err := service.Client().UsersById(user).ContactFoldersById(destination).Contacts().Post(ctx, contact, nil) if err != nil { - return nil, clues.Wrap(err, "uploading Contact").WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Wrap(err, "uploading Contact").WithClues(ctx).With(graph.ErrData(err)...) } if response == nil { @@ -124,7 +124,7 @@ func RestoreExchangeEvent( response, err := service.Client().UsersById(user).CalendarsById(destination).Events().Post(ctx, transformedEvent, nil) if err != nil { - return nil, clues.Wrap(err, "uploading event").WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Wrap(err, "uploading event").WithClues(ctx).With(graph.ErrData(err)...) } if response == nil { @@ -248,7 +248,7 @@ func SendMailToBackStore( response, err := service.Client().UsersById(user).MailFoldersById(destination).Messages().Post(ctx, message, nil) if err != nil { - return clues.Wrap(err, "restoring mail").WithClues(ctx).WithAll(graph.ErrData(err)...) + return clues.Wrap(err, "restoring mail").WithClues(ctx).With(graph.ErrData(err)...) } if response == nil { @@ -379,7 +379,7 @@ func restoreCollection( user = directory.ResourceOwner() ) - ctx = clues.AddAll( + ctx = clues.Add( ctx, "full_path", directory, "service", service, diff --git a/src/internal/connector/graph/service.go b/src/internal/connector/graph/service.go index 781914133..01e6f4a73 100644 --- a/src/internal/connector/graph/service.go +++ b/src/internal/connector/graph/service.go @@ -336,7 +336,7 @@ func (middleware RetryHandler) Intercept( response, err := pipeline.Next(req, middlewareIndex) if err != nil && !IsErrTimeout(err) { - return nil, clues.Stack(err).WithClues(ctx).WithAll(ErrData(err)...) + return nil, clues.Stack(err).WithClues(ctx).With(ErrData(err)...) } exponentialBackOff := backoff.NewExponentialBackOff() @@ -354,7 +354,7 @@ func (middleware RetryHandler) Intercept( exponentialBackOff, err) if err != nil { - return nil, clues.Stack(err).WithClues(ctx).WithAll(ErrData(err)...) + return nil, clues.Stack(err).WithClues(ctx).With(ErrData(err)...) } return response, nil diff --git a/src/internal/connector/graph_connector.go b/src/internal/connector/graph_connector.go index 8e8bb824b..5b1679060 100644 --- a/src/internal/connector/graph_connector.go +++ b/src/internal/connector/graph_connector.go @@ -322,12 +322,12 @@ func getResources( if err != nil { return nil, clues.Wrap(err, "retrieving tenant's resources"). WithClues(ctx). - WithAll(graph.ErrData(err)...) + With(graph.ErrData(err)...) } iter, err := msgraphgocore.NewPageIterator(response, gs.Adapter(), parser) if err != nil { - return nil, clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } callbackFunc := func(item any) bool { @@ -352,7 +352,7 @@ func getResources( } if err := iter.Iterate(ctx, callbackFunc); err != nil { - return nil, clues.Stack(err).WithClues(ctx).WithAll(graph.ErrData(err)...) + return nil, clues.Stack(err).WithClues(ctx).With(graph.ErrData(err)...) } return resources, errs.Err() diff --git a/src/internal/connector/onedrive/collections.go b/src/internal/connector/onedrive/collections.go index 279993edf..749e865a8 100644 --- a/src/internal/connector/onedrive/collections.go +++ b/src/internal/connector/onedrive/collections.go @@ -505,7 +505,7 @@ func (c *Collections) UpdateCollections( if ok { prevPath, err = path.FromDataLayerPath(prevPathStr, false) if err != nil { - return clues.Wrap(err, "invalid previous path").WithAll("path_string", prevPathStr) + return clues.Wrap(err, "invalid previous path").With("path_string", prevPathStr) } } @@ -617,7 +617,7 @@ func (c *Collections) UpdateCollections( if ok { prevCollectionPath, err = path.FromDataLayerPath(prevCollectionPathStr, false) if err != nil { - return clues.Wrap(err, "invalid previous path").WithAll("path_string", prevCollectionPathStr) + return clues.Wrap(err, "invalid previous path").With("path_string", prevCollectionPathStr) } } diff --git a/src/internal/connector/uploadsession/uploadsession.go b/src/internal/connector/uploadsession/uploadsession.go index 5dc04388c..60f84f6ef 100644 --- a/src/internal/connector/uploadsession/uploadsession.go +++ b/src/internal/connector/uploadsession/uploadsession.go @@ -57,7 +57,7 @@ func (iw *writer) Write(p []byte) (int, error) { }). SetBody(bytes.NewReader(p)).Put(iw.url) if err != nil { - return 0, clues.Wrap(err, "uploading item").WithAll( + return 0, clues.Wrap(err, "uploading item").With( "upload_id", iw.id, "upload_chunk_size", rangeLength, "upload_offset", iw.lastWrittenOffset, diff --git a/src/internal/kopia/model_store.go b/src/internal/kopia/model_store.go index 58111dfa9..90ecda844 100644 --- a/src/internal/kopia/model_store.go +++ b/src/internal/kopia/model_store.go @@ -214,7 +214,7 @@ func (ms ModelStore) baseModelFromMetadata( ) (*model.BaseModel, error) { res := &model.BaseModel{} if err := ms.populateBaseModelFromMetadata(res, m); err != nil { - return nil, clues.Stack(err).WithAll("metadata_id", m.ID, "metadata_modtime", m.ModTime) + return nil, clues.Stack(err).With("metadata_id", m.ID, "metadata_modtime", m.ModTime) } return res, nil @@ -349,7 +349,7 @@ func (ms *ModelStore) GetWithModelStoreID( if mdlbl != s.String() { return clues.Stack(errModelTypeMismatch). WithClues(ctx). - WithAll("expected_label", s, "got_label", mdlbl) + With("expected_label", s, "got_label", mdlbl) } if err := ms.populateBaseModelFromMetadata(m.Base(), metadata); err != nil { @@ -387,14 +387,14 @@ func (ms *ModelStore) checkPrevModelVersion( if meta.ID != b.ModelStoreID { return clues.New("updated model has different ModelStoreID"). WithClues(ctx). - WithAll("expected_id", meta.ID, "model_store_id", b.ModelStoreID) + With("expected_id", meta.ID, "model_store_id", b.ModelStoreID) } mdlbl := meta.Labels[manifest.TypeLabelKey] if mdlbl != s.String() { return clues.New("updated model has different model type"). WithClues(ctx). - WithAll("expected_label", s, "got_label", mdlbl) + With("expected_label", s, "got_label", mdlbl) } return nil diff --git a/src/internal/kopia/upload.go b/src/internal/kopia/upload.go index 302063933..c6d77b126 100644 --- a/src/internal/kopia/upload.go +++ b/src/internal/kopia/upload.go @@ -170,7 +170,7 @@ func (cp *corsoProgress) FinishedFile(relativePath string, err error) { if d.info == nil { if d.prevPath == nil { cp.errs.Add(clues.New("item sourced from previous backup with no previous path"). - WithAll( + With( "service", d.repoPath.Service().String(), "category", d.repoPath.Category().String(), )) @@ -264,7 +264,7 @@ func (cp *corsoProgress) Error(relpath string, err error, isIgnored bool) { defer cp.UploadProgress.Error(relpath, err, isIgnored) cp.errs.Add(clues.Wrap(err, "kopia reported error"). - WithAll("is_ignored", isIgnored, "relative_path", relpath)) + With("is_ignored", isIgnored, "relative_path", relpath)) } func (cp *corsoProgress) put(k string, v *itemDetails) { diff --git a/src/internal/operations/backup.go b/src/internal/operations/backup.go index 64debf159..03f410508 100644 --- a/src/internal/operations/backup.go +++ b/src/internal/operations/backup.go @@ -149,7 +149,7 @@ func (op *BackupOperation) Run(ctx context.Context) (err error) { op.Results.BackupID = model.StableID(uuid.NewString()) - ctx = clues.AddAll( + ctx = clues.Add( ctx, "tenant_id", op.account.ID(), // TODO: pii "resource_owner", op.ResourceOwner, // TODO: pii @@ -609,7 +609,7 @@ func mergeDetails( if addedEntries != len(shortRefsFromPrevBackup) { return clues.New("incomplete migration of backup details"). WithClues(ctx). - WithAll("item_count", addedEntries, "expected_item_count", len(shortRefsFromPrevBackup)) + With("item_count", addedEntries, "expected_item_count", len(shortRefsFromPrevBackup)) } return nil diff --git a/src/internal/operations/manifests.go b/src/internal/operations/manifests.go index ebe40f8a9..1460bb5a7 100644 --- a/src/internal/operations/manifests.go +++ b/src/internal/operations/manifests.go @@ -204,7 +204,7 @@ func collectMetadata( if err != nil { return nil, clues. Wrap(err, "building metadata path"). - WithAll("metadata_file", fn, "category", reason.Category) + With("metadata_file", fn, "category", reason.Category) } paths = append(paths, p) diff --git a/src/internal/operations/restore.go b/src/internal/operations/restore.go index e44a7cbc4..cd935e042 100644 --- a/src/internal/operations/restore.go +++ b/src/internal/operations/restore.go @@ -150,7 +150,7 @@ func (op *RestoreOperation) Run(ctx context.Context) (restoreDetails *details.De observe.Complete() }() - ctx = clues.AddAll( + ctx = clues.Add( ctx, "tenant_id", op.account.ID(), // TODO: pii "backup_id", op.BackupID, @@ -208,7 +208,7 @@ func (op *RestoreOperation) do( return nil, errors.Wrap(err, "formatting paths from details") } - ctx = clues.AddAll( + ctx = clues.Add( ctx, "resource_owner", bup.Selector.DiscreteOwner, "details_paths", len(paths)) diff --git a/src/pkg/path/resource_path.go b/src/pkg/path/resource_path.go index 77dcaacf3..b1a64449a 100644 --- a/src/pkg/path/resource_path.go +++ b/src/pkg/path/resource_path.go @@ -144,7 +144,7 @@ func validateServiceAndCategory(service ServiceType, category CategoryType) erro if _, ok := cats[category]; !ok { return clues.New("unknown service/category combination"). - WithAll("service", fmt.Sprintf("%q", service), "category", fmt.Sprintf("%q", category)) + With("service", fmt.Sprintf("%q", service), "category", fmt.Sprintf("%q", category)) } return nil diff --git a/src/pkg/repository/repository.go b/src/pkg/repository/repository.go index 272861d31..df5e415bc 100644 --- a/src/pkg/repository/repository.go +++ b/src/pkg/repository/repository.go @@ -89,7 +89,7 @@ func Initialize( s storage.Storage, opts control.Options, ) (Repository, error) { - ctx = clues.AddAll( + ctx = clues.Add( ctx, "acct_provider", acct.Provider.String(), "acct_id", acct.ID(), // TODO: pii @@ -157,7 +157,7 @@ func Connect( s storage.Storage, opts control.Options, ) (Repository, error) { - ctx = clues.AddAll( + ctx = clues.Add( ctx, "acct_provider", acct.Provider.String(), "acct_id", acct.ID(), // TODO: pii