From f730df37c27f126ef0b69e6f8556feb45d6bd344 Mon Sep 17 00:00:00 2001 From: Dmitry S Date: Wed, 10 Apr 2024 16:26:12 +0200 Subject: [PATCH 01/12] fix issues flagged by golangci-lint The issues flagged by golangci-lint: https://gist.github.com/dmitris/b2b6836f2e90efa2131a74d8c5253ab7 Related to issue #3519. --- account/account.go | 4 +- adapters/adkernelAdn/adkernelAdn.go | 2 +- adapters/adnuntius/adnuntius.go | 6 +- adapters/adtelligent/adtelligent.go | 3 +- adapters/avocet/avocet.go | 1 + adapters/beintoo/beintoo.go | 4 +- adapters/between/between.go | 2 +- .../cadent_aperture_mx/cadentaperturemx.go | 4 +- adapters/connectad/connectad.go | 2 - adapters/consumable/consumable.go | 3 - adapters/dmx/dmx.go | 7 +- adapters/gamma/gamma.go | 7 +- adapters/lemmadigital/lemmadigital.go | 2 + adapters/minutemedia/minutemedia.go | 2 + adapters/rubicon/rubicon.go | 2 +- adapters/smartrtb/smartrtb.go | 6 +- adapters/sovrnXsp/sovrnXsp.go | 6 +- adapters/tappx/tappx.go | 8 +- adapters/tappx/tappx_test.go | 7 +- adapters/yieldlab/yieldlab.go | 12 +-- adapters/yieldmo/yieldmo.go | 2 - adservertargeting/respdataprocessor.go | 5 +- bidadjustment/apply.go | 2 +- config/config.go | 18 ++-- config/events.go | 8 +- endpoints/cookie_sync_test.go | 4 +- endpoints/events/vtrack.go | 14 ++-- endpoints/openrtb2/auction.go | 6 +- exchange/bidder.go | 6 +- exchange/bidder_test.go | 5 +- floors/fetcher_test.go | 1 - main.go | 6 +- openrtb_ext/imp_theadx.go | 4 +- openrtb_ext/request_wrapper.go | 1 - openrtb_ext/request_wrapper_test.go | 1 + .../aspects/request_timeout_handler_test.go | 2 +- server/server_test.go | 2 +- server/ssl/ssl_test.go | 2 +- stored_requests/events/http/http.go | 83 +++++++++---------- stored_responses/stored_responses_test.go | 6 +- 40 files changed, 132 insertions(+), 136 deletions(-) diff --git a/account/account.go b/account/account.go index b40d9a88dc4..418fd90c9ac 100644 --- a/account/account.go +++ b/account/account.go @@ -19,7 +19,7 @@ import ( func GetAccount(ctx context.Context, cfg *config.Configuration, fetcher stored_requests.AccountFetcher, accountID string, me metrics.MetricsEngine) (account *config.Account, errs []error) { if cfg.AccountRequired && accountID == metrics.PublisherUnknown { return nil, []error{&errortypes.AcctRequired{ - Message: fmt.Sprintf("Prebid-server has been configured to discard requests without a valid Account ID. Please reach out to the prebid server host."), + Message: "Prebid-server has been configured to discard requests without a valid Account ID. Please reach out to the prebid server host.", }} } @@ -32,7 +32,7 @@ func GetAccount(ctx context.Context, cfg *config.Configuration, fetcher stored_r } if cfg.AccountRequired && cfg.AccountDefaults.Disabled { errs = append(errs, &errortypes.AcctRequired{ - Message: fmt.Sprintf("Prebid-server could not verify the Account ID. Please reach out to the prebid server host."), + Message: "Prebid-server could not verify the Account ID. Please reach out to the prebid server host.", }) return nil, errs } diff --git a/adapters/adkernelAdn/adkernelAdn.go b/adapters/adkernelAdn/adkernelAdn.go index 00b4c1a23c4..33e5ee93b05 100644 --- a/adapters/adkernelAdn/adkernelAdn.go +++ b/adapters/adkernelAdn/adkernelAdn.go @@ -124,7 +124,7 @@ func compatBannerImpression(imp *openrtb2.Imp) error { //As banner.w/h are required fields for adkernelAdn platform - take the first format entry if banner.W == nil && banner.H == nil { if len(banner.Format) == 0 { - return newBadInputError(fmt.Sprintf("Expected at least one banner.format entry or explicit w/h")) + return newBadInputError("Expected at least one banner.format entry or explicit w/h") } format := banner.Format[0] banner.Format = banner.Format[1:] diff --git a/adapters/adnuntius/adnuntius.go b/adapters/adnuntius/adnuntius.go index 465547dbe72..823c1783144 100644 --- a/adapters/adnuntius/adnuntius.go +++ b/adapters/adnuntius/adnuntius.go @@ -218,7 +218,7 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters }} } - if adnuntiusExt.NoCookies == true { + if adnuntiusExt.NoCookies { noCookies = true } @@ -463,7 +463,7 @@ func generateBidResponse(adnResponse *AdnResponse, request *openrtb2.BidRequest) adBid, err := generateAdResponse(ad, imp, adunit.Html, request) if err != nil { return nil, []error{&errortypes.BadInput{ - Message: fmt.Sprintf("Error at ad generation"), + Message: "Error at ad generation", }} } @@ -476,7 +476,7 @@ func generateBidResponse(adnResponse *AdnResponse, request *openrtb2.BidRequest) dealBid, err := generateAdResponse(deal, imp, deal.Html, request) if err != nil { return nil, []error{&errortypes.BadInput{ - Message: fmt.Sprintf("Error at ad generation"), + Message: "Error at ad generation", }} } diff --git a/adapters/adtelligent/adtelligent.go b/adapters/adtelligent/adtelligent.go index d466c3df191..c1edd895aca 100644 --- a/adapters/adtelligent/adtelligent.go +++ b/adapters/adtelligent/adtelligent.go @@ -172,7 +172,8 @@ func validateImpression(imp *openrtb2.Imp) (int, error) { // common extension for all impressions var impExtBuffer []byte - impExtBuffer, err = json.Marshal(&adtelligentImpExt{ + // TODO: confirm the missing error handling is intended + impExtBuffer, _ /* err */ = json.Marshal(&adtelligentImpExt{ Adtelligent: impExt, }) diff --git a/adapters/avocet/avocet.go b/adapters/avocet/avocet.go index 097370859b3..12e850958dc 100644 --- a/adapters/avocet/avocet.go +++ b/adapters/avocet/avocet.go @@ -86,6 +86,7 @@ func (a *AvocetAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalR if len(br.SeatBid[i].Bid[j].Ext) > 0 { err := json.Unmarshal(br.SeatBid[i].Bid[j].Ext, &ext) if err != nil { + // TODO: find out why we are not using errs errs = append(errs, err) continue } diff --git a/adapters/beintoo/beintoo.go b/adapters/beintoo/beintoo.go index ee16082a750..9a68bb40858 100644 --- a/adapters/beintoo/beintoo.go +++ b/adapters/beintoo/beintoo.go @@ -27,7 +27,7 @@ func (a *BeintooAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada }} } - if errors := preprocess(request); errors != nil && len(errors) > 0 { + if errors := preprocess(request); len(errors) > 0 { return nil, append(errors, &errortypes.BadInput{ Message: fmt.Sprintf("Error in preprocess of Imp, err: %s", errors), }) @@ -133,8 +133,6 @@ func addImpProps(imp *openrtb2.Imp, secure *int8, BeintooExt *openrtb_ext.ExtImp imp.BidFloor = bidFloor } } - - return } // Adding header fields to request header diff --git a/adapters/between/between.go b/adapters/between/between.go index 50c130a7676..4b9deae67ed 100644 --- a/adapters/between/between.go +++ b/adapters/between/between.go @@ -28,7 +28,7 @@ func (a *BetweenAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada }} } ext, errors := preprocess(request) - if errors != nil && len(errors) > 0 { + if len(errors) > 0 { return nil, errors } endpoint, err := a.buildEndpointURL(ext) diff --git a/adapters/cadent_aperture_mx/cadentaperturemx.go b/adapters/cadent_aperture_mx/cadentaperturemx.go index 2a0b3759733..e86cddbe6c4 100644 --- a/adapters/cadent_aperture_mx/cadentaperturemx.go +++ b/adapters/cadent_aperture_mx/cadentaperturemx.go @@ -42,7 +42,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E }} } - if errs := preprocess(request); errs != nil && len(errs) > 0 { + if errs := preprocess(request); len(errs) > 0 { return nil, append(errs, &errortypes.BadInput{ Message: fmt.Sprintf("Error in preprocess of Imp, err: %s", errs), }) @@ -192,8 +192,6 @@ func addImpProps(imp *openrtb2.Imp, secure *int8, cadentExt *openrtb_ext.ExtImpC imp.BidFloorCur = "USD" } } - - return } // Adding header fields to request header diff --git a/adapters/connectad/connectad.go b/adapters/connectad/connectad.go index e71184aec0c..ca681c1b7bb 100644 --- a/adapters/connectad/connectad.go +++ b/adapters/connectad/connectad.go @@ -146,8 +146,6 @@ func addImpInfo(imp *openrtb2.Imp, secure *int8, cadExt *openrtb_ext.ExtImpConne imp.BidFloor = cadExt.Bidfloor imp.BidFloorCur = "USD" } - - return } func addHeaderIfNonEmpty(headers http.Header, headerName string, headerValue string) { diff --git a/adapters/consumable/consumable.go b/adapters/consumable/consumable.go index 17ef90f2acf..1f669f28c74 100644 --- a/adapters/consumable/consumable.go +++ b/adapters/consumable/consumable.go @@ -104,13 +104,10 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R switch bidType { case openrtb_ext.BidTypeAudio: seatBid.Bid[i].MType = openrtb2.MarkupAudio - break case openrtb_ext.BidTypeVideo: seatBid.Bid[i].MType = openrtb2.MarkupVideo - break case openrtb_ext.BidTypeBanner: seatBid.Bid[i].MType = openrtb2.MarkupBanner - break } bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ Bid: &seatBid.Bid[i], diff --git a/adapters/dmx/dmx.go b/adapters/dmx/dmx.go index e35b5562204..000e01c2cfb 100644 --- a/adapters/dmx/dmx.go +++ b/adapters/dmx/dmx.go @@ -103,7 +103,7 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb2.BidRequest, req *adapt if dmxReq.App.ID != "" { anyHasId = true } - if anyHasId == false { + if !anyHasId { if idfa, valid := getIdfa(request); valid { dmxReq.App.ID = idfa anyHasId = true @@ -190,7 +190,7 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb2.BidRequest, req *adapt dmxReq.Imp = imps - if anyHasId == false { + if !anyHasId { return nil, []error{errors.New("This request contained no identifier")} } @@ -264,8 +264,7 @@ func (adapter *DmxAdapter) MakeBids(request *openrtb2.BidRequest, externalReques } func fetchParams(params dmxExt, inst openrtb2.Imp, ins openrtb2.Imp, imps []openrtb2.Imp, banner *openrtb2.Banner, video *openrtb2.Video, intVal int8) []openrtb2.Imp { - var tempimp openrtb2.Imp - tempimp = inst + var tempimp openrtb2.Imp = inst if params.Bidder.Bidfloor != 0 { tempimp.BidFloor = params.Bidder.Bidfloor } diff --git a/adapters/gamma/gamma.go b/adapters/gamma/gamma.go index 631132cc505..0539383a8c5 100644 --- a/adapters/gamma/gamma.go +++ b/adapters/gamma/gamma.go @@ -150,7 +150,7 @@ func (a *GammaAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapt errs = append(errs, err) return nil, errs } - var invalidImpIndex = make([]int, 0, 0) + var invalidImpIndex = make([]int, 0) for i := 0; i < len(request.Imp); i++ { if request.Imp[i].Banner != nil { @@ -182,7 +182,7 @@ func (a *GammaAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapt } else if len(request.Imp) == len(invalidImpIndex) { //only true if every Imp was not a Banner or a Video err := &errortypes.BadInput{ - Message: fmt.Sprintf("No valid impression in the bid request"), + Message: "No valid impression in the bid request", } errs = append(errs, err) return nil, errs @@ -205,8 +205,7 @@ func (a *GammaAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapt } func convertBid(gBid gammaBid, mediaType openrtb_ext.BidType) *openrtb2.Bid { - var bid openrtb2.Bid - bid = gBid.Bid + var bid openrtb2.Bid = gBid.Bid if mediaType == openrtb_ext.BidTypeVideo { //Return inline VAST XML Document (Section 6.4.2) diff --git a/adapters/lemmadigital/lemmadigital.go b/adapters/lemmadigital/lemmadigital.go index 7ff32ba4098..82f301c9d4a 100644 --- a/adapters/lemmadigital/lemmadigital.go +++ b/adapters/lemmadigital/lemmadigital.go @@ -102,6 +102,8 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } bidResponse.Bids = append(bidResponse.Bids, b) } + // golangci-lint staticheck SA4004: the surrounding loop is unconditionally terminated + // TODO: confirm the break is intended and add '// nosemgrep: SA4004' break } diff --git a/adapters/minutemedia/minutemedia.go b/adapters/minutemedia/minutemedia.go index cb5581e5cde..45f7ba6ad39 100644 --- a/adapters/minutemedia/minutemedia.go +++ b/adapters/minutemedia/minutemedia.go @@ -102,6 +102,8 @@ func extractOrg(openRTBRequest *openrtb2.BidRequest) (string, error) { return "", fmt.Errorf("failed to unmarshal ImpExtMinuteMedia: %w", err) } + // golangci-lint staticcheck SA4004: the surrounding loop is unconditionally terminated + // TODO: confirm this is intended and add '// nosemgrep: SA4004' return strings.TrimSpace(impExt.Org), nil } diff --git a/adapters/rubicon/rubicon.go b/adapters/rubicon/rubicon.go index cb968fbe37e..98913051201 100644 --- a/adapters/rubicon/rubicon.go +++ b/adapters/rubicon/rubicon.go @@ -587,7 +587,7 @@ func createImpsToExtMap(imps []openrtb2.Imp) (map[*openrtb2.Imp]rubiconExtImpBid func prepareImpsToExtMap(impsToExtMap map[*openrtb2.Imp]rubiconExtImpBidder) map[*openrtb2.Imp]rubiconExtImpBidder { preparedImpsToExtMap := make(map[*openrtb2.Imp]rubiconExtImpBidder) for imp, bidderExt := range impsToExtMap { - if bidderExt.Bidder.BidOnMultiformat == false { + if !bidderExt.Bidder.BidOnMultiformat { impCopy := imp preparedImpsToExtMap[impCopy] = bidderExt continue diff --git a/adapters/smartrtb/smartrtb.go b/adapters/smartrtb/smartrtb.go index 4e15c5abf34..6b7be6ccf22 100644 --- a/adapters/smartrtb/smartrtb.go +++ b/adapters/smartrtb/smartrtb.go @@ -31,9 +31,9 @@ type bidRequestExt struct { // bidExt.CreativeType values. const ( creativeTypeBanner string = "BANNER" - creativeTypeVideo = "VIDEO" - creativeTypeNative = "NATIVE" - creativeTypeAudio = "AUDIO" + creativeTypeVideo string = "VIDEO" + creativeTypeNative string = "NATIVE" + creativeTypeAudio string = "AUDIO" ) // Bid response extension from downstream. diff --git a/adapters/sovrnXsp/sovrnXsp.go b/adapters/sovrnXsp/sovrnXsp.go index 4b3841638ab..ed97697e824 100644 --- a/adapters/sovrnXsp/sovrnXsp.go +++ b/adapters/sovrnXsp/sovrnXsp.go @@ -20,9 +20,9 @@ type adapter struct { // bidExt.CreativeType values. const ( creativeTypeBanner int = 0 - creativeTypeVideo = 1 - creativeTypeNative = 2 - creativeTypeAudio = 3 + creativeTypeVideo int = 1 + creativeTypeNative int = 2 + creativeTypeAudio int = 3 ) // Bid response extension from XSP. diff --git a/adapters/tappx/tappx.go b/adapters/tappx/tappx.go index 6da9497b36b..57aaa039409 100644 --- a/adapters/tappx/tappx.go +++ b/adapters/tappx/tappx.go @@ -86,8 +86,7 @@ func (a *TappxAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapt }} } - var test int - test = int(request.Test) + test := int(request.Test) url, err := a.buildEndpointURL(&tappxExt, test) if url == "" { @@ -134,6 +133,11 @@ func (a *TappxAdapter) buildEndpointURL(params *openrtb_ext.ExtImpTappx, test in tappxHost := "tappx.com" isNewEndpoint, err := regexp.Match(`^(zz|vz)[0-9]{3,}([a-z]{2,3}|test)$`, []byte(params.Endpoint)) + if err != nil { + return "", &errortypes.BadInput{ + Message: "Unable to match params.Endpoint " + string(params.Endpoint) + "): " + err.Error(), + } + } if isNewEndpoint { tappxHost = params.Endpoint + ".pub.tappx.com/rtb/" } else { diff --git a/adapters/tappx/tappx_test.go b/adapters/tappx/tappx_test.go index b3c6f3fe625..dbbe6e0d28e 100644 --- a/adapters/tappx/tappx_test.go +++ b/adapters/tappx/tappx_test.go @@ -38,13 +38,16 @@ func TestTsValue(t *testing.T) { bidderTappx := bidder.(*TappxAdapter) - var test int - test = 0 + var test int = 0 var tappxExt openrtb_ext.ExtImpTappx tappxExt.Endpoint = "DUMMYENDPOINT" tappxExt.TappxKey = "dummy-tappx-key" url, err := bidderTappx.buildEndpointURL(&tappxExt, test) + if err != nil { + t.Errorf("Error in buildEndpointURL: %s", err.Error()) + return + } match, err := regexp.MatchString(`http://ssp\.api\.tappx\.com/rtb/v2/DUMMYENDPOINT\?tappxkey=dummy-tappx-key&ts=[0-9]{13}&type_cnn=prebid&v=1\.5`, url) if err != nil { diff --git a/adapters/yieldlab/yieldlab.go b/adapters/yieldlab/yieldlab.go index 72041659192..c92abe7597d 100644 --- a/adapters/yieldlab/yieldlab.go +++ b/adapters/yieldlab/yieldlab.go @@ -498,20 +498,20 @@ func makeSupplyChain(openRtbSchain openrtb2.SupplyChain) string { // makeNodeValue converts any known value type from a schain node to a string and does URL encoding if necessary. func makeNodeValue(nodeParam any) string { - switch nodeParam.(type) { + switch nodeParam := nodeParam.(type) { case string: - return url.QueryEscape(nodeParam.(string)) + return url.QueryEscape(nodeParam) case *int8: - pointer := nodeParam.(*int8) + pointer := nodeParam if pointer == nil { return "" } return makeNodeValue(int(*pointer)) case int: - return strconv.Itoa(nodeParam.(int)) + return strconv.Itoa(nodeParam) case json.RawMessage: - if freeFormData := nodeParam.(json.RawMessage); freeFormData != nil { - freeFormJson, err := json.Marshal(freeFormData) + if nodeParam != nil { + freeFormJson, err := json.Marshal(nodeParam) if err != nil { return "" } diff --git a/adapters/yieldmo/yieldmo.go b/adapters/yieldmo/yieldmo.go index f01527cc08c..2b97a64c455 100644 --- a/adapters/yieldmo/yieldmo.go +++ b/adapters/yieldmo/yieldmo.go @@ -35,14 +35,12 @@ type ExtBid struct { } func (a *YieldmoAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { - var errs []error var adapterRequests []*adapters.RequestData adapterReq, errors := a.makeRequest(request) if adapterReq != nil { adapterRequests = append(adapterRequests, adapterReq) } - errs = append(errs, errors...) return adapterRequests, errors } diff --git a/adservertargeting/respdataprocessor.go b/adservertargeting/respdataprocessor.go index 5ec305c1451..cd81765a232 100644 --- a/adservertargeting/respdataprocessor.go +++ b/adservertargeting/respdataprocessor.go @@ -82,13 +82,14 @@ func buildBidExt(targetingData map[string]string, } bidExtTargeting, err := jsonutil.Marshal(bidExtTargetingData) if err != nil { - warnings = append(warnings, createWarning(err.Error())) + // TODO: figure out the intended usage of warnings, here and several lines below + // warnings = append(warnings, createWarning(err.Error())) return nil } newExt, err := jsonpatch.MergePatch(bid.Ext, bidExtTargeting) if err != nil { - warnings = append(warnings, createWarning(err.Error())) + // warnings = append(warnings, createWarning(err.Error())) return nil } return newExt diff --git a/bidadjustment/apply.go b/bidadjustment/apply.go index 16b8305a01a..86bc813dbee 100644 --- a/bidadjustment/apply.go +++ b/bidadjustment/apply.go @@ -21,7 +21,7 @@ const minBid = 0.1 // Apply gets the highest priority adjustment slice given a map of rules, and applies those adjustments to a bid's price func Apply(rules map[string][]openrtb_ext.Adjustment, bidInfo *adapters.TypedBid, bidderName openrtb_ext.BidderName, currency string, reqInfo *adapters.ExtraRequestInfo, bidType string) (float64, string) { - adjustments := []openrtb_ext.Adjustment{} + var adjustments []openrtb_ext.Adjustment if len(rules) > 0 { adjustments = get(rules, bidType, string(bidderName), bidInfo.Bid.DealID) } else { diff --git a/config/config.go b/config/config.go index d2f2103972d..ca88aa21878 100644 --- a/config/config.go +++ b/config/config.go @@ -182,32 +182,32 @@ func (data *ExternalCache) validate(errs []error) []error { } if data.Scheme != "" && data.Scheme != "http" && data.Scheme != "https" { - return append(errs, errors.New("External cache Scheme must be http or https if specified")) + return append(errs, errors.New("external cache Scheme must be http or https if specified")) } // Either host or path or both not empty, validate. if data.Host == "" && data.Path != "" || data.Host != "" && data.Path == "" { - return append(errs, errors.New("External cache Host and Path must both be specified")) + return append(errs, errors.New("external cache Host and Path must both be specified")) } if strings.HasSuffix(data.Host, "/") { - return append(errs, errors.New(fmt.Sprintf("External cache Host '%s' must not end with a path separator", data.Host))) + return append(errs, fmt.Errorf("external cache Host '%s' must not end with a path separator", data.Host)) } if strings.Contains(data.Host, "://") { - return append(errs, errors.New(fmt.Sprintf("External cache Host must not specify a protocol. '%s'", data.Host))) + return append(errs, fmt.Errorf("external cache Host must not specify a protocol. '%s'", data.Host)) } if !strings.HasPrefix(data.Path, "/") { - return append(errs, errors.New(fmt.Sprintf("External cache Path '%s' must begin with a path separator", data.Path))) + return append(errs, fmt.Errorf("external cache Path '%s' must begin with a path separator", data.Path)) } urlObj, err := url.Parse("https://" + data.Host + data.Path) if err != nil { - return append(errs, errors.New(fmt.Sprintf("External cache Path validation error: %s ", err.Error()))) + return append(errs, fmt.Errorf("external cache Path validation error: %s ", err.Error())) } if urlObj.Host != data.Host { - return append(errs, errors.New(fmt.Sprintf("External cache Host '%s' is invalid", data.Host))) + return append(errs, fmt.Errorf("external cache Host '%s' is invalid", data.Host)) } if urlObj.Path != data.Path { - return append(errs, errors.New("External cache Path is invalid")) + return append(errs, fmt.Errorf("external cache Path is invalid")) } return errs @@ -264,7 +264,7 @@ func (cfg *GDPR) validate(v *viper.Viper, errs []error) []error { if cfg.HostVendorID == 0 { glog.Warning("gdpr.host_vendor_id was not specified. Host company GDPR checks will be skipped.") } - if cfg.AMPException == true { + if cfg.AMPException { errs = append(errs, fmt.Errorf("gdpr.amp_exception has been discontinued and must be removed from your config. If you need to disable GDPR for AMP, you may do so per-account (gdpr.integration_enabled.amp) or at the host level for the default account (account_defaults.gdpr.integration_enabled.amp)")) } return cfg.validatePurposes(errs) diff --git a/config/events.go b/config/events.go index cf3139d83ca..c73460e0491 100644 --- a/config/events.go +++ b/config/events.go @@ -82,11 +82,9 @@ func (e Events) validate(errs []error) []error { // validateVASTEvents verifies the all VASTEvent objects and returns error if at least one is invalid. func validateVASTEvents(events []VASTEvent) error { - if events != nil { - for i, event := range events { - if err := event.validate(); err != nil { - return fmt.Errorf(err.Error(), i, i) - } + for i, event := range events { + if err := event.validate(); err != nil { + return fmt.Errorf(err.Error(), i, i) } } return nil diff --git a/endpoints/cookie_sync_test.go b/endpoints/cookie_sync_test.go index 35d7dd4baf5..edd1958fcb0 100644 --- a/endpoints/cookie_sync_test.go +++ b/endpoints/cookie_sync_test.go @@ -2221,8 +2221,8 @@ type FakeAccountsFetcher struct { AccountData map[string]json.RawMessage } -func (f FakeAccountsFetcher) FetchAccount(ctx context.Context, defaultAccountJSON json.RawMessage, accountID string) (json.RawMessage, []error) { - defaultAccountJSON = json.RawMessage(`{"disabled":false}`) +func (f FakeAccountsFetcher) FetchAccount(ctx context.Context, _ json.RawMessage, accountID string) (json.RawMessage, []error) { + defaultAccountJSON := json.RawMessage(`{"disabled":false}`) if accountID == metrics.PublisherUnknown { return defaultAccountJSON, nil diff --git a/endpoints/events/vtrack.go b/endpoints/events/vtrack.go index a2e185f4ba9..459dd0be957 100644 --- a/endpoints/events/vtrack.go +++ b/endpoints/events/vtrack.go @@ -194,12 +194,12 @@ func ParseVTrackRequest(httpRequest *http.Request, maxRequestSize int64) (req *B for _, bcr := range req.Puts { if bcr.BidID == "" { - err = error(&errortypes.BadInput{Message: fmt.Sprint("'bidid' is required field and can't be empty")}) + err = error(&errortypes.BadInput{Message: "'bidid' is required field and can't be empty"}) return req, err } if bcr.Bidder == "" { - err = error(&errortypes.BadInput{Message: fmt.Sprint("'bidder' is required field and can't be empty")}) + err = error(&errortypes.BadInput{Message: "'bidder' is required field and can't be empty"}) return req, err } } @@ -271,12 +271,14 @@ func getBiddersAllowingVastUpdate(req *BidCacheRequest, bidderInfos *config.Bidd // isAllowVastForBidder checks if a bidder is active and allowed to modify vast xml data func isAllowVastForBidder(bidder string, bidderInfos *config.BidderInfos, allowUnknownBidder bool, normalizeBidderName normalizeBidderName) bool { - //if bidder is active and isModifyingVastXmlAllowed is true + // if bidder is active and isModifyingVastXmlAllowed is true // check if bidder is configured if normalizedBidder, ok := normalizeBidderName(bidder); ok { - if b, ok := (*bidderInfos)[normalizedBidder.String()]; bidderInfos != nil && ok { - // check if bidder is enabled - return b.IsEnabled() && b.ModifyingVastXmlAllowed + if bidderInfos != nil { + if b, ok := (*bidderInfos)[normalizedBidder.String()]; ok { + // check if bidder is enabled + return b.IsEnabled() && b.ModifyingVastXmlAllowed + } } } diff --git a/endpoints/openrtb2/auction.go b/endpoints/openrtb2/auction.go index 4f014b963d1..71c6103dee7 100644 --- a/endpoints/openrtb2/auction.go +++ b/endpoints/openrtb2/auction.go @@ -2319,9 +2319,11 @@ func (deps *endpointDeps) processStoredRequests(requestJson []byte, impInfo []Im // parseImpInfo parses the request JSON and returns impression and unmarshalled imp.ext.prebid func parseImpInfo(requestJson []byte) (impData []ImpExtPrebidData, errs []error) { + // ignore the error such as '&errors.errorString{s:"Unknown value type"}' if impArray, dataType, _, err := jsonparser.Get(requestJson, "imp"); err == nil && dataType == jsonparser.Array { - _, err = jsonparser.ArrayEach(impArray, func(imp []byte, _ jsonparser.ValueType, _ int, err error) { - impExtData, _, _, err := jsonparser.Get(imp, "ext", "prebid") + _, _ = jsonparser.ArrayEach(impArray, func(imp []byte, _ jsonparser.ValueType, _ int, _ error) { + // ignore possible errors if there is no ext.prebid key + impExtData, _, _, _ := jsonparser.Get(imp, "ext", "prebid") var impExtPrebid openrtb_ext.ExtImpPrebid if impExtData != nil { if err := jsonutil.Unmarshal(impExtData, &impExtPrebid); err != nil { diff --git a/exchange/bidder.go b/exchange/bidder.go index 8b54f9847bb..deb90d801e0 100644 --- a/exchange/bidder.go +++ b/exchange/bidder.go @@ -669,7 +669,7 @@ func (bidder *bidderAdapter) addClientTrace(ctx context.Context) context.Context }, // GotConn is called after a successful connection is obtained GotConn: func(info httptrace.GotConnInfo) { - connWaitTime := time.Now().Sub(connStart) + connWaitTime := time.Since(connStart) bidder.me.RecordAdapterConnections(bidder.BidderName, info.Reused, connWaitTime) }, @@ -679,7 +679,7 @@ func (bidder *bidderAdapter) addClientTrace(ctx context.Context) context.Context }, // DNSDone is called when a DNS lookup ends. DNSDone: func(info httptrace.DNSDoneInfo) { - dnsLookupTime := time.Now().Sub(dnsStart) + dnsLookupTime := time.Since(dnsStart) bidder.me.RecordDNSTime(dnsLookupTime) }, @@ -689,7 +689,7 @@ func (bidder *bidderAdapter) addClientTrace(ctx context.Context) context.Context }, TLSHandshakeDone: func(tls.ConnectionState, error) { - tlsHandshakeTime := time.Now().Sub(tlsStart) + tlsHandshakeTime := time.Since(tlsStart) bidder.me.RecordTLSHandshakeTime(tlsHandshakeTime) }, diff --git a/exchange/bidder_test.go b/exchange/bidder_test.go index 9f092b7dea3..76ffe95d6ce 100644 --- a/exchange/bidder_test.go +++ b/exchange/bidder_test.go @@ -2414,10 +2414,7 @@ type goodMultiHTTPCallsBidder struct { func (bidder *goodMultiHTTPCallsBidder) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { bidder.bidRequest = request response := make([]*adapters.RequestData, len(bidder.httpRequest)) - - for i, r := range bidder.httpRequest { - response[i] = r - } + copy(response, bidder.httpRequest) return response, nil } diff --git a/floors/fetcher_test.go b/floors/fetcher_test.go index cdf0537c9ed..c6da623e5c5 100644 --- a/floors/fetcher_test.go +++ b/floors/fetcher_test.go @@ -1219,7 +1219,6 @@ func TestPriceFloorFetcherSubmitFailed(t *testing.T) { } func getRandomNumber() int { - rand.Seed(time.Now().UnixNano()) min := 1 max := 10 return rand.Intn(max-min+1) + min diff --git a/main.go b/main.go index 1909199d1e9..f517749e7ad 100644 --- a/main.go +++ b/main.go @@ -2,7 +2,6 @@ package main import ( "flag" - "math/rand" "net/http" "path/filepath" "runtime" @@ -22,7 +21,6 @@ import ( ) func init() { - rand.Seed(time.Now().UnixNano()) jsoniter.RegisterExtension(&jsonutil.RawMessageExtension{}) } @@ -80,7 +78,9 @@ func serve(cfg *config.Configuration) error { } corsRouter := router.SupportCORS(r) - server.Listen(cfg, router.NoCache{Handler: corsRouter}, router.Admin(currencyConverter, fetchingInterval), r.MetricsEngine) + if err := server.Listen(cfg, router.NoCache{Handler: corsRouter}, router.Admin(currencyConverter, fetchingInterval), r.MetricsEngine); err != nil { + glog.Errorf("prebid-server returned an error: %v", err) + } r.Shutdown() return nil diff --git a/openrtb_ext/imp_theadx.go b/openrtb_ext/imp_theadx.go index bee3ac6088a..9910aeccd53 100644 --- a/openrtb_ext/imp_theadx.go +++ b/openrtb_ext/imp_theadx.go @@ -7,6 +7,6 @@ import ( type ExtImpTheadx struct { TagID json.Number `json:"tagid"` InventorySourceID int `json:"wid,omitempty"` - MemberID int `json:"pid,optional,omitempty"` - PlacementName string `json:"pname,optional,omitempty"` + MemberID int `json:"pid,omitempty"` + PlacementName string `json:"pname,omitempty"` } diff --git a/openrtb_ext/request_wrapper.go b/openrtb_ext/request_wrapper.go index 4c4eb9a6988..3567625a53b 100644 --- a/openrtb_ext/request_wrapper.go +++ b/openrtb_ext/request_wrapper.go @@ -649,7 +649,6 @@ func (ue *UserExt) SetConsentedProvidersSettingsOut(cpSettings *ConsentedProvide ue.consentedProvidersSettingsOut = cpSettings ue.consentedProvidersSettingsOutDirty = true - return } func (ue *UserExt) GetPrebid() *ExtUserPrebid { diff --git a/openrtb_ext/request_wrapper_test.go b/openrtb_ext/request_wrapper_test.go index ffa925e46ac..5a101e47cd1 100644 --- a/openrtb_ext/request_wrapper_test.go +++ b/openrtb_ext/request_wrapper_test.go @@ -706,6 +706,7 @@ func TestCloneUserExt(t *testing.T) { eids[1].UIDs[0].AType = 0 eids[0].UIDs = append(eids[0].UIDs, openrtb2.UID{ID: "Z", AType: 2}) eids = append(eids, openrtb2.EID{Source: "Blank"}) + // TODO: double-check why we fill eids but don't use it userExt.eids = nil }, }, diff --git a/router/aspects/request_timeout_handler_test.go b/router/aspects/request_timeout_handler_test.go index f77d48aa6e6..0d6f2cf8114 100644 --- a/router/aspects/request_timeout_handler_test.go +++ b/router/aspects/request_timeout_handler_test.go @@ -78,7 +78,7 @@ func TestAny(t *testing.T) { reqTimeFloat, _ := strconv.ParseFloat(test.reqTimeInQueue, 64) result := ExecuteAspectRequest(t, test.reqTimeInQueue, test.reqTimeOut, test.setHeaders, metrics.ReqTypeVideo, test.requestStatusMetrics, reqTimeFloat) assert.Equal(t, test.expectedRespCode, result.Code, test.expectedRespCodeMessage) - assert.Equal(t, test.expectedRespBody, string(result.Body.Bytes()), test.expectedRespBodyMessage) + assert.Equal(t, test.expectedRespBody, result.Body.String(), test.expectedRespBodyMessage) } } diff --git a/server/server_test.go b/server/server_test.go index 03a2fc911b5..5978d4a3ffb 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -75,7 +75,7 @@ func TestNewSocketServer(t *testing.T) { ret := newSocketServer(cfg, nil) assert.NotEqual(t, nil, ret, "ret : isNil()") assert.Equal(t, mockServer.Addr, ret.Addr, fmt.Sprintf("Addr invalide: %v != %v", - ret.Addr, mockServer.Addr)) + ret.Addr, mockServer.Addr)) //nolint:staticcheck // non-nil ret is ensures by the assert above assert.Equal(t, mockServer.ReadTimeout, ret.ReadTimeout, fmt.Sprintf("ReadTimeout invalide: %v != %v", ret.ReadTimeout, mockServer.ReadTimeout)) assert.Equal(t, mockServer.WriteTimeout, ret.WriteTimeout, fmt.Sprintf("WriteTimeout invalide: %v != %v", diff --git a/server/ssl/ssl_test.go b/server/ssl/ssl_test.go index b72fb7ae9a3..e6abdbdcfa7 100644 --- a/server/ssl/ssl_test.go +++ b/server/ssl/ssl_test.go @@ -47,7 +47,7 @@ func TestAppendPEMFileToRootCAPoolFail(t *testing.T) { // In this test we are going to pass a file that does not exist as value of second argument fakeCertificatesFile := "mockcertificates/NO-FILE.pem" - certPool, err := AppendPEMFileToRootCAPool(certPool, fakeCertificatesFile) + _, err := AppendPEMFileToRootCAPool(certPool, fakeCertificatesFile) // Assert AppendPEMFileToRootCAPool correctly throws an error when trying to load an nonexisting file assert.Errorf(t, err, "AppendPEMFileToRootCAPool should throw an error by while loading fake file %s \n", fakeCertificatesFile) diff --git a/stored_requests/events/http/http.go b/stored_requests/events/http/http.go index 6c2145da2f3..0f5dfb9a596 100644 --- a/stored_requests/events/http/http.go +++ b/stored_requests/events/http/http.go @@ -109,58 +109,55 @@ func (e *HTTPEvents) fetchAll() { } func (e *HTTPEvents) refresh(ticker <-chan time.Time) { - for { - select { - case thisTime := <-ticker: - thisTimeInUTC := thisTime.UTC() - - // Parse the endpoint url defined - endpointUrl, urlErr := url.Parse(e.Endpoint) - - // Error with url parsing - if urlErr != nil { - glog.Errorf("Disabling refresh HTTP cache from GET '%s': %v", e.Endpoint, urlErr) - return - } + for thisTime := range ticker { + thisTimeInUTC := thisTime.UTC() - // Parse the url query string - urlQuery := endpointUrl.Query() + // Parse the endpoint url defined + endpointUrl, urlErr := url.Parse(e.Endpoint) - // See the last-modified query param - urlQuery.Set("last-modified", e.lastUpdate.Format(time.RFC3339)) + // Error with url parsing + if urlErr != nil { + glog.Errorf("Disabling refresh HTTP cache from GET '%s': %v", e.Endpoint, urlErr) + return + } - // Rebuild - endpointUrl.RawQuery = urlQuery.Encode() + // Parse the url query string + urlQuery := endpointUrl.Query() - // Convert to string - endpoint := endpointUrl.String() + // See the last-modified query param + urlQuery.Set("last-modified", e.lastUpdate.Format(time.RFC3339)) - glog.Infof("Refreshing HTTP cache from GET '%s'", endpoint) + // Rebuild + endpointUrl.RawQuery = urlQuery.Encode() - ctx, cancel := e.ctxProducer() - resp, err := ctxhttp.Get(ctx, e.client, endpoint) - if respObj, ok := e.parse(endpoint, resp, err); ok { - invalidations := events.Invalidation{ - Requests: extractInvalidations(respObj.StoredRequests), - Imps: extractInvalidations(respObj.StoredImps), - Responses: extractInvalidations(respObj.StoredResponses), - Accounts: extractInvalidations(respObj.Accounts), - } - if len(respObj.StoredRequests) > 0 || len(respObj.StoredImps) > 0 || len(respObj.StoredResponses) > 0 || len(respObj.Accounts) > 0 { - e.saves <- events.Save{ - Requests: respObj.StoredRequests, - Imps: respObj.StoredImps, - Responses: respObj.StoredResponses, - Accounts: respObj.Accounts, - } - } - if len(invalidations.Requests) > 0 || len(invalidations.Imps) > 0 || len(invalidations.Responses) > 0 || len(invalidations.Accounts) > 0 { - e.invalidations <- invalidations + // Convert to string + endpoint := endpointUrl.String() + + glog.Infof("Refreshing HTTP cache from GET '%s'", endpoint) + + ctx, cancel := e.ctxProducer() + resp, err := ctxhttp.Get(ctx, e.client, endpoint) + if respObj, ok := e.parse(endpoint, resp, err); ok { + invalidations := events.Invalidation{ + Requests: extractInvalidations(respObj.StoredRequests), + Imps: extractInvalidations(respObj.StoredImps), + Responses: extractInvalidations(respObj.StoredResponses), + Accounts: extractInvalidations(respObj.Accounts), + } + if len(respObj.StoredRequests) > 0 || len(respObj.StoredImps) > 0 || len(respObj.StoredResponses) > 0 || len(respObj.Accounts) > 0 { + e.saves <- events.Save{ + Requests: respObj.StoredRequests, + Imps: respObj.StoredImps, + Responses: respObj.StoredResponses, + Accounts: respObj.Accounts, } - e.lastUpdate = thisTimeInUTC } - cancel() + if len(invalidations.Requests) > 0 || len(invalidations.Imps) > 0 || len(invalidations.Responses) > 0 || len(invalidations.Accounts) > 0 { + e.invalidations <- invalidations + } + e.lastUpdate = thisTimeInUTC } + cancel() } } diff --git a/stored_responses/stored_responses_test.go b/stored_responses/stored_responses_test.go index 49ce19d3414..58bba22aae8 100644 --- a/stored_responses/stored_responses_test.go +++ b/stored_responses/stored_responses_test.go @@ -258,7 +258,7 @@ func TestProcessStoredAuctionAndBidResponsesErrors(t *testing.T) { for _, test := range testCases { t.Run(test.description, func(t *testing.T) { rw := &openrtb_ext.RequestWrapper{BidRequest: &test.request} - _, _, _, errorList := ProcessStoredResponses(nil, rw, nil) + _, _, _, errorList := ProcessStoredResponses(context.TODO(), rw, nil) assert.Equalf(t, test.expectedErrorList, errorList, "Error doesn't match: %s\n", test.description) }) } @@ -663,7 +663,7 @@ func TestProcessStoredAuctionAndBidResponses(t *testing.T) { for _, test := range testCases { t.Run(test.description, func(t *testing.T) { rw := openrtb_ext.RequestWrapper{BidRequest: &test.request} - storedAuctionResponses, storedBidResponses, bidderImpReplaceImpId, errorList := ProcessStoredResponses(nil, &rw, fetcher) + storedAuctionResponses, storedBidResponses, bidderImpReplaceImpId, errorList := ProcessStoredResponses(context.TODO(), &rw, fetcher) assert.Equal(t, test.expectedStoredAuctionResponses, storedAuctionResponses) assert.Equal(t, test.expectedStoredBidResponses, storedBidResponses) assert.Equal(t, test.expectedBidderImpReplaceImpID, bidderImpReplaceImpId) @@ -866,7 +866,7 @@ func TestProcessStoredResponsesNotFoundResponse(t *testing.T) { for _, test := range testCases { t.Run(test.description, func(t *testing.T) { rw := openrtb_ext.RequestWrapper{BidRequest: &test.request} - _, _, _, errorList := ProcessStoredResponses(nil, &rw, fetcher) + _, _, _, errorList := ProcessStoredResponses(context.TODO(), &rw, fetcher) for _, err := range test.expectedErrors { assert.Contains(t, errorList, err) } From 45876edaef7e1a461578ebfcc7ff41adfa791766 Mon Sep 17 00:00:00 2001 From: Dmitry S Date: Wed, 17 Apr 2024 12:01:44 +0200 Subject: [PATCH 02/12] handle error in adtelligent.go --- adapters/adtelligent/adtelligent.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/adapters/adtelligent/adtelligent.go b/adapters/adtelligent/adtelligent.go index c1edd895aca..492de0a364b 100644 --- a/adapters/adtelligent/adtelligent.go +++ b/adapters/adtelligent/adtelligent.go @@ -172,10 +172,14 @@ func validateImpression(imp *openrtb2.Imp) (int, error) { // common extension for all impressions var impExtBuffer []byte - // TODO: confirm the missing error handling is intended - impExtBuffer, _ /* err */ = json.Marshal(&adtelligentImpExt{ + impExtBuffer, err = json.Marshal(&adtelligentImpExt{ Adtelligent: impExt, }) + if err != nil { + return 0, &errortypes.BadInput{ + Message: fmt.Sprintf("ignoring imp id=%s, error while marshaling impExt, err: %s", imp.ID, err), + } + } if impExt.BidFloor > 0 { imp.BidFloor = impExt.BidFloor From ea9ea984f04e047bed7d8d0dcf95347cc90b081e Mon Sep 17 00:00:00 2001 From: Dmitry S Date: Wed, 17 Apr 2024 12:15:25 +0200 Subject: [PATCH 03/12] handle errors in AvocetAdapter.MakeBids --- adapters/avocet/avocet.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/adapters/avocet/avocet.go b/adapters/avocet/avocet.go index 12e850958dc..76ce8195219 100644 --- a/adapters/avocet/avocet.go +++ b/adapters/avocet/avocet.go @@ -86,7 +86,6 @@ func (a *AvocetAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalR if len(br.SeatBid[i].Bid[j].Ext) > 0 { err := json.Unmarshal(br.SeatBid[i].Bid[j].Ext, &ext) if err != nil { - // TODO: find out why we are not using errs errs = append(errs, err) continue } @@ -104,6 +103,9 @@ func (a *AvocetAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalR bidResponse.Bids = append(bidResponse.Bids, tbid) } } + if len(errs) > 0 { + return nil, errs + } return bidResponse, nil } From cc910896f1f177b990ca76f454623d0d63a415ae Mon Sep 17 00:00:00 2001 From: Dmitry S Date: Wed, 17 Apr 2024 12:30:22 +0200 Subject: [PATCH 04/12] dmx adapter: change anyHasId flag to hasNoID --- adapters/dmx/dmx.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/adapters/dmx/dmx.go b/adapters/dmx/dmx.go index 000e01c2cfb..85e6070b7ae 100644 --- a/adapters/dmx/dmx.go +++ b/adapters/dmx/dmx.go @@ -64,7 +64,6 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb2.BidRequest, req *adapt var publisherId string var sellerId string var userExt openrtb_ext.ExtUser - var anyHasId = false var reqCopy openrtb2.BidRequest = *request var dmxReq *openrtb2.BidRequest = &reqCopy var dmxRawPubId dmxPubExt @@ -85,6 +84,7 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb2.BidRequest, req *adapt } } + hasNoID := true if request.App != nil { appCopy := *request.App appPublisherCopy := *request.App.Publisher @@ -101,12 +101,12 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb2.BidRequest, req *adapt } dmxReq.App.Publisher.Ext = ext if dmxReq.App.ID != "" { - anyHasId = true + hasNoID = false } - if !anyHasId { + if hasNoID { if idfa, valid := getIdfa(request); valid { dmxReq.App.ID = idfa - anyHasId = true + hasNoID = false } } } else { @@ -145,12 +145,12 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb2.BidRequest, req *adapt if dmxReq.User != nil { if dmxReq.User.ID != "" { - anyHasId = true + hasNoID = false } if dmxReq.User.Ext != nil { if err := json.Unmarshal(dmxReq.User.Ext, &userExt); err == nil { if len(userExt.Eids) > 0 { - anyHasId = true + hasNoID = false } } } @@ -190,7 +190,7 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb2.BidRequest, req *adapt dmxReq.Imp = imps - if !anyHasId { + if hasNoID { return nil, []error{errors.New("This request contained no identifier")} } @@ -264,7 +264,7 @@ func (adapter *DmxAdapter) MakeBids(request *openrtb2.BidRequest, externalReques } func fetchParams(params dmxExt, inst openrtb2.Imp, ins openrtb2.Imp, imps []openrtb2.Imp, banner *openrtb2.Banner, video *openrtb2.Video, intVal int8) []openrtb2.Imp { - var tempimp openrtb2.Imp = inst + tempimp := inst if params.Bidder.Bidfloor != 0 { tempimp.BidFloor = params.Bidder.Bidfloor } From ce3d56d821df8a9f8a7a144c37f35bbc1b3f3f6e Mon Sep 17 00:00:00 2001 From: Dmitry S Date: Wed, 17 Apr 2024 16:13:28 +0200 Subject: [PATCH 05/12] address PR feedback --- adapters/gamma/gamma.go | 2 +- adapters/lemmadigital/lemmadigital.go | 4 +--- adapters/rubicon/rubicon.go | 2 +- adapters/smartrtb/smartrtb.go | 7 ++++--- adapters/tappx/tappx_test.go | 5 +++-- adservertargeting/respdataprocessor.go | 5 ++--- config/config.go | 2 +- endpoints/events/vtrack.go | 1 - floors/fetcher_test.go | 2 ++ main.go | 2 +- server/server_test.go | 26 ++++++++++++-------------- 11 files changed, 28 insertions(+), 30 deletions(-) diff --git a/adapters/gamma/gamma.go b/adapters/gamma/gamma.go index 0539383a8c5..c8e93389a00 100644 --- a/adapters/gamma/gamma.go +++ b/adapters/gamma/gamma.go @@ -205,7 +205,7 @@ func (a *GammaAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapt } func convertBid(gBid gammaBid, mediaType openrtb_ext.BidType) *openrtb2.Bid { - var bid openrtb2.Bid = gBid.Bid + bid := gBid.Bid if mediaType == openrtb_ext.BidTypeVideo { //Return inline VAST XML Document (Section 6.4.2) diff --git a/adapters/lemmadigital/lemmadigital.go b/adapters/lemmadigital/lemmadigital.go index 82f301c9d4a..1a01fac026b 100644 --- a/adapters/lemmadigital/lemmadigital.go +++ b/adapters/lemmadigital/lemmadigital.go @@ -102,9 +102,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } bidResponse.Bids = append(bidResponse.Bids, b) } - // golangci-lint staticheck SA4004: the surrounding loop is unconditionally terminated - // TODO: confirm the break is intended and add '// nosemgrep: SA4004' - break + break //nolint: staticcheck // break is intended, exempt from staticcheck SA4004 } return bidResponse, nil diff --git a/adapters/rubicon/rubicon.go b/adapters/rubicon/rubicon.go index 98913051201..a12d2fc730a 100644 --- a/adapters/rubicon/rubicon.go +++ b/adapters/rubicon/rubicon.go @@ -587,7 +587,7 @@ func createImpsToExtMap(imps []openrtb2.Imp) (map[*openrtb2.Imp]rubiconExtImpBid func prepareImpsToExtMap(impsToExtMap map[*openrtb2.Imp]rubiconExtImpBidder) map[*openrtb2.Imp]rubiconExtImpBidder { preparedImpsToExtMap := make(map[*openrtb2.Imp]rubiconExtImpBidder) for imp, bidderExt := range impsToExtMap { - if !bidderExt.Bidder.BidOnMultiformat { + if bidderExt.Bidder.BidOnMultiformat == false { //nolint: staticcheck impCopy := imp preparedImpsToExtMap[impCopy] = bidderExt continue diff --git a/adapters/smartrtb/smartrtb.go b/adapters/smartrtb/smartrtb.go index 6b7be6ccf22..1c5d1abb1de 100644 --- a/adapters/smartrtb/smartrtb.go +++ b/adapters/smartrtb/smartrtb.go @@ -29,11 +29,12 @@ type bidRequestExt struct { } // bidExt.CreativeType values. +// nolint: staticcheck // staticcheck SA9004: only the first constant in this group has an explicit type const ( creativeTypeBanner string = "BANNER" - creativeTypeVideo string = "VIDEO" - creativeTypeNative string = "NATIVE" - creativeTypeAudio string = "AUDIO" + creativeTypeVideo = "VIDEO" + creativeTypeNative = "NATIVE" + creativeTypeAudio = "AUDIO" ) // Bid response extension from downstream. diff --git a/adapters/tappx/tappx_test.go b/adapters/tappx/tappx_test.go index dbbe6e0d28e..c68bed2ca28 100644 --- a/adapters/tappx/tappx_test.go +++ b/adapters/tappx/tappx_test.go @@ -8,6 +8,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/openrtb_ext" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestJsonSamples(t *testing.T) { @@ -38,14 +39,14 @@ func TestTsValue(t *testing.T) { bidderTappx := bidder.(*TappxAdapter) - var test int = 0 + test := 0 var tappxExt openrtb_ext.ExtImpTappx tappxExt.Endpoint = "DUMMYENDPOINT" tappxExt.TappxKey = "dummy-tappx-key" url, err := bidderTappx.buildEndpointURL(&tappxExt, test) if err != nil { - t.Errorf("Error in buildEndpointURL: %s", err.Error()) + require.NoError(t, err, "buildEndpointURL") return } diff --git a/adservertargeting/respdataprocessor.go b/adservertargeting/respdataprocessor.go index cd81765a232..51bad207337 100644 --- a/adservertargeting/respdataprocessor.go +++ b/adservertargeting/respdataprocessor.go @@ -82,14 +82,13 @@ func buildBidExt(targetingData map[string]string, } bidExtTargeting, err := jsonutil.Marshal(bidExtTargetingData) if err != nil { - // TODO: figure out the intended usage of warnings, here and several lines below - // warnings = append(warnings, createWarning(err.Error())) + warnings = append(warnings, createWarning(err.Error())) //nolint: ineffassign,staticcheck return nil } newExt, err := jsonpatch.MergePatch(bid.Ext, bidExtTargeting) if err != nil { - // warnings = append(warnings, createWarning(err.Error())) + warnings = append(warnings, createWarning(err.Error())) //nolint: ineffassign,staticcheck return nil } return newExt diff --git a/config/config.go b/config/config.go index ca88aa21878..a28d24874f8 100644 --- a/config/config.go +++ b/config/config.go @@ -182,7 +182,7 @@ func (data *ExternalCache) validate(errs []error) []error { } if data.Scheme != "" && data.Scheme != "http" && data.Scheme != "https" { - return append(errs, errors.New("external cache Scheme must be http or https if specified")) + return append(errs, errors.New("External cache Scheme must be http or https if specified")) } // Either host or path or both not empty, validate. diff --git a/endpoints/events/vtrack.go b/endpoints/events/vtrack.go index 459dd0be957..01e544a4e80 100644 --- a/endpoints/events/vtrack.go +++ b/endpoints/events/vtrack.go @@ -276,7 +276,6 @@ func isAllowVastForBidder(bidder string, bidderInfos *config.BidderInfos, allowU if normalizedBidder, ok := normalizeBidderName(bidder); ok { if bidderInfos != nil { if b, ok := (*bidderInfos)[normalizedBidder.String()]; ok { - // check if bidder is enabled return b.IsEnabled() && b.ModifyingVastXmlAllowed } } diff --git a/floors/fetcher_test.go b/floors/fetcher_test.go index c6da623e5c5..499c9312302 100644 --- a/floors/fetcher_test.go +++ b/floors/fetcher_test.go @@ -1219,6 +1219,8 @@ func TestPriceFloorFetcherSubmitFailed(t *testing.T) { } func getRandomNumber() int { + //nolint: staticcheck // SA1019: rand.Seed has been deprecated since Go 1.20 and an alternative has been available since Go 1.0: As of Go 1.20 there is no reason to call Seed with a random value. + rand.Seed(time.Now().UnixNano()) min := 1 max := 10 return rand.Intn(max-min+1) + min diff --git a/main.go b/main.go index f517749e7ad..4ef96b34724 100644 --- a/main.go +++ b/main.go @@ -79,7 +79,7 @@ func serve(cfg *config.Configuration) error { corsRouter := router.SupportCORS(r) if err := server.Listen(cfg, router.NoCache{Handler: corsRouter}, router.Admin(currencyConverter, fetchingInterval), r.MetricsEngine); err != nil { - glog.Errorf("prebid-server returned an error: %v", err) + glog.Fatalf("prebid-server returned an error: %v", err) } r.Shutdown() diff --git a/server/server_test.go b/server/server_test.go index 5978d4a3ffb..66d42fd4919 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/config" metricsconfig "github.com/prebid/prebid-server/v2/metrics/config" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestServerShutdown(t *testing.T) { @@ -21,7 +22,7 @@ func TestServerShutdown(t *testing.T) { stopper := make(chan os.Signal) done := make(chan struct{}) go shutdownAfterSignals(server, stopper, done) - go server.Serve(ln) + go server.Serve(ln) //nolint: errcheck stopper <- os.Interrupt <-done @@ -73,17 +74,16 @@ func TestNewSocketServer(t *testing.T) { } ret := newSocketServer(cfg, nil) - assert.NotEqual(t, nil, ret, "ret : isNil()") + require.NotNil(t, ret, "ret : isNil()") + assert.Equal(t, mockServer.Addr, ret.Addr, fmt.Sprintf("Addr invalide: %v != %v", - ret.Addr, mockServer.Addr)) //nolint:staticcheck // non-nil ret is ensures by the assert above + ret.Addr, mockServer.Addr)) assert.Equal(t, mockServer.ReadTimeout, ret.ReadTimeout, fmt.Sprintf("ReadTimeout invalide: %v != %v", ret.ReadTimeout, mockServer.ReadTimeout)) assert.Equal(t, mockServer.WriteTimeout, ret.WriteTimeout, fmt.Sprintf("WriteTimeout invalide: %v != %v", ret.WriteTimeout, mockServer.WriteTimeout)) - if ret != nil { - ret.Close() - } + ret.Close() } func TestNewMainServer(t *testing.T) { @@ -103,7 +103,8 @@ func TestNewMainServer(t *testing.T) { } ret := newMainServer(cfg, nil) - assert.NotEqual(t, nil, ret, "ret : isNil()") + require.NotNil(t, ret, "ret : isNil()") + assert.Equal(t, ret.Addr, mockServer.Addr, fmt.Sprintf("Addr invalide: %v != %v", ret.Addr, mockServer.Addr)) assert.Equal(t, ret.ReadTimeout, mockServer.ReadTimeout, @@ -111,9 +112,7 @@ func TestNewMainServer(t *testing.T) { assert.Equal(t, ret.WriteTimeout, mockServer.WriteTimeout, fmt.Sprintf("WriteTimeout invalide: %v != %v", ret.WriteTimeout, mockServer.WriteTimeout)) - if ret != nil { - ret.Close() - } + ret.Close() } func TestNewTCPListener(t *testing.T) { @@ -155,13 +154,11 @@ func TestNewAdminServer(t *testing.T) { } ret := newAdminServer(cfg, nil) - assert.NotEqual(t, nil, ret, "ret : isNil()") + require.NotNil(t, ret, "ret : isNil()") assert.Equal(t, mockServer.Addr, ret.Addr, fmt.Sprintf("Addr invalide: %v != %v", ret.Addr, mockServer.Addr)) - if ret != nil { - ret.Close() - } + ret.Close() } func TestRunServer(t *testing.T) { @@ -181,6 +178,7 @@ func TestRunServer(t *testing.T) { } func TestListen(t *testing.T) { + // TODO(dmitris): check if the unused const 'name' can be deleted [PR3621] const name = "TestListen" var ( handler, adminHandler http.Handler From 4bd9b241a6731665df1b218d271fba075e961b34 Mon Sep 17 00:00:00 2001 From: Dmitry Savintsev Date: Wed, 17 Apr 2024 17:47:25 +0200 Subject: [PATCH 06/12] gamma.go invalidImpIndex var declaration --- adapters/gamma/gamma.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapters/gamma/gamma.go b/adapters/gamma/gamma.go index c8e93389a00..8e14331b465 100644 --- a/adapters/gamma/gamma.go +++ b/adapters/gamma/gamma.go @@ -150,7 +150,7 @@ func (a *GammaAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapt errs = append(errs, err) return nil, errs } - var invalidImpIndex = make([]int, 0) + var invalidImpIndex []int for i := 0; i < len(request.Imp); i++ { if request.Imp[i].Banner != nil { From 3d2f8c6a76581d1617fefbea84b99445a6446e06 Mon Sep 17 00:00:00 2001 From: Dmitry Savintsev Date: Mon, 22 Apr 2024 22:09:34 +0200 Subject: [PATCH 07/12] add nolint: staticcheck for early loop termination --- adapters/minutemedia/minutemedia.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/adapters/minutemedia/minutemedia.go b/adapters/minutemedia/minutemedia.go index 45f7ba6ad39..0ce67bbfb72 100644 --- a/adapters/minutemedia/minutemedia.go +++ b/adapters/minutemedia/minutemedia.go @@ -102,8 +102,7 @@ func extractOrg(openRTBRequest *openrtb2.BidRequest) (string, error) { return "", fmt.Errorf("failed to unmarshal ImpExtMinuteMedia: %w", err) } - // golangci-lint staticcheck SA4004: the surrounding loop is unconditionally terminated - // TODO: confirm this is intended and add '// nosemgrep: SA4004' + //nolint: staticcheck // SA4004: the surrounding loop is unconditionally terminated return strings.TrimSpace(impExt.Org), nil } From bbd2b68fc658c8890cb161f2e07e4d4179bc1071 Mon Sep 17 00:00:00 2001 From: Dmitry S Date: Thu, 25 Apr 2024 16:53:33 +0200 Subject: [PATCH 08/12] rename tempimp var to camelCase - tempImp --- adapters/dmx/dmx.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/adapters/dmx/dmx.go b/adapters/dmx/dmx.go index 85e6070b7ae..f080ca8ee44 100644 --- a/adapters/dmx/dmx.go +++ b/adapters/dmx/dmx.go @@ -264,36 +264,36 @@ func (adapter *DmxAdapter) MakeBids(request *openrtb2.BidRequest, externalReques } func fetchParams(params dmxExt, inst openrtb2.Imp, ins openrtb2.Imp, imps []openrtb2.Imp, banner *openrtb2.Banner, video *openrtb2.Video, intVal int8) []openrtb2.Imp { - tempimp := inst + tempImp := inst if params.Bidder.Bidfloor != 0 { - tempimp.BidFloor = params.Bidder.Bidfloor + tempImp.BidFloor = params.Bidder.Bidfloor } if params.Bidder.TagId != "" { - tempimp.TagID = params.Bidder.TagId - tempimp.Secure = &intVal + tempImp.TagID = params.Bidder.TagId + tempImp.Secure = &intVal } if params.Bidder.DmxId != "" { - tempimp.TagID = params.Bidder.DmxId - tempimp.Secure = &intVal + tempImp.TagID = params.Bidder.DmxId + tempImp.Secure = &intVal } if banner != nil { if banner.H == nil || banner.W == nil { banner.H = &banner.Format[0].H banner.W = &banner.Format[0].W } - tempimp.Banner = banner + tempImp.Banner = banner } if video != nil { video.Protocols = checkProtocols(video) - tempimp.Video = video + tempImp.Video = video } - if tempimp.TagID == "" { + if tempImp.TagID == "" { return imps } - imps = append(imps, tempimp) + imps = append(imps, tempImp) return imps } From 5430f6c492d263c57d051d1570c38ff0f8d83b93 Mon Sep 17 00:00:00 2001 From: Dmitry S Date: Thu, 25 Apr 2024 17:56:39 +0200 Subject: [PATCH 09/12] resolve TODOs in tests --- openrtb_ext/request_wrapper_test.go | 3 +-- server/server_test.go | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/openrtb_ext/request_wrapper_test.go b/openrtb_ext/request_wrapper_test.go index 5a101e47cd1..7b21531e02e 100644 --- a/openrtb_ext/request_wrapper_test.go +++ b/openrtb_ext/request_wrapper_test.go @@ -705,8 +705,7 @@ func TestCloneUserExt(t *testing.T) { eids[0].UIDs[1].ID = "G2" eids[1].UIDs[0].AType = 0 eids[0].UIDs = append(eids[0].UIDs, openrtb2.UID{ID: "Z", AType: 2}) - eids = append(eids, openrtb2.EID{Source: "Blank"}) - // TODO: double-check why we fill eids but don't use it + eids = append(eids, openrtb2.EID{Source: "Blank"}) //nolint: ineffassign, staticcheck // this value of `eids` is never used (staticcheck) userExt.eids = nil }, }, diff --git a/server/server_test.go b/server/server_test.go index 66d42fd4919..7f81f781b8e 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -178,8 +178,6 @@ func TestRunServer(t *testing.T) { } func TestListen(t *testing.T) { - // TODO(dmitris): check if the unused const 'name' can be deleted [PR3621] - const name = "TestListen" var ( handler, adminHandler http.Handler From 55345bfb4b39f6bf9ccd3456d3879e72e5cd883b Mon Sep 17 00:00:00 2001 From: Dmitry S Date: Mon, 29 Apr 2024 17:30:59 +0200 Subject: [PATCH 10/12] remove unnecessary comment (PR feedback) --- endpoints/openrtb2/auction.go | 1 - 1 file changed, 1 deletion(-) diff --git a/endpoints/openrtb2/auction.go b/endpoints/openrtb2/auction.go index 71c6103dee7..e5773735e63 100644 --- a/endpoints/openrtb2/auction.go +++ b/endpoints/openrtb2/auction.go @@ -2322,7 +2322,6 @@ func parseImpInfo(requestJson []byte) (impData []ImpExtPrebidData, errs []error) // ignore the error such as '&errors.errorString{s:"Unknown value type"}' if impArray, dataType, _, err := jsonparser.Get(requestJson, "imp"); err == nil && dataType == jsonparser.Array { _, _ = jsonparser.ArrayEach(impArray, func(imp []byte, _ jsonparser.ValueType, _ int, _ error) { - // ignore possible errors if there is no ext.prebid key impExtData, _, _, _ := jsonparser.Get(imp, "ext", "prebid") var impExtPrebid openrtb_ext.ExtImpPrebid if impExtData != nil { From ea94905c0a83e8c9db801f4b90a4e4a7524174da Mon Sep 17 00:00:00 2001 From: Dmitry S Date: Mon, 29 Apr 2024 17:36:37 +0200 Subject: [PATCH 11/12] remove comment about error handling --- endpoints/openrtb2/auction.go | 1 - 1 file changed, 1 deletion(-) diff --git a/endpoints/openrtb2/auction.go b/endpoints/openrtb2/auction.go index e5773735e63..a8ac44cf0d6 100644 --- a/endpoints/openrtb2/auction.go +++ b/endpoints/openrtb2/auction.go @@ -2319,7 +2319,6 @@ func (deps *endpointDeps) processStoredRequests(requestJson []byte, impInfo []Im // parseImpInfo parses the request JSON and returns impression and unmarshalled imp.ext.prebid func parseImpInfo(requestJson []byte) (impData []ImpExtPrebidData, errs []error) { - // ignore the error such as '&errors.errorString{s:"Unknown value type"}' if impArray, dataType, _, err := jsonparser.Get(requestJson, "imp"); err == nil && dataType == jsonparser.Array { _, _ = jsonparser.ArrayEach(impArray, func(imp []byte, _ jsonparser.ValueType, _ int, _ error) { impExtData, _, _, _ := jsonparser.Get(imp, "ext", "prebid") From 6d4f03aa5d36a8803dfb798b3fb5bf5d5e5e1178 Mon Sep 17 00:00:00 2001 From: Dmitry S Date: Thu, 2 May 2024 12:26:36 +0200 Subject: [PATCH 12/12] address PR feedback --- adapters/lemmadigital/lemmadigital.go | 7 +++---- adapters/minutemedia/minutemedia.go | 23 +++++++++++------------ adapters/tappx/tappx_test.go | 5 +---- adapters/yieldmo/yieldmo.go | 10 ++-------- 4 files changed, 17 insertions(+), 28 deletions(-) diff --git a/adapters/lemmadigital/lemmadigital.go b/adapters/lemmadigital/lemmadigital.go index 1a01fac026b..281cd2e1f0f 100644 --- a/adapters/lemmadigital/lemmadigital.go +++ b/adapters/lemmadigital/lemmadigital.go @@ -94,15 +94,14 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R if len(response.Cur) > 0 { bidResponse.Currency = response.Cur } - for _, seatBid := range response.SeatBid { - for i := range seatBid.Bid { + if len(response.SeatBid) > 0 { + for i := range response.SeatBid[0].Bid { b := &adapters.TypedBid{ - Bid: &seatBid.Bid[i], + Bid: &response.SeatBid[0].Bid[i], BidType: bidType, } bidResponse.Bids = append(bidResponse.Bids, b) } - break //nolint: staticcheck // break is intended, exempt from staticcheck SA4004 } return bidResponse, nil diff --git a/adapters/minutemedia/minutemedia.go b/adapters/minutemedia/minutemedia.go index 0ce67bbfb72..796f9ec6e6b 100644 --- a/adapters/minutemedia/minutemedia.go +++ b/adapters/minutemedia/minutemedia.go @@ -91,22 +91,21 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, _ *adapters.RequestData func extractOrg(openRTBRequest *openrtb2.BidRequest) (string, error) { var err error - for _, imp := range openRTBRequest.Imp { - var bidderExt adapters.ExtImpBidder - if err = json.Unmarshal(imp.Ext, &bidderExt); err != nil { - return "", fmt.Errorf("failed to unmarshal bidderExt: %w", err) - } + if len(openRTBRequest.Imp) == 0 { + return "", errors.New("no imps in bid request") + } - var impExt openrtb_ext.ImpExtMinuteMedia - if err = json.Unmarshal(bidderExt.Bidder, &impExt); err != nil { - return "", fmt.Errorf("failed to unmarshal ImpExtMinuteMedia: %w", err) - } + var bidderExt adapters.ExtImpBidder + if err = json.Unmarshal(openRTBRequest.Imp[0].Ext, &bidderExt); err != nil { + return "", fmt.Errorf("failed to unmarshal bidderExt: %w", err) + } - //nolint: staticcheck // SA4004: the surrounding loop is unconditionally terminated - return strings.TrimSpace(impExt.Org), nil + var impExt openrtb_ext.ImpExtMinuteMedia + if err = json.Unmarshal(bidderExt.Bidder, &impExt); err != nil { + return "", fmt.Errorf("failed to unmarshal ImpExtMinuteMedia: %w", err) } - return "", errors.New("no imps in bid request") + return strings.TrimSpace(impExt.Org), nil } func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) { diff --git a/adapters/tappx/tappx_test.go b/adapters/tappx/tappx_test.go index c68bed2ca28..803dfa5bde2 100644 --- a/adapters/tappx/tappx_test.go +++ b/adapters/tappx/tappx_test.go @@ -45,10 +45,7 @@ func TestTsValue(t *testing.T) { tappxExt.TappxKey = "dummy-tappx-key" url, err := bidderTappx.buildEndpointURL(&tappxExt, test) - if err != nil { - require.NoError(t, err, "buildEndpointURL") - return - } + require.NoError(t, err, "buildEndpointURL") match, err := regexp.MatchString(`http://ssp\.api\.tappx\.com/rtb/v2/DUMMYENDPOINT\?tappxkey=dummy-tappx-key&ts=[0-9]{13}&type_cnn=prebid&v=1\.5`, url) if err != nil { diff --git a/adapters/yieldmo/yieldmo.go b/adapters/yieldmo/yieldmo.go index 2b97a64c455..6693861c2fb 100644 --- a/adapters/yieldmo/yieldmo.go +++ b/adapters/yieldmo/yieldmo.go @@ -35,14 +35,8 @@ type ExtBid struct { } func (a *YieldmoAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { - var adapterRequests []*adapters.RequestData - - adapterReq, errors := a.makeRequest(request) - if adapterReq != nil { - adapterRequests = append(adapterRequests, adapterReq) - } - - return adapterRequests, errors + reqData, errors := a.makeRequest(request) + return []*adapters.RequestData{reqData}, errors } func (a *YieldmoAdapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestData, []error) {