Skip to content

Commit

Permalink
Log the blocked request, do not trigger an error
Browse files Browse the repository at this point in the history
  • Loading branch information
dehort committed Sep 19, 2024
1 parent aa00631 commit 8198b50
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions internal/validator/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,18 @@ func (this *handler) onMessage(ctx context.Context, msg *kafka.Message) {
ctx = utils.SetLog(ctx, utils.GetLogFromContext(ctx).With("url", request.URL))
utils.GetLogFromContext(ctx).Debugw("Processing request",
"account", request.Account,
"org_id", request.OrgID,
"topic", *msg.TopicPartition.Topic,
"partition", msg.TopicPartition.Partition,
"offset", msg.TopicPartition.Offset.String(),
"size", request.Size,
)

if utils.IsOrgIdBlocklisted(cfg, request.OrgID) {
utils.GetLogFromContext(ctx).Debugw("Rejecting payload because the org_id is blocklisted")
return
}

if err := this.validateRequest(&request); err != nil {
this.validationFailed(ctx, err, requestType, &request)
return
Expand Down Expand Up @@ -156,10 +162,6 @@ func (this *handler) validateRequest(request *messageModel.IngressValidationRequ
return fmt.Errorf("Rejecting payload due to file size: %d", request.Size)
}

if utils.IsOrgIdBlocklisted(cfg, request.OrgID) {
return fmt.Errorf("Rejecting payload because the org_id is blocklisted: %s", request.OrgID)
}

return
}

Expand Down

0 comments on commit 8198b50

Please sign in to comment.