From f4bed346fdfcca7b1b43b12696a4ee58f1e6e61f Mon Sep 17 00:00:00 2001 From: Steven Rhodes Date: Thu, 14 Sep 2023 19:09:00 -0700 Subject: [PATCH] Add error handling --- services/packages/server/packages.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/services/packages/server/packages.go b/services/packages/server/packages.go index 3411a225..3d7e90ff 100644 --- a/services/packages/server/packages.go +++ b/services/packages/server/packages.go @@ -346,6 +346,10 @@ func (s *server) Install(ctx context.Context, req *pb.InstallRequest) (*pb.Insta // Make sure we actually installed the package. postValidateCommand, err := generateValidate(req.PackageSystem, req.Name, req.Version) + if err != nil { + recorder.CounterOrLog(ctx, packagesInstallFailureCounter, 1, attribute.String("reason", "post_validate_err")) + return nil, err + } validation, err := util.RunCommand(ctx, postValidateCommand[0], postValidateCommand[1:]) if err != nil { recorder.CounterOrLog(ctx, packagesInstallFailureCounter, 1, attribute.String("reason", "post_validate_err")) @@ -468,6 +472,10 @@ func (s *server) Update(ctx context.Context, req *pb.UpdateRequest) (*pb.UpdateR // Make sure we actually installed the package. postValidateCommand, err := generateValidate(req.PackageSystem, req.Name, req.NewVersion) + if err != nil { + recorder.CounterOrLog(ctx, packagesUpdateFailureCounter, 1, attribute.String("reason", "post_validate_err")) + return nil, err + } validation, err := util.RunCommand(ctx, postValidateCommand[0], postValidateCommand[1:]) if err != nil { recorder.CounterOrLog(ctx, packagesUpdateFailureCounter, 1, attribute.String("reason", "post_validate_err"))