From abf5eee5a9d7ea0742f0febe5e1f27dfaceac090 Mon Sep 17 00:00:00 2001 From: George MacRorie Date: Wed, 12 Feb 2020 14:22:21 +0000 Subject: [PATCH] fix(kv): return not found code when user resource mapping indexed by not in source --- kv/urm.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/kv/urm.go b/kv/urm.go index 13c77d14a3d..358c37a394d 100644 --- a/kv/urm.go +++ b/kv/urm.go @@ -195,13 +195,16 @@ func (s *Service) findUserResourceMappingsByIndex(ctx context.Context, tx Tx, fi } for k, v := cursor.Next(); k != nil && v != nil; k, v = cursor.Next() { - v, err := bkt.Get(v) + nv, err := bkt.Get(v) if err != nil { - return nil, err + return nil, &influxdb.Error{ + Code: influxdb.ENotFound, + Err: err, + } } m := &influxdb.UserResourceMapping{} - if err := json.Unmarshal(v, m); err != nil { + if err := json.Unmarshal(nv, m); err != nil { return nil, CorruptURMError(err) } @@ -531,11 +534,13 @@ func (s *Service) deleteOrgDependentMappings(ctx context.Context, tx Tx, m *infl return err } for _, b := range bs { - if err := s.deleteUserResourceMapping(ctx, tx, influxdb.UserResourceMappingFilter{ + filter := influxdb.UserResourceMappingFilter{ ResourceType: influxdb.BucketsResourceType, ResourceID: b.ID, UserID: m.UserID, - }); err != nil { + } + + if err := s.deleteUserResourceMapping(ctx, tx, filter); err != nil { if influxdb.ErrorCode(err) == influxdb.ENotFound { s.log.Info("URM bucket is missing", zap.Stringer("orgID", m.ResourceID)) continue