Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: handle nil deference and improve log messages (#5797)
Danny Xu545a4c354e2f
diff --git a/backend/api/v1/review_service.go b/backend/api/v1/review_service.goindex f1c464a6a3..c5605bc93e 100644--- a/backend/api/v1/review_service.go+++ b/backend/api/v1/review_service.go@@ -50,6 +50,9 @@ func (s *ReviewService) GetReview(ctx context.Context, request *v1pb.GetReviewReif err != nil {return nil, status.Errorf(codes.Internal, "failed to get issue, error: %v", err)}+ if issue == nil {+ return nil, status.Errorf(codes.NotFound, "issue %d not found", reviewID)+ }review, err := convertToReview(ctx, s.store, issue)if err != nil {return nil, status.Errorf(codes.Internal, "failed to convert to review, error: %v", err)@@ -67,6 +70,9 @@ func (s *ReviewService) ApproveReview(ctx context.Context, request *v1pb.Approveif err != nil {return nil, status.Errorf(codes.Internal, "failed to get issue, error: %v", err)}+ if issue == nil {+ return nil, status.Errorf(codes.NotFound, "issue %d not found", reviewID)+ }payload := &storepb.IssuePayload{}if err := protojson.Unmarshal([]byte(issue.Payload), payload); err != nil {return nil, status.Errorf(codes.Internal, "failed to unmarshal issue payload, error: %v", err)@@ -199,6 +205,9 @@ func (s *ReviewService) UpdateReview(ctx context.Context, request *v1pb.UpdateReif err != nil {return nil, status.Errorf(codes.Internal, "failed to get issue, error: %v", err)}+ if issue == nil {+ return nil, status.Errorf(codes.NotFound, "issue %d not found", reviewID)+ }patch := &store.UpdateIssueMessage{}for _, path := range request.UpdateMask.Paths {diff --git a/backend/plugin/vcs/gitlab/gitlab.go b/backend/plugin/vcs/gitlab/gitlab.goindex 78ff879625..7aef220e27 100644--- a/backend/plugin/vcs/gitlab/gitlab.go+++ b/backend/plugin/vcs/gitlab/gitlab.go@@ -555,7 +555,7 @@ func (p *Provider) CreateFile(ctx context.Context, oauthCtx common.OauthContext,}url := fmt.Sprintf("%s/projects/%s/repository/files/%s", p.APIURL(instanceURL), repositoryID, url.QueryEscape(filePath))- code, _, _, err := oauth.Post(+ code, _, resp, err := oauth.Post(ctx,p.client,url,@@ -578,10 +578,10 @@ func (p *Provider) CreateFile(ctx context.Context, oauthCtx common.OauthContext,if code == http.StatusNotFound {return common.Errorf(common.NotFound, "failed to create file through URL %s", url)} else if code >= 300 {- return errors.Errorf("failed to create file through URL %s, status code: %d, body: %s",+ return errors.Errorf("failed to create file through URL %s, status code: %d, response body: %s",url,code,- body,+ resp,)}return nil@@ -606,7 +606,7 @@ func (p *Provider) OverwriteFile(ctx context.Context, oauthCtx common.OauthConte}url := fmt.Sprintf("%s/projects/%s/repository/files/%s", p.APIURL(instanceURL), repositoryID, url.QueryEscape(filePath))- code, _, _, err := oauth.Put(+ code, _, resp, err := oauth.Put(ctx,p.client,url,@@ -629,10 +629,10 @@ func (p *Provider) OverwriteFile(ctx context.Context, oauthCtx common.OauthConteif code == http.StatusNotFound {return common.Errorf(common.NotFound, "failed to overwrite file through URL %s", url)} else if code >= 300 {- return errors.Errorf("failed to overwrite file through URL %s, status code: %d, body: %s",+ return errors.Errorf("failed to overwrite file through URL %s, status code: %d, response body: %s",url,code,- body,+ resp,)}return nil