diff --git a/adapters/adgeneration/adgeneration_test.go b/adapters/adgeneration/adgeneration_test.go index 802db77e313..24e1de5eccd 100644 --- a/adapters/adgeneration/adgeneration_test.go +++ b/adapters/adgeneration/adgeneration_test.go @@ -259,6 +259,7 @@ func checkBidResponse(t *testing.T, bidderResponse *adapters.BidderResponse, exp var expectedCrID string = "Dummy_supership.jp" var extectedDealID string = "test-deal-id" + //nolint: staticcheck // false positive SA5011: possible nil pointer dereference assert.Equal(t, expectedCurrency, bidderResponse.Currency) assert.Equal(t, 1, len(bidderResponse.Bids)) assert.Equal(t, expectedID, bidderResponse.Bids[0].Bid.ID) diff --git a/adapters/adtarget/adtarget.go b/adapters/adtarget/adtarget.go index bb760574d93..8c5d11704a5 100644 --- a/adapters/adtarget/adtarget.go +++ b/adapters/adtarget/adtarget.go @@ -174,7 +174,11 @@ func validateImpressionAndSetExt(imp *openrtb2.Imp) (int, error) { impExtBuffer, err = json.Marshal(&adtargetImpExt{ Adtarget: impExt, }) - + if err != nil { + return 0, &errortypes.BadInput{ + Message: fmt.Sprintf("ignoring imp id=%s, error while encoding impExt, err: %s", imp.ID, err), + } + } if impExt.BidFloor > 0 { imp.BidFloor = impExt.BidFloor } diff --git a/adapters/advangelists/advangelists.go b/adapters/advangelists/advangelists.go index f1d3a013f37..bddb9706c5b 100644 --- a/adapters/advangelists/advangelists.go +++ b/adapters/advangelists/advangelists.go @@ -199,7 +199,7 @@ func (adapter *AdvangelistsAdapter) buildEndpointURL(params *openrtb_ext.ExtImpA // MakeBids translates advangelists bid response to prebid-server specific format func (adapter *AdvangelistsAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { - var msg = "" + var msg string if response.StatusCode == http.StatusNoContent { return nil, nil } diff --git a/adapters/algorix/algorix.go b/adapters/algorix/algorix.go index cf28bff7d67..28a1a560829 100644 --- a/adapters/algorix/algorix.go +++ b/adapters/algorix/algorix.go @@ -142,6 +142,9 @@ func preProcess(request *openrtb2.BidRequest) { videoCopy := *request.Imp[i].Video videoExt := algorixVideoExt{Rewarded: 1} videoCopy.Ext, err = json.Marshal(&videoExt) + if err != nil { + continue + } request.Imp[i].Video = &videoCopy } } diff --git a/adapters/beintoo/beintoo.go b/adapters/beintoo/beintoo.go index 9a68bb40858..500e0e4a9df 100644 --- a/adapters/beintoo/beintoo.go +++ b/adapters/beintoo/beintoo.go @@ -23,7 +23,7 @@ func (a *BeintooAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada if len(request.Imp) == 0 { return nil, []error{&errortypes.BadInput{ - Message: fmt.Sprintf("No Imps in Bid Request"), + Message: "No Imps in Bid Request", }} } @@ -36,7 +36,7 @@ func (a *BeintooAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada data, err := json.Marshal(request) if err != nil { return nil, []error{&errortypes.BadInput{ - Message: fmt.Sprintf("Error in packaging request to JSON"), + Message: "Error in packaging request to JSON", }} } @@ -95,7 +95,7 @@ func buildImpBanner(imp *openrtb2.Imp) error { if imp.Banner == nil { return &errortypes.BadInput{ - Message: fmt.Sprintf("Request needs to include a Banner object"), + Message: "Request needs to include a Banner object", } } @@ -105,7 +105,7 @@ func buildImpBanner(imp *openrtb2.Imp) error { if banner.W == nil && banner.H == nil { if len(banner.Format) == 0 { return &errortypes.BadInput{ - Message: fmt.Sprintf("Need at least one size to build request"), + Message: "Need at least one size to build request", } } format := banner.Format[0] diff --git a/adapters/between/between.go b/adapters/between/between.go index 4b9deae67ed..a639c219561 100644 --- a/adapters/between/between.go +++ b/adapters/between/between.go @@ -24,7 +24,7 @@ func (a *BetweenAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada var errors []error if len(request.Imp) == 0 { return nil, []error{&errortypes.BadInput{ - Message: fmt.Sprintf("No valid Imps in Bid Request"), + Message: "No valid Imps in Bid Request", }} } ext, errors := preprocess(request) @@ -40,7 +40,7 @@ func (a *BetweenAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada data, err := json.Marshal(request) if err != nil { return nil, []error{&errortypes.BadInput{ - Message: fmt.Sprintf("Error in packaging request to JSON"), + Message: "Error in packaging request to JSON", }} } headers := http.Header{} @@ -103,14 +103,14 @@ func (a *BetweenAdapter) buildEndpointURL(e *openrtb_ext.ExtImpBetween) (string, func buildImpBanner(imp *openrtb2.Imp) error { if imp.Banner == nil { return &errortypes.BadInput{ - Message: fmt.Sprintf("Request needs to include a Banner object"), + Message: "Request needs to include a Banner object", } } banner := *imp.Banner if banner.W == nil && banner.H == nil { if len(banner.Format) == 0 { return &errortypes.BadInput{ - Message: fmt.Sprintf("Need at least one size to build request"), + Message: "Need at least one size to build request", } } format := banner.Format[0] diff --git a/adapters/bluesea/bluesea.go b/adapters/bluesea/bluesea.go index 326b15fa42d..2e8d50b6e08 100644 --- a/adapters/bluesea/bluesea.go +++ b/adapters/bluesea/bluesea.go @@ -97,7 +97,7 @@ func extraImpExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpBluesea, error) { } if len(blueseaImpExt.PubId) == 0 || len(blueseaImpExt.Token) == 0 { return nil, &errortypes.BadInput{ - Message: fmt.Sprintf("Error in parsing imp.ext.bidder, empty pubid or token"), + Message: "Error in parsing imp.ext.bidder, empty pubid or token", } } return &blueseaImpExt, nil diff --git a/adapters/cadent_aperture_mx/cadentaperturemx.go b/adapters/cadent_aperture_mx/cadentaperturemx.go index e86cddbe6c4..ae191469a27 100644 --- a/adapters/cadent_aperture_mx/cadentaperturemx.go +++ b/adapters/cadent_aperture_mx/cadentaperturemx.go @@ -38,7 +38,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E if len(request.Imp) == 0 { return nil, []error{&errortypes.BadInput{ - Message: fmt.Sprintf("No Imps in Bid Request"), + Message: "No Imps in Bid Request", }} } @@ -51,7 +51,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E data, err := json.Marshal(request) if err != nil { return nil, []error{&errortypes.BadInput{ - Message: fmt.Sprintf("Error in packaging request to JSON"), + Message: "Error in packaging request to JSON", }} } @@ -117,7 +117,7 @@ func buildImpBanner(imp *openrtb2.Imp) error { if imp.Banner == nil { return &errortypes.BadInput{ - Message: fmt.Sprintf("Request needs to include a Banner object"), + Message: "Request needs to include a Banner object", } } @@ -127,7 +127,7 @@ func buildImpBanner(imp *openrtb2.Imp) error { if banner.W == nil && banner.H == nil { if len(banner.Format) == 0 { return &errortypes.BadInput{ - Message: fmt.Sprintf("Need at least one size to build request"), + Message: "Need at least one size to build request", } } format := banner.Format[0] @@ -144,13 +144,13 @@ func buildImpVideo(imp *openrtb2.Imp) error { if len(imp.Video.MIMEs) == 0 { return &errortypes.BadInput{ - Message: fmt.Sprintf("Video: missing required field mimes"), + Message: "Video: missing required field mimes", } } if (imp.Video.H == nil || *imp.Video.H == 0) && (imp.Video.W == nil || *imp.Video.W == 0) { return &errortypes.BadInput{ - Message: fmt.Sprintf("Video: Need at least one size to build request"), + Message: "Video: Need at least one size to build request", } } diff --git a/adapters/connectad/connectad.go b/adapters/connectad/connectad.go index ca681c1b7bb..83023195c54 100644 --- a/adapters/connectad/connectad.go +++ b/adapters/connectad/connectad.go @@ -32,14 +32,14 @@ func (a *ConnectAdAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *a if errs := preprocess(request); len(errs) > 0 { return nil, append(errs, &errortypes.BadInput{ - Message: fmt.Sprintf("Error in preprocess of Imp"), + Message: "Error in preprocess of Imp", }) } data, err := json.Marshal(request) if err != nil { return nil, []error{&errortypes.BadInput{ - Message: fmt.Sprintf("Error in packaging request to JSON"), + Message: "Error in packaging request to JSON", }} } @@ -183,7 +183,7 @@ func buildImpBanner(imp *openrtb2.Imp) error { if imp.Banner == nil { return &errortypes.BadInput{ - Message: fmt.Sprintf("We need a Banner Object in the request"), + Message: "We need a Banner Object in the request", } } @@ -193,7 +193,7 @@ func buildImpBanner(imp *openrtb2.Imp) error { if len(banner.Format) == 0 { return &errortypes.BadInput{ - Message: fmt.Sprintf("At least one size is required"), + Message: "At least one size is required", } } format := banner.Format[0] diff --git a/adapters/consumable/consumable.go b/adapters/consumable/consumable.go index 1f669f28c74..dd139e58fb0 100644 --- a/adapters/consumable/consumable.go +++ b/adapters/consumable/consumable.go @@ -89,12 +89,10 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp)) bidResponse.Currency = response.Cur - var errors []error for _, seatBid := range response.SeatBid { for i, bid := range seatBid.Bid { bidType, err := getMediaTypeForBid(bid) if err != nil { - errors = append(errors, err) continue } var bidVideo *openrtb_ext.ExtBidPrebidVideo diff --git a/adapters/deepintent/deepintent.go b/adapters/deepintent/deepintent.go index 1df58a060fa..32f0d53ddf8 100644 --- a/adapters/deepintent/deepintent.go +++ b/adapters/deepintent/deepintent.go @@ -151,7 +151,7 @@ func buildImpBanner(imp *openrtb2.Imp) error { if imp.Banner == nil { return &errortypes.BadInput{ - Message: fmt.Sprintf("We need a Banner Object in the request"), + Message: "We need a Banner Object in the request", } } @@ -161,7 +161,7 @@ func buildImpBanner(imp *openrtb2.Imp) error { if len(banner.Format) == 0 { return &errortypes.BadInput{ - Message: fmt.Sprintf("At least one size is required"), + Message: "At least one size is required", } } format := banner.Format[0] diff --git a/adapters/definemedia/definemedia.go b/adapters/definemedia/definemedia.go index 79d1b7fbfb4..0bb4ff79e19 100644 --- a/adapters/definemedia/definemedia.go +++ b/adapters/definemedia/definemedia.go @@ -99,7 +99,7 @@ func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) { return openrtb_ext.ParseBidType(string(bidExt.Prebid.Type)) } return "", &errortypes.BadServerResponse{ - Message: fmt.Sprintf("Invalid mediatype in the impression"), + Message: "Invalid mediatype in the impression", } } } diff --git a/adapters/dmx/dmx.go b/adapters/dmx/dmx.go index f080ca8ee44..0ad522c4398 100644 --- a/adapters/dmx/dmx.go +++ b/adapters/dmx/dmx.go @@ -224,13 +224,13 @@ func (adapter *DmxAdapter) MakeBids(request *openrtb2.BidRequest, externalReques if http.StatusBadRequest == response.StatusCode { return nil, []error{&errortypes.BadInput{ - Message: fmt.Sprintf("Unexpected status code 400"), + Message: "Unexpected status code 400", }} } if http.StatusOK != response.StatusCode { return nil, []error{&errortypes.BadInput{ - Message: fmt.Sprintf("Unexpected response no status code"), + Message: "Unexpected response no status code", }} } diff --git a/adapters/e_volution/evolution.go b/adapters/e_volution/evolution.go index f182480de5b..89ab5e0994c 100644 --- a/adapters/e_volution/evolution.go +++ b/adapters/e_volution/evolution.go @@ -92,7 +92,7 @@ func (a *adapter) MakeBids( if len(bidResp.SeatBid) == 0 { return nil, []error{&errortypes.BadServerResponse{ - Message: fmt.Sprintf("Empty seatbid"), + Message: "Empty seatbid", }} } diff --git a/adapters/gamma/gamma.go b/adapters/gamma/gamma.go index 8e14331b465..56153aeedd6 100644 --- a/adapters/gamma/gamma.go +++ b/adapters/gamma/gamma.go @@ -267,7 +267,7 @@ func (a *GammaAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRe }) } else { err := &errortypes.BadServerResponse{ - Message: fmt.Sprintf("Missing Ad Markup. Run with request.debug = 1 for more info"), + Message: "Missing Ad Markup. Run with request.debug = 1 for more info", } errs = append(errs, err) } diff --git a/adapters/gamoshi/gamoshi.go b/adapters/gamoshi/gamoshi.go index 19016fdbdae..13cf4d8b2fd 100644 --- a/adapters/gamoshi/gamoshi.go +++ b/adapters/gamoshi/gamoshi.go @@ -55,7 +55,7 @@ func (a *GamoshiAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada if !validImpExists { 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 diff --git a/adapters/grid/grid.go b/adapters/grid/grid.go index fe3e9fb0198..3f521ba5e0a 100644 --- a/adapters/grid/grid.go +++ b/adapters/grid/grid.go @@ -2,6 +2,7 @@ package grid import ( "encoding/json" + "errors" "fmt" "net/http" "sort" @@ -394,8 +395,12 @@ func (a *GridAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalReq for _, sb := range bidResp.SeatBid { for i := range sb.Bid { - bidMeta, err := getBidMeta(sb.Bid[i].Ext) + bidMeta, err := getBidMeta(sb.Bid[i].Ext) //nolint: ineffassign,staticcheck // ineffectual assignment to err + bidType, err := getMediaTypeForImp(sb.Bid[i].ImpID, internalRequest.Imp, sb.Bid[i]) + if err != nil { + return nil, []error{err} + } if sb.Bid[i].AdmNative != nil && sb.Bid[i].AdM == "" { if bytes, err := json.Marshal(sb.Bid[i].AdmNative); err == nil { sb.Bid[i].AdM = string(bytes) @@ -427,6 +432,9 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co } func getBidMeta(ext json.RawMessage) (*openrtb_ext.ExtBidPrebidMeta, error) { + if ext == nil { + return nil, errors.New("nil ext passed to getBidMeta") + } var bidExt GridBidExt if err := json.Unmarshal(ext, &bidExt); err != nil { diff --git a/adapters/imds/imds.go b/adapters/imds/imds.go index 797c7e25b6b..1fba38a0c6d 100644 --- a/adapters/imds/imds.go +++ b/adapters/imds/imds.go @@ -71,7 +71,7 @@ func (a *adapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestDa // if the bid request is missing seatId or TagId then ignore it if validExtImpObj.SeatId == "" || validExtImpObj.TagId == "" { errs = append(errs, &errortypes.BadServerResponse{ - Message: fmt.Sprintf("Invalid Impression"), + Message: "Invalid Impression", }) continue } @@ -91,7 +91,7 @@ func (a *adapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestDa if firstExtImp == nil || firstExtImp.SeatId == "" || firstExtImp.TagId == "" { return nil, append(errs, &errortypes.BadServerResponse{ - Message: fmt.Sprintf("Invalid Impression"), + Message: "Invalid Impression", }) } // this is where the empty seatId is filled diff --git a/adapters/mobfoxpb/mobfoxpb.go b/adapters/mobfoxpb/mobfoxpb.go index 3b24aa88dab..b7630d7f9e1 100644 --- a/adapters/mobfoxpb/mobfoxpb.go +++ b/adapters/mobfoxpb/mobfoxpb.go @@ -50,7 +50,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E key, errKey := jsonparser.GetString(imp.Ext, "bidder", "key") if errTag != nil && errKey != nil { errs = append(errs, &errortypes.BadInput{ - Message: fmt.Sprintf("Invalid or non existing key and tagId, atleast one should be present"), + Message: "Invalid or non existing key and tagId, at least one should be present", }) return nil, errs } diff --git a/adapters/mobfoxpb/mobfoxpbtest/supplemental/bad-imp-ext.json b/adapters/mobfoxpb/mobfoxpbtest/supplemental/bad-imp-ext.json index 6f2b95a8c54..4dddecb499b 100644 --- a/adapters/mobfoxpb/mobfoxpbtest/supplemental/bad-imp-ext.json +++ b/adapters/mobfoxpb/mobfoxpbtest/supplemental/bad-imp-ext.json @@ -34,7 +34,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "Invalid or non existing key and tagId, atleast one should be present", + "value": "Invalid or non existing key and tagId, at least one should be present", "comparison": "literal" } ] diff --git a/adapters/mobfoxpb/mobfoxpbtest/supplemental/imp_ext_empty_object.json b/adapters/mobfoxpb/mobfoxpbtest/supplemental/imp_ext_empty_object.json index 9179916e922..dc2bd77834a 100644 --- a/adapters/mobfoxpb/mobfoxpbtest/supplemental/imp_ext_empty_object.json +++ b/adapters/mobfoxpb/mobfoxpbtest/supplemental/imp_ext_empty_object.json @@ -30,7 +30,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "Invalid or non existing key and tagId, atleast one should be present", + "value": "Invalid or non existing key and tagId, at least one should be present", "comparison": "literal" } ] diff --git a/adapters/mobfoxpb/mobfoxpbtest/supplemental/imp_ext_string.json b/adapters/mobfoxpb/mobfoxpbtest/supplemental/imp_ext_string.json index 45c32a1aa63..d5d2955a03f 100644 --- a/adapters/mobfoxpb/mobfoxpbtest/supplemental/imp_ext_string.json +++ b/adapters/mobfoxpb/mobfoxpbtest/supplemental/imp_ext_string.json @@ -30,7 +30,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "Invalid or non existing key and tagId, atleast one should be present", + "value": "Invalid or non existing key and tagId, at least one should be present", "comparison": "literal" } ] diff --git a/adapters/nobid/nobid.go b/adapters/nobid/nobid.go index 455ba7500b0..9c91c78dd2b 100644 --- a/adapters/nobid/nobid.go +++ b/adapters/nobid/nobid.go @@ -30,7 +30,7 @@ func (a *NoBidAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapt if len(request.Imp) == 0 { return nil, []error{&errortypes.BadInput{ - Message: fmt.Sprintf("No Imps in Bid Request"), + Message: "No Imps in Bid Request", }} } diff --git a/adapters/ownadx/ownadx.go b/adapters/ownadx/ownadx.go index 54973bd0bb8..5c54b395ddc 100644 --- a/adapters/ownadx/ownadx.go +++ b/adapters/ownadx/ownadx.go @@ -145,14 +145,14 @@ func (adapter *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalR if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{ &errortypes.BadServerResponse{ - Message: fmt.Sprintf("Bad server response "), + Message: "Bad server response ", }, } } if len(bidResp.SeatBid) == 0 { return nil, []error{ &errortypes.BadServerResponse{ - Message: fmt.Sprintf("Array SeatBid cannot be empty "), + Message: "Array SeatBid cannot be empty ", }, } } @@ -162,7 +162,7 @@ func (adapter *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalR if len(seatBid.Bid) == 0 { return nil, []error{ &errortypes.BadServerResponse{ - Message: fmt.Sprintf("Bid cannot be empty "), + Message: "Bid cannot be empty ", }, } } diff --git a/adapters/pulsepoint/pulsepoint.go b/adapters/pulsepoint/pulsepoint.go index 0d1c58f0d1f..c351bb7d051 100644 --- a/adapters/pulsepoint/pulsepoint.go +++ b/adapters/pulsepoint/pulsepoint.go @@ -139,7 +139,7 @@ func (a *PulsePointAdapter) MakeBids(internalRequest *openrtb2.BidRequest, exter bid := sb.Bid[i] imp := impsByID[bid.ImpID] bidType := getBidType(imp) - if &imp != nil && bidType != "" { + if bidType != "" { bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ Bid: &bid, BidType: bidType, diff --git a/adapters/rubicon/rubicon.go b/adapters/rubicon/rubicon.go index a12d2fc730a..04610e59510 100644 --- a/adapters/rubicon/rubicon.go +++ b/adapters/rubicon/rubicon.go @@ -458,8 +458,14 @@ func (a *RubiconAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada } else { appCopy := *request.App appCopy.Ext, err = json.Marshal(rubiconSiteExt{RP: rubiconSiteExtRP{SiteID: int(siteId)}}) + if err != nil { + errs = append(errs, &errortypes.BadInput{Message: err.Error()}) + } appCopy.Publisher = &openrtb2.Publisher{} appCopy.Publisher.Ext, err = json.Marshal(&pubExt) + if err != nil { + errs = append(errs, &errortypes.BadInput{Message: err.Error()}) + } rubiconRequest.App = &appCopy } @@ -587,7 +593,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 { //nolint: staticcheck + if bidderExt.Bidder.BidOnMultiformat == false { //nolint: gosimple,staticcheck impCopy := imp preparedImpsToExtMap[impCopy] = bidderExt continue diff --git a/adapters/tappx/tappx.go b/adapters/tappx/tappx.go index 57aaa039409..e50a5089c1d 100644 --- a/adapters/tappx/tappx.go +++ b/adapters/tappx/tappx.go @@ -131,13 +131,13 @@ 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(), } } + var tappxHost string if isNewEndpoint { tappxHost = params.Endpoint + ".pub.tappx.com/rtb/" } else { diff --git a/adapters/telaria/telaria.go b/adapters/telaria/telaria.go index e98730d7ad2..3658bfdf0b7 100644 --- a/adapters/telaria/telaria.go +++ b/adapters/telaria/telaria.go @@ -200,11 +200,14 @@ func (a *TelariaAdapter) MakeRequests(requestIn *openrtb2.BidRequest, reqInfo *a return nil, []error{err} } + if telariaImpExt == nil { + return nil, []error{&errortypes.BadInput{Message: "Telaria: nil ExtImpTelaria object"}} + } // Swap the tagID with adCode imp.TagID = telariaImpExt.AdCode // Add the Extra from Imp to the top level Ext - if telariaImpExt != nil && telariaImpExt.Extra != nil { + if telariaImpExt.Extra != nil { request.Ext, err = json.Marshal(&telariaBidExt{Extra: telariaImpExt.Extra}) if err != nil { return nil, []error{err} diff --git a/adapters/trafficgate/trafficgate.go b/adapters/trafficgate/trafficgate.go index 262c265cae5..24e8be20c6c 100644 --- a/adapters/trafficgate/trafficgate.go +++ b/adapters/trafficgate/trafficgate.go @@ -105,12 +105,12 @@ func (a *adapter) MakeBids( var bidExt BidResponseExt if err := json.Unmarshal(seatBid.Bid[i].Ext, &bidExt); err != nil { return nil, []error{&errortypes.BadServerResponse{ - Message: fmt.Sprintf("Missing response ext"), + Message: "Missing response ext", }} } if len(bidExt.Prebid.Type) < 1 { return nil, []error{&errortypes.BadServerResponse{ - Message: fmt.Sprintf("Unable to read bid.ext.prebid.type"), + Message: "Unable to read bid.ext.prebid.type", }} } bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ @@ -143,13 +143,13 @@ func getBidderParams(imp *openrtb2.Imp) (*openrtb_ext.ExtImpTrafficGate, error) var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ - Message: fmt.Sprintf("Missing bidder ext"), + Message: "Missing bidder ext", } } var TrafficGateExt openrtb_ext.ExtImpTrafficGate if err := json.Unmarshal(bidderExt.Bidder, &TrafficGateExt); err != nil { return nil, &errortypes.BadInput{ - Message: fmt.Sprintf("Bidder parameters required"), + Message: "Bidder parameters required", } } diff --git a/adapters/ucfunnel/ucfunnel.go b/adapters/ucfunnel/ucfunnel.go index 3ea68e685b3..f74e79bddcf 100644 --- a/adapters/ucfunnel/ucfunnel.go +++ b/adapters/ucfunnel/ucfunnel.go @@ -75,7 +75,7 @@ func (a *UcfunnelAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ad // If all the requests were malformed, don't bother making a server call with no impressions. if len(request.Imp) == 0 { return nil, []error{&errortypes.BadInput{ - Message: fmt.Sprintf("No impression in the bid request\n"), + Message: "No impression in the bid request\n", }} } diff --git a/adapters/yahooAds/yahooAds.go b/adapters/yahooAds/yahooAds.go index 4d1ebdbbf52..dddeddcce21 100644 --- a/adapters/yahooAds/yahooAds.go +++ b/adapters/yahooAds/yahooAds.go @@ -182,7 +182,9 @@ func changeRequestForBidService(request *openrtb2.BidRequest, extension *openrtb return err } regsExt["gpp"], err = json.Marshal(&requestRegs.GPP) - + if err != nil { + return fmt.Errorf("failed to marshal requestRegs.GPP: %v", err) + } if requestRegs.GPPSID != nil { regsExt["gpp_sid"], err = json.Marshal(&requestRegs.GPPSID) if err != nil { diff --git a/config/bidderinfo.go b/config/bidderinfo.go index d78f5722552..25ec9381464 100644 --- a/config/bidderinfo.go +++ b/config/bidderinfo.go @@ -637,7 +637,7 @@ func applyBidderInfoConfigOverrides(configBidderInfos nillableFieldBidderInfos, if configBidderInfo.nillableFields.ModifyingVastXmlAllowed != nil { mergedBidderInfo.ModifyingVastXmlAllowed = configBidderInfo.bidderInfo.ModifyingVastXmlAllowed } - if configBidderInfo.bidderInfo.Experiment.AdsCert.Enabled == true { + if configBidderInfo.bidderInfo.Experiment.AdsCert.Enabled { mergedBidderInfo.Experiment.AdsCert.Enabled = true } if configBidderInfo.bidderInfo.EndpointCompression != "" { diff --git a/currency/rate_converter.go b/currency/rate_converter.go index a9ab9547f83..1dd18fabcb1 100644 --- a/currency/rate_converter.go +++ b/currency/rate_converter.go @@ -138,8 +138,7 @@ func (rc *RateConverter) checkStaleRates() bool { // GetInfo returns setup information about the converter func (rc *RateConverter) GetInfo() ConverterInfo { - var rates *map[string]map[string]float64 - rates = rc.Rates().GetRates() + var rates *map[string]map[string]float64 = rc.Rates().GetRates() return converterInfo{ source: rc.syncSourceURL, lastUpdated: rc.LastUpdated(), diff --git a/exchange/auction.go b/exchange/auction.go index 94f0121d05a..8e3c432e48c 100644 --- a/exchange/auction.go +++ b/exchange/auction.go @@ -44,9 +44,9 @@ type DebugData struct { func (d *DebugLog) BuildCacheString() { if d.Regexp != nil { - d.Data.Request = fmt.Sprintf(d.Regexp.ReplaceAllString(d.Data.Request, "")) - d.Data.Headers = fmt.Sprintf(d.Regexp.ReplaceAllString(d.Data.Headers, "")) - d.Data.Response = fmt.Sprintf(d.Regexp.ReplaceAllString(d.Data.Response, "")) + d.Data.Request = fmt.Sprint(d.Regexp.ReplaceAllString(d.Data.Request, "")) + d.Data.Headers = fmt.Sprint(d.Regexp.ReplaceAllString(d.Data.Headers, "")) + d.Data.Response = fmt.Sprint(d.Regexp.ReplaceAllString(d.Data.Response, "")) } d.Data.Request = fmt.Sprintf("%s", d.Data.Request) diff --git a/exchange/bidder_test.go b/exchange/bidder_test.go index 76ffe95d6ce..31c497d6f1c 100644 --- a/exchange/bidder_test.go +++ b/exchange/bidder_test.go @@ -1065,7 +1065,7 @@ func TestMultiCurrencies_RateConverterNotSet(t *testing.T) { seatBid := seatBids[0] // Verify: - assert.Equal(t, false, (seatBid == nil && tc.expectedBidsCount != 0), tc.description) + assert.Falsef(t, seatBid == nil && tc.expectedBidsCount != 0, tc.description) assert.Equal(t, tc.expectedBidsCount, uint(len(seatBid.Bids)), tc.description) assert.ElementsMatch(t, tc.expectedBadCurrencyErrors, errs, tc.description) assert.False(t, extraBidderRespInfo.respProcessingStartTime.IsZero()) diff --git a/exchange/exchange_test.go b/exchange/exchange_test.go index 5849dbc3f25..99334389f82 100644 --- a/exchange/exchange_test.go +++ b/exchange/exchange_test.go @@ -365,7 +365,7 @@ func TestDebugBehaviour(t *testing.T) { if test.generateWarnings { var errL []error errL = append(errL, &errortypes.Warning{ - Message: fmt.Sprintf("CCPA consent test warning."), + Message: "CCPA consent test warning.", WarningCode: errortypes.InvalidPrivacyConsentWarningCode}) auctionRequest.Warnings = errL } @@ -2595,7 +2595,7 @@ func TestCategoryMapping(t *testing.T) { adapterBids[bidderName1] = &seatBid - bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, *requestExt.Prebid.Targeting, adapterBids, categoriesFetcher, targData, &randomDeduplicateBidBooleanGenerator{}, &nonBids{}) + bidCategory, adapterBids, rejections, err := applyCategoryMapping(context.TODO(), *requestExt.Prebid.Targeting, adapterBids, categoriesFetcher, targData, &randomDeduplicateBidBooleanGenerator{}, &nonBids{}) assert.Equal(t, nil, err, "Category mapping error should be empty") assert.Equal(t, 1, len(rejections), "There should be 1 bid rejection message") @@ -2650,7 +2650,7 @@ func TestCategoryMappingNoIncludeBrandCategory(t *testing.T) { adapterBids[bidderName1] = &seatBid - bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, *requestExt.Prebid.Targeting, adapterBids, categoriesFetcher, targData, &randomDeduplicateBidBooleanGenerator{}, &nonBids{}) + bidCategory, adapterBids, rejections, err := applyCategoryMapping(context.TODO(), *requestExt.Prebid.Targeting, adapterBids, categoriesFetcher, targData, &randomDeduplicateBidBooleanGenerator{}, &nonBids{}) assert.Equal(t, nil, err, "Category mapping error should be empty") assert.Empty(t, rejections, "There should be no bid rejection messages") @@ -2702,7 +2702,7 @@ func TestCategoryMappingTranslateCategoriesNil(t *testing.T) { adapterBids[bidderName1] = &seatBid - bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, *requestExt.Prebid.Targeting, adapterBids, categoriesFetcher, targData, &randomDeduplicateBidBooleanGenerator{}, &nonBids{}) + bidCategory, adapterBids, rejections, err := applyCategoryMapping(context.TODO(), *requestExt.Prebid.Targeting, adapterBids, categoriesFetcher, targData, &randomDeduplicateBidBooleanGenerator{}, &nonBids{}) assert.Equal(t, nil, err, "Category mapping error should be empty") assert.Equal(t, 1, len(rejections), "There should be 1 bid rejection message") @@ -2784,7 +2784,7 @@ func TestCategoryMappingTranslateCategoriesFalse(t *testing.T) { adapterBids[bidderName1] = &seatBid - bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, *requestExt.Prebid.Targeting, adapterBids, categoriesFetcher, targData, &randomDeduplicateBidBooleanGenerator{}, &nonBids{}) + bidCategory, adapterBids, rejections, err := applyCategoryMapping(context.TODO(), *requestExt.Prebid.Targeting, adapterBids, categoriesFetcher, targData, &randomDeduplicateBidBooleanGenerator{}, &nonBids{}) assert.Equal(t, nil, err, "Category mapping error should be empty") assert.Empty(t, rejections, "There should be no bid rejection messages") @@ -2862,7 +2862,7 @@ func TestCategoryDedupe(t *testing.T) { }, } deduplicateGenerator := fakeBooleanGenerator{value: tt.dedupeGeneratorValue} - bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, *requestExt.Prebid.Targeting, adapterBids, categoriesFetcher, targData, &deduplicateGenerator, &nonBids{}) + bidCategory, adapterBids, rejections, err := applyCategoryMapping(context.TODO(), *requestExt.Prebid.Targeting, adapterBids, categoriesFetcher, targData, &deduplicateGenerator, &nonBids{}) assert.Nil(t, err) assert.Equal(t, 3, len(rejections)) @@ -2931,7 +2931,7 @@ func TestNoCategoryDedupe(t *testing.T) { adapterBids[bidderName1] = &seatBid - bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, *requestExt.Prebid.Targeting, adapterBids, categoriesFetcher, targData, &randomDeduplicateBidBooleanGenerator{}, &nonBids{}) + bidCategory, adapterBids, rejections, err := applyCategoryMapping(context.TODO(), *requestExt.Prebid.Targeting, adapterBids, categoriesFetcher, targData, &randomDeduplicateBidBooleanGenerator{}, &nonBids{}) assert.Equal(t, nil, err, "Category mapping error should be empty") assert.Equal(t, 2, len(rejections), "There should be 2 bid rejection messages") @@ -2996,7 +2996,7 @@ func TestCategoryMappingBidderName(t *testing.T) { adapterBids[bidderName1] = &seatBid1 adapterBids[bidderName2] = &seatBid2 - bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, *requestExt.Prebid.Targeting, adapterBids, categoriesFetcher, targData, &randomDeduplicateBidBooleanGenerator{}, &nonBids{}) + bidCategory, adapterBids, rejections, err := applyCategoryMapping(context.TODO(), *requestExt.Prebid.Targeting, adapterBids, categoriesFetcher, targData, &randomDeduplicateBidBooleanGenerator{}, &nonBids{}) assert.NoError(t, err, "Category mapping error should be empty") assert.Empty(t, rejections, "There should be 0 bid rejection messages") @@ -3050,7 +3050,7 @@ func TestCategoryMappingBidderNameNoCategories(t *testing.T) { adapterBids[bidderName1] = &seatBid1 adapterBids[bidderName2] = &seatBid2 - bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, *requestExt.Prebid.Targeting, adapterBids, categoriesFetcher, targData, &randomDeduplicateBidBooleanGenerator{}, &nonBids{}) + bidCategory, adapterBids, rejections, err := applyCategoryMapping(context.TODO(), *requestExt.Prebid.Targeting, adapterBids, categoriesFetcher, targData, &randomDeduplicateBidBooleanGenerator{}, &nonBids{}) assert.NoError(t, err, "Category mapping error should be empty") assert.Empty(t, rejections, "There should be 0 bid rejection messages") @@ -3151,7 +3151,7 @@ func TestBidRejectionErrors(t *testing.T) { adapterBids[bidderName] = &seatBid - bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, *test.reqExt.Prebid.Targeting, adapterBids, categoriesFetcher, targData, &randomDeduplicateBidBooleanGenerator{}, &nonBids{}) + bidCategory, adapterBids, rejections, err := applyCategoryMapping(context.TODO(), *test.reqExt.Prebid.Targeting, adapterBids, categoriesFetcher, targData, &randomDeduplicateBidBooleanGenerator{}, &nonBids{}) if len(test.expectedCatDur) > 0 { // Bid deduplication case @@ -3214,7 +3214,7 @@ func TestCategoryMappingTwoBiddersOneBidEachNoCategorySamePrice(t *testing.T) { adapterBids[bidderNameApn1] = &seatBidApn1 adapterBids[bidderNameApn2] = &seatBidApn2 - bidCategory, _, rejections, err := applyCategoryMapping(nil, *requestExt.Prebid.Targeting, adapterBids, categoriesFetcher, targData, &randomDeduplicateBidBooleanGenerator{}, &nonBids{}) + bidCategory, _, rejections, err := applyCategoryMapping(context.TODO(), *requestExt.Prebid.Targeting, adapterBids, categoriesFetcher, targData, &randomDeduplicateBidBooleanGenerator{}, &nonBids{}) assert.NoError(t, err, "Category mapping error should be empty") assert.Len(t, rejections, 1, "There should be 1 bid rejection message") @@ -3298,7 +3298,7 @@ func TestCategoryMappingTwoBiddersManyBidsEachNoCategorySamePrice(t *testing.T) adapterBids[bidderNameApn1] = &seatBidApn1 adapterBids[bidderNameApn2] = &seatBidApn2 - _, adapterBids, rejections, err := applyCategoryMapping(nil, *requestExt.Prebid.Targeting, adapterBids, categoriesFetcher, targData, &fakeBooleanGenerator{value: true}, &nonBids{}) + _, adapterBids, rejections, err := applyCategoryMapping(context.TODO(), *requestExt.Prebid.Targeting, adapterBids, categoriesFetcher, targData, &fakeBooleanGenerator{value: true}, &nonBids{}) assert.NoError(t, err, "Category mapping error should be empty") diff --git a/gdpr/purpose_enforcer_test.go b/gdpr/purpose_enforcer_test.go index fa0605702a0..1f931898ff1 100644 --- a/gdpr/purpose_enforcer_test.go +++ b/gdpr/purpose_enforcer_test.go @@ -111,10 +111,10 @@ func TestNewPurposeEnforcerBuilder(t *testing.T) { assert.IsType(t, tt.wantType, enforcer1, tt.description) // assert enforcer 1 config values are properly set - switch enforcer1.(type) { + switch enforcerCasted := enforcer1.(type) { case *FullEnforcement: { - fullEnforcer := enforcer1.(*FullEnforcement) + fullEnforcer := enforcerCasted assert.Equal(t, fullEnforcer.cfg.PurposeID, tt.purpose, tt.description) assert.Equal(t, fullEnforcer.cfg.EnforceAlgo, tt.enforceAlgo, tt.description) assert.Equal(t, fullEnforcer.cfg.EnforcePurpose, tt.enforcePurpose, tt.description) @@ -132,6 +132,8 @@ func TestNewPurposeEnforcerBuilder(t *testing.T) { assert.Equal(t, basicEnforcer.cfg.BasicEnforcementVendorsMap, tt.basicVendorsMap, tt.description) assert.Equal(t, basicEnforcer.cfg.VendorExceptionMap, tt.vendorExceptionMap, tt.description) } + default: + assert.FailNow(t, "unexpected type of enforcer") } } } diff --git a/hooks/hookexecution/execution.go b/hooks/hookexecution/execution.go index 03500bb5f0e..46b54e46b3c 100644 --- a/hooks/hookexecution/execution.go +++ b/hooks/hookexecution/execution.go @@ -343,7 +343,7 @@ func handleModuleActivities[P any](hookCode string, activityControl privacy.Acti privacy.ScrubUserFPD(bidderReqCopy) } if !transmitPreciseGeoActivityAllowed { - ipConf := privacy.IPConf{} + var ipConf privacy.IPConf if account != nil { ipConf = privacy.IPConf{IPV6: account.Privacy.IPv6Config, IPV4: account.Privacy.IPv4Config} } else { diff --git a/hooks/hookexecution/executor.go b/hooks/hookexecution/executor.go index cc3ada786d0..835e9de32c1 100644 --- a/hooks/hookexecution/executor.go +++ b/hooks/hookexecution/executor.go @@ -202,7 +202,7 @@ func (e *hookExecutor) ExecuteBidderRequestStage(req *openrtb_ext.RequestWrapper stageName := hooks.StageBidderRequest.String() executionCtx := e.newContext(stageName) payload := hookstage.BidderRequestPayload{Request: req, Bidder: bidder} - outcome, payload, contexts, reject := executeStage(executionCtx, plan, payload, handler, e.metricEngine) + outcome, _, contexts, reject := executeStage(executionCtx, plan, payload, handler, e.metricEngine) outcome.Entity = entity(bidder) outcome.Stage = stageName diff --git a/hooks/hookexecution/mocks_test.go b/hooks/hookexecution/mocks_test.go index a0d9e25c9fe..8c34a518bab 100644 --- a/hooks/hookexecution/mocks_test.go +++ b/hooks/hookexecution/mocks_test.go @@ -58,14 +58,12 @@ func (e mockUpdateBodyHook) HandleEntrypointHook(_ context.Context, _ hookstage. func (e mockUpdateBodyHook) HandleRawAuctionHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.RawAuctionRequestPayload) (hookstage.HookResult[hookstage.RawAuctionRequestPayload], error) { c := hookstage.ChangeSet[hookstage.RawAuctionRequestPayload]{} c.AddMutation( - func(payload hookstage.RawAuctionRequestPayload) (hookstage.RawAuctionRequestPayload, error) { - payload = []byte(`{"name": "John", "last_name": "Doe", "foo": "bar"}`) - return payload, nil + func(_ hookstage.RawAuctionRequestPayload) (hookstage.RawAuctionRequestPayload, error) { + return []byte(`{"name": "John", "last_name": "Doe", "foo": "bar"}`), nil }, hookstage.MutationUpdate, "body", "foo", ).AddMutation( - func(payload hookstage.RawAuctionRequestPayload) (hookstage.RawAuctionRequestPayload, error) { - payload = []byte(`{"last_name": "Doe", "foo": "bar"}`) - return payload, nil + func(_ hookstage.RawAuctionRequestPayload) (hookstage.RawAuctionRequestPayload, error) { + return []byte(`{"last_name": "Doe", "foo": "bar"}`), nil }, hookstage.MutationDelete, "body", "name", ) @@ -120,9 +118,8 @@ func (e mockTimeoutHook) HandleEntrypointHook(_ context.Context, _ hookstage.Mod func (e mockTimeoutHook) HandleRawAuctionHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.RawAuctionRequestPayload) (hookstage.HookResult[hookstage.RawAuctionRequestPayload], error) { time.Sleep(20 * time.Millisecond) c := hookstage.ChangeSet[hookstage.RawAuctionRequestPayload]{} - c.AddMutation(func(payload hookstage.RawAuctionRequestPayload) (hookstage.RawAuctionRequestPayload, error) { - payload = []byte(`{"last_name": "Doe", "foo": "bar", "address": "A st."}`) - return payload, nil + c.AddMutation(func(_ hookstage.RawAuctionRequestPayload) (hookstage.RawAuctionRequestPayload, error) { + return []byte(`{"last_name": "Doe", "foo": "bar", "address": "A st."}`), nil }, hookstage.MutationUpdate, "param", "address") return hookstage.HookResult[hookstage.RawAuctionRequestPayload]{ChangeSet: c}, nil diff --git a/metrics/config/metrics_test.go b/metrics/config/metrics_test.go index e201cf52cf5..4139f063b72 100644 --- a/metrics/config/metrics_test.go +++ b/metrics/config/metrics_test.go @@ -48,8 +48,7 @@ func TestMultiMetricsEngine(t *testing.T) { engineList := make(MultiMetricsEngine, 2) engineList[0] = goEngine engineList[1] = &NilMetricsEngine{} - var metricsEngine metrics.MetricsEngine - metricsEngine = &engineList + var metricsEngine metrics.MetricsEngine = &engineList labels := metrics.Labels{ Source: metrics.DemandWeb, RType: metrics.ReqTypeORTB2Web, diff --git a/metrics/prometheus/prometheus_test.go b/metrics/prometheus/prometheus_test.go index 3ce2f222896..fcb9ba6452c 100644 --- a/metrics/prometheus/prometheus_test.go +++ b/metrics/prometheus/prometheus_test.go @@ -1757,7 +1757,7 @@ func getHistogramFromHistogramVecByTwoKeys(histogram *prometheus.HistogramVec, l processMetrics(histogram, func(m dto.Metric) { for ind, label := range m.GetLabel() { if label.GetName() == label1Key && label.GetValue() == label1Value { - valInd := ind + var valInd int if ind == 1 { valInd = 0 } else { diff --git a/router/router.go b/router/router.go index c285bbdab1b..c085c6fc5c9 100644 --- a/router/router.go +++ b/router/router.go @@ -373,7 +373,7 @@ func readDefaultRequest(defReqConfig config.DefReqConfig) (map[string]string, [] } if err := jsonutil.UnmarshalValid(defReqJSON, defReq); err != nil { - // we might not have aliases defined, but will atleast show that the JSON file is parsable. + // we might not have aliases defined, but will at least show that the JSON file is parsable. glog.Fatalf("error parsing alias json in file %s: %v", defReqConfig.FileSystem.FileName, err) return aliases, []byte{} } diff --git a/stored_requests/backends/file_fetcher/fetcher_test.go b/stored_requests/backends/file_fetcher/fetcher_test.go index cc1c0f50989..97206822968 100644 --- a/stored_requests/backends/file_fetcher/fetcher_test.go +++ b/stored_requests/backends/file_fetcher/fetcher_test.go @@ -185,7 +185,7 @@ func TestCategoriesFetcherWithPublisher(t *testing.T) { if err != nil { t.Errorf("Failed to create a category Fetcher: %v", err) } - category, err := fetcher.FetchCategories(nil, "test", "categories", "IAB1-1") + category, err := fetcher.FetchCategories(context.TODO(), "test", "categories", "IAB1-1") assert.Equal(t, nil, err, "Categories were loaded incorrectly") assert.Equal(t, "Beverages", category, "Categories were loaded incorrectly") } @@ -195,7 +195,7 @@ func TestCategoriesFetcherWithoutPublisher(t *testing.T) { if err != nil { t.Errorf("Failed to create a category Fetcher: %v", err) } - category, err := fetcher.FetchCategories(nil, "test", "", "IAB1-1") + category, err := fetcher.FetchCategories(context.TODO(), "test", "", "IAB1-1") assert.Equal(t, nil, err, "Categories were loaded incorrectly") assert.Equal(t, "VideoGames", category, "Categories were loaded incorrectly") } @@ -205,7 +205,7 @@ func TestCategoriesFetcherNoCategory(t *testing.T) { if err != nil { t.Errorf("Failed to create a category Fetcher: %v", err) } - _, fetchingErr := fetcher.FetchCategories(nil, "test", "", "IAB1-100") + _, fetchingErr := fetcher.FetchCategories(context.TODO(), "test", "", "IAB1-100") assert.Equal(t, fmt.Errorf("Unable to find category for adserver 'test', publisherId: '', iab category: 'IAB1-100'"), fetchingErr, "Categories were loaded incorrectly") } @@ -215,7 +215,7 @@ func TestCategoriesFetcherBrokenJson(t *testing.T) { if err != nil { t.Errorf("Failed to create a category Fetcher: %v", err) } - _, fetchingErr := fetcher.FetchCategories(nil, "test", "broken", "IAB1-100") + _, fetchingErr := fetcher.FetchCategories(context.TODO(), "test", "broken", "IAB1-100") assert.Equal(t, fmt.Errorf("Unable to unmarshal categories for adserver: 'test', publisherId: 'broken'"), fetchingErr, "Categories were loaded incorrectly") } @@ -225,7 +225,7 @@ func TestCategoriesFetcherNoCategoriesFile(t *testing.T) { if err != nil { t.Errorf("Failed to create a category Fetcher: %v", err) } - _, fetchingErr := fetcher.FetchCategories(nil, "test", "not_exists", "IAB1-100") + _, fetchingErr := fetcher.FetchCategories(context.TODO(), "test", "not_exists", "IAB1-100") assert.Equal(t, fmt.Errorf("Unable to find mapping file for adserver: 'test', publisherId: 'not_exists'"), fetchingErr, "Categories were loaded incorrectly") } diff --git a/stored_requests/backends/http_fetcher/fetcher.go b/stored_requests/backends/http_fetcher/fetcher.go index 75aa1090ce4..ea388778cc2 100644 --- a/stored_requests/backends/http_fetcher/fetcher.go +++ b/stored_requests/backends/http_fetcher/fetcher.go @@ -207,6 +207,9 @@ func (fetcher *HttpFetcher) FetchCategories(ctx context.Context, primaryAdServer defer httpResp.Body.Close() respBytes, err := io.ReadAll(httpResp.Body) + if err != nil { + return "", fmt.Errorf("Unable to read response body: %v", err) + } tmp := make(map[string]stored_requests.Category) if err := jsonutil.UnmarshalValid(respBytes, &tmp); err != nil { diff --git a/stored_requests/backends/http_fetcher/fetcher_test.go b/stored_requests/backends/http_fetcher/fetcher_test.go index 1358ce413c1..9c7c1cb2505 100644 --- a/stored_requests/backends/http_fetcher/fetcher_test.go +++ b/stored_requests/backends/http_fetcher/fetcher_test.go @@ -105,7 +105,7 @@ func TestFetchAccountsNoIDsProvided(t *testing.T) { fetcher, close := newTestAccountFetcher(t, []string{"acc-1", "acc-2"}) defer close() - accData, errs := fetcher.FetchAccounts(nil, []string{}) + accData, errs := fetcher.FetchAccounts(context.TODO(), []string{}) assert.Empty(t, errs, "Unexpected error fetching empty account list") assert.Nil(t, accData, "Fetching empty account list should return nil") } @@ -115,7 +115,7 @@ func TestFetchAccountsFailedBuildRequest(t *testing.T) { fetcher, close := newTestAccountFetcher(t, []string{"acc-1", "acc-2"}) defer close() - accData, errs := fetcher.FetchAccounts(nil, []string{"acc-1"}) + accData, errs := fetcher.FetchAccounts(nil, []string{"acc-1"}) //nolint: staticcheck // test handling of a nil context assert.Len(t, errs, 1, "Fetching accounts without context should result in error ") assert.Nil(t, accData, "Fetching accounts without context should return nil") } diff --git a/usersync/cookie_test.go b/usersync/cookie_test.go index 1ecfe51b5b5..d3fa72b9fe0 100644 --- a/usersync/cookie_test.go +++ b/usersync/cookie_test.go @@ -646,13 +646,13 @@ func TestReadCookieOptOut(t *testing.T) { optOutCookieValue := "optOutCookieValue" decoder := Base64Decoder{} - cookie := *(&Cookie{ + cookie := Cookie{ uids: map[string]UIDEntry{ "foo": newTempId("fooID", 1), "bar": newTempId("barID", 2), }, optOut: false, - }) + } existingCookie, _ := ToHTTPCookie(&cookie)