Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions endpoints/openrtb2/auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,11 @@ func (deps *endpointDeps) Auction(w http.ResponseWriter, r *http.Request, _ http
setBrowsingTopicsHeader(w, r)

req, impExtInfoMap, storedAuctionResponses, storedBidResponses, bidderImpReplaceImp, account, errL := deps.parseRequest(r, &labels, hookExecutor)
if errortypes.ContainsFatalError(errL) && writeError(errL, w, &labels) {
return
if errortypes.ContainsFatalError(errL) {
logBadInputRequest(errL, req)
if writeError(errL, w, &labels) {
return
}
}

if rejectErr := hookexecution.FindFirstRejectOrNil(errL); rejectErr != nil {
Expand Down Expand Up @@ -236,6 +239,7 @@ func (deps *endpointDeps) Auction(w http.ResponseWriter, r *http.Request, _ http
err := deps.setIntegrationType(req, account)
if err != nil {
errL = append(errL, err)
logBadInputRequest(errL, req)
writeError(errL, w, &labels)
return
}
Expand Down Expand Up @@ -281,6 +285,7 @@ func (deps *endpointDeps) Auction(w http.ResponseWriter, r *http.Request, _ http
rejectErr, isRejectErr := hookexecution.CastRejectErr(err)
if err != nil && !isRejectErr {
if errortypes.ReadCode(err) == errortypes.BadInputErrorCode {
logBadInputRequest([]error{err}, req)
writeError([]error{err}, w, &labels)
return
}
Expand Down Expand Up @@ -1927,6 +1932,34 @@ func setDoNotTrackImplicitly(httpReq *http.Request, r *openrtb_ext.RequestWrappe
}
}

// logBadInputRequest logs the request and errors for badinput cases
func logBadInputRequest(errs []error, req *openrtb_ext.RequestWrapper) {
// Check if this is a badinput case (not BlockedApp, AccountDisabled, or MalformedAcct)
isBadInput := true
for _, err := range errs {
erVal := errortypes.ReadCode(err)
if erVal == errortypes.BlockedAppErrorCode || erVal == errortypes.AccountDisabledErrorCode || erVal == errortypes.MalformedAcctErrorCode {
isBadInput = false
break
}
}

if !isBadInput {
return
}

// Log the request and errors for badinput
if req != nil && req.BidRequest != nil {
if reqBytes, marshalErr := jsonutil.Marshal(req.BidRequest); marshalErr == nil {
logger.Errorf("/openrtb2/auction BadInput request: %s, errors: %v", string(reqBytes), errs)
} else {
logger.Errorf("/openrtb2/auction BadInput errors: %v (failed to marshal request: %v)", errs, marshalErr)
}
} else {
logger.Errorf("/openrtb2/auction BadInput errors: %v (request not available)", errs)
}
}

// Write(return) errors to the client, if any. Returns true if errors were found.
func writeError(errs []error, w http.ResponseWriter, labels *metrics.Labels) bool {
var rc bool = false
Expand Down