diff --git a/adapters/33across/33across.go b/adapters/33across/33across.go index b9f0c98a38f..5e9c8b65721 100644 --- a/adapters/33across/33across.go +++ b/adapters/33across/33across.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type TtxAdapter struct { @@ -76,7 +77,7 @@ func (a *TtxAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapter // Skip over imps whose extensions cannot be read since // we cannot glean Prod or ZoneID which are required to // group together. However let's not block request creation. - if err := json.Unmarshal(impCopy.Ext, &impExt); err == nil { + if err := jsonutil.Unmarshal(impCopy.Ext, &impExt); err == nil { impKey := impExt.Ttx.Prod + impExt.Ttx.Zoneid groupedImps[impKey] = append(groupedImps[impKey], impCopy) } else { @@ -126,14 +127,14 @@ func makeImps(imp openrtb2.Imp) (openrtb2.Imp, error) { } var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return openrtb2.Imp{}, &errortypes.BadInput{ Message: err.Error(), } } var ttxExt openrtb_ext.ExtImp33across - if err := json.Unmarshal(bidderExt.Bidder, &ttxExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &ttxExt); err != nil { return openrtb2.Imp{}, &errortypes.BadInput{ Message: err.Error(), } @@ -177,7 +178,7 @@ func makeReqExt(request *openrtb2.BidRequest) ([]byte, error) { var reqExt reqExt if len(request.Ext) > 0 { - if err := json.Unmarshal(request.Ext, &reqExt); err != nil { + if err := jsonutil.Unmarshal(request.Ext, &reqExt); err != nil { return nil, err } } @@ -215,7 +216,7 @@ func (a *TtxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequ var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -226,7 +227,7 @@ func (a *TtxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequ var bidExt bidExt var bidType openrtb_ext.BidType - if err := json.Unmarshal(sb.Bid[i].Ext, &bidExt); err != nil { + if err := jsonutil.Unmarshal(sb.Bid[i].Ext, &bidExt); err != nil { bidType = openrtb_ext.BidTypeBanner } else { bidType = getBidType(bidExt) diff --git a/adapters/aax/aax.go b/adapters/aax/aax.go index 09a06a1f5bb..a70c5d20c50 100644 --- a/adapters/aax/aax.go +++ b/adapters/aax/aax.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -63,7 +64,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -96,7 +97,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co func getMediaTypeForImp(bid openrtb2.Bid, imps []openrtb2.Imp) (openrtb_ext.BidType, error) { var bidExt aaxResponseBidExt - err := json.Unmarshal(bid.Ext, &bidExt) + err := jsonutil.Unmarshal(bid.Ext, &bidExt) if err == nil { switch bidExt.AdCodeType { case "banner": diff --git a/adapters/aceex/aceex.go b/adapters/aceex/aceex.go index c579fe81c9b..c2bfc83ec4d 100644 --- a/adapters/aceex/aceex.go +++ b/adapters/aceex/aceex.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -90,13 +91,13 @@ func (a *adapter) MakeRequests( func (a *adapter) getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtAceex, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: "ext.bidder not provided", } } var aceexExt openrtb_ext.ExtAceex - if err := json.Unmarshal(bidderExt.Bidder, &aceexExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &aceexExt); err != nil { return nil, &errortypes.BadInput{ Message: "ext.bidder not provided", } @@ -151,7 +152,7 @@ func (a *adapter) MakeBids( responseBody := bidderRawResponse.Body var bidResp openrtb2.BidResponse - if err := json.Unmarshal(responseBody, &bidResp); err != nil { + if err := jsonutil.Unmarshal(responseBody, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Bad Server Response", }} diff --git a/adapters/acuityads/acuityads.go b/adapters/acuityads/acuityads.go index 43d8e1eff97..e2a7077cdbc 100644 --- a/adapters/acuityads/acuityads.go +++ b/adapters/acuityads/acuityads.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type AcuityAdsAdapter struct { @@ -90,13 +91,13 @@ func (a *AcuityAdsAdapter) MakeRequests( func (a *AcuityAdsAdapter) getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtAcuityAds, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: "ext.bidder not provided", } } var acuityAdsExt openrtb_ext.ExtAcuityAds - if err := json.Unmarshal(bidderExt.Bidder, &acuityAdsExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &acuityAdsExt); err != nil { return nil, &errortypes.BadInput{ Message: "ext.bidder not provided", } @@ -155,7 +156,7 @@ func (a *AcuityAdsAdapter) MakeBids( responseBody := bidderRawResponse.Body var bidResp openrtb2.BidResponse - if err := json.Unmarshal(responseBody, &bidResp); err != nil { + if err := jsonutil.Unmarshal(responseBody, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Bad Server Response", }} diff --git a/adapters/adapterstest/test_json.go b/adapters/adapterstest/test_json.go index 78f08421b3d..0935cd18d5d 100644 --- a/adapters/adapterstest/test_json.go +++ b/adapters/adapterstest/test_json.go @@ -8,6 +8,7 @@ import ( "os" "path/filepath" "regexp" + "strings" "testing" "github.com/google/go-cmp/cmp" @@ -273,6 +274,10 @@ func assertErrorList(t *testing.T, description string, actual []error, expected if matched, _ := regexp.MatchString(expected[i].Value, actual[i].Error()); !matched { t.Errorf(`%s error[%d] had wrong message. Expected match with regex "%s", got "%s"`, description, i, expected[i].Value, actual[i].Error()) } + } else if expected[i].Comparison == "startswith" { + if !strings.HasPrefix(actual[i].Error(), expected[i].Value) { + t.Errorf(`%s error[%d] had wrong message. Expected to start with "%s", got "%s"`, description, i, expected[i].Value, actual[i].Error()) + } } else { t.Fatalf(`invalid comparison type "%s"`, expected[i].Comparison) } diff --git a/adapters/adelement/adelement.go b/adapters/adelement/adelement.go index 427741eb077..75629539029 100644 --- a/adapters/adelement/adelement.go +++ b/adapters/adelement/adelement.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -58,13 +59,13 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte func getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtAdelement, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: "ext.bidder not provided", } } var adelementExt openrtb_ext.ExtAdelement - if err := json.Unmarshal(bidderExt.Bidder, &adelementExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &adelementExt); err != nil { return nil, &errortypes.BadInput{ Message: "ext.bidder not provided", } @@ -88,7 +89,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Bad Server Response", }} diff --git a/adapters/adf/adf.go b/adapters/adf/adf.go index afa9bc84562..0d361bcaf3e 100644 --- a/adapters/adf/adf.go +++ b/adapters/adf/adf.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -36,7 +37,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte for _, imp := range request.Imp { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { errors = append(errors, &errortypes.BadInput{ Message: err.Error(), }) @@ -44,7 +45,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte } var adfImpExt openrtb_ext.ExtImpAdf - if err := json.Unmarshal(bidderExt.Bidder, &adfImpExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &adfImpExt); err != nil { errors = append(errors, &errortypes.BadInput{ Message: err.Error(), }) @@ -65,7 +66,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte var err error if len(request.Ext) > 0 { - if err = json.Unmarshal(request.Ext, &requestExt); err != nil { + if err = jsonutil.Unmarshal(request.Ext, &requestExt); err != nil { errors = append(errors, err) } } @@ -117,7 +118,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } @@ -144,7 +145,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) { if bid.Ext != nil { var bidExt openrtb_ext.ExtBid - err := json.Unmarshal(bid.Ext, &bidExt) + err := jsonutil.Unmarshal(bid.Ext, &bidExt) if err == nil && bidExt.Prebid != nil { return openrtb_ext.ParseBidType(string(bidExt.Prebid.Type)) } diff --git a/adapters/adf/adftest/supplemental/unparsable-response.json b/adapters/adf/adftest/supplemental/unparsable-response.json index 5e63febee4c..5a89ff2dd3b 100644 --- a/adapters/adf/adftest/supplemental/unparsable-response.json +++ b/adapters/adf/adftest/supplemental/unparsable-response.json @@ -43,7 +43,7 @@ "expectedBidResponses": [], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/adgeneration/adgeneration.go b/adapters/adgeneration/adgeneration.go index 192680ca9f2..1fc2e62a13d 100644 --- a/adapters/adgeneration/adgeneration.go +++ b/adapters/adgeneration/adgeneration.go @@ -1,7 +1,6 @@ package adgeneration import ( - "encoding/json" "errors" "fmt" "net/http" @@ -15,6 +14,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type AdgenerationAdapter struct { @@ -149,10 +149,10 @@ func (adg *AdgenerationAdapter) getRawQuery(id string, request *openrtb2.BidRequ func unmarshalExtImpAdgeneration(imp *openrtb2.Imp) (*openrtb_ext.ExtImpAdgeneration, error) { var bidderExt adapters.ExtImpBidder var adgExt openrtb_ext.ExtImpAdgeneration - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, err } - if err := json.Unmarshal(bidderExt.Bidder, &adgExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &adgExt); err != nil { return nil, err } if adgExt.Id == "" { @@ -203,7 +203,7 @@ func (adg *AdgenerationAdapter) MakeBids(internalRequest *openrtb2.BidRequest, e }} } var bidResp adgServerResponse - err := json.Unmarshal(response.Body, &bidResp) + err := jsonutil.Unmarshal(response.Body, &bidResp) if err != nil { return nil, []error{err} } diff --git a/adapters/adhese/adhese.go b/adapters/adhese/adhese.go index 09bd4ba8041..988d720bfd7 100644 --- a/adapters/adhese/adhese.go +++ b/adapters/adhese/adhese.go @@ -16,6 +16,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type AdheseAdapter struct { @@ -32,7 +33,7 @@ func extractTargetParameters(parameters openrtb_ext.ExtImpAdhese) string { } var parametersAsString = "" var targetParsed map[string]interface{} - err := json.Unmarshal(parameters.Keywords, &targetParsed) + err := jsonutil.Unmarshal(parameters.Keywords, &targetParsed) if err != nil { return "" } @@ -59,7 +60,7 @@ func extractTargetParameters(parameters openrtb_ext.ExtImpAdhese) string { func extractGdprParameter(request *openrtb2.BidRequest) string { if request.User != nil { var extUser openrtb_ext.ExtUser - if err := json.Unmarshal(request.User.Ext, &extUser); err == nil { + if err := jsonutil.Unmarshal(request.User.Ext, &extUser); err == nil { return "/xt" + extUser.Consent } } @@ -94,13 +95,13 @@ func (a *AdheseAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adap var imp = &request.Imp[0] var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { errs = append(errs, WrapReqError("Request could not be parsed as ExtImpBidder due to: "+err.Error())) return nil, errs } var params openrtb_ext.ExtImpAdhese - if err := json.Unmarshal(bidderExt.Bidder, ¶ms); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, ¶ms); err != nil { errs = append(errs, WrapReqError("Request could not be parsed as ExtImpAdhese due to: "+err.Error())) return nil, errs } @@ -138,7 +139,7 @@ func (a *AdheseAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalR var bidResponse openrtb2.BidResponse var adheseBidResponseArray []AdheseBid - if err := json.Unmarshal(response.Body, &adheseBidResponseArray); err != nil { + if err := jsonutil.Unmarshal(response.Body, &adheseBidResponseArray); err != nil { return nil, []error{err, WrapServerError(fmt.Sprintf("Response %v could not be parsed as generic Adhese bid.", string(response.Body)))} } @@ -150,11 +151,11 @@ func (a *AdheseAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalR if adheseBid.Origin == "JERLICIA" { var extArray []AdheseExt var originDataArray []AdheseOriginData - if err := json.Unmarshal(response.Body, &extArray); err != nil { + if err := jsonutil.Unmarshal(response.Body, &extArray); err != nil { return nil, []error{err, WrapServerError(fmt.Sprintf("Response %v could not be parsed to JERLICIA ext.", string(response.Body)))} } - if err := json.Unmarshal(response.Body, &originDataArray); err != nil { + if err := jsonutil.Unmarshal(response.Body, &originDataArray); err != nil { return nil, []error{err, WrapServerError(fmt.Sprintf("Response %v could not be parsed to JERLICIA origin data.", string(response.Body)))} } bidResponse = convertAdheseBid(adheseBid, extArray[0], originDataArray[0]) diff --git a/adapters/adhese/adhesetest/supplemental/req-invalid-empty-imp-ext.json b/adapters/adhese/adhesetest/supplemental/req-invalid-empty-imp-ext.json index e98823b2914..9169847be35 100644 --- a/adapters/adhese/adhesetest/supplemental/req-invalid-empty-imp-ext.json +++ b/adapters/adhese/adhesetest/supplemental/req-invalid-empty-imp-ext.json @@ -31,8 +31,8 @@ "expectedBidResponses": [], "expectedMakeRequestsErrors": [ { - "value": "Request could not be parsed as ExtImpAdhese due to: unexpected end of JSON input", - "comparison": "literal" + "value": "Request could not be parsed as ExtImpAdhese due to: expect { or n, but found", + "comparison": "startswith" } ] } \ No newline at end of file diff --git a/adapters/adhese/adhesetest/supplemental/req-invalid-no-imp-ext.json b/adapters/adhese/adhesetest/supplemental/req-invalid-no-imp-ext.json index bcb891719ae..76f5315c1cb 100644 --- a/adapters/adhese/adhesetest/supplemental/req-invalid-no-imp-ext.json +++ b/adapters/adhese/adhesetest/supplemental/req-invalid-no-imp-ext.json @@ -30,8 +30,8 @@ "expectedBidResponses": [], "expectedMakeRequestsErrors": [ { - "value": "Request could not be parsed as ExtImpBidder due to: unexpected end of JSON input", - "comparison": "literal" + "value": "Request could not be parsed as ExtImpBidder due to: expect { or n, but found", + "comparison": "startswith" } ] } \ No newline at end of file diff --git a/adapters/adhese/adhesetest/supplemental/res-invalid-height.json b/adapters/adhese/adhesetest/supplemental/res-invalid-height.json index 86ff3e49692..4c7989cb56b 100644 --- a/adapters/adhese/adhesetest/supplemental/res-invalid-height.json +++ b/adapters/adhese/adhesetest/supplemental/res-invalid-height.json @@ -82,7 +82,7 @@ "expectedBidResponses": [], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal number into Go struct field AdheseBid.height of type string", + "value": "cannot unmarshal adhese.AdheseBid.Height: expects \" or n, but found 9", "comparison": "literal" }, { "value": "Response (.*\n.*)+ could not be parsed as generic Adhese bid", diff --git a/adapters/adhese/adhesetest/supplemental/res-invalid-no-body.json b/adapters/adhese/adhesetest/supplemental/res-invalid-no-body.json index f05ca15a862..1ec91d9ad0a 100644 --- a/adapters/adhese/adhesetest/supplemental/res-invalid-no-body.json +++ b/adapters/adhese/adhesetest/supplemental/res-invalid-no-body.json @@ -53,8 +53,8 @@ "expectedBidResponses": [], "expectedMakeBidsErrors": [ { - "value": "unexpected end of JSON input", - "comparison": "literal" + "value": "decode slice: expect [ or n, but found", + "comparison": "startswith" },{ "value": "Response could not be parsed as generic Adhese bid.", "comparison": "literal" diff --git a/adapters/adhese/adhesetest/supplemental/res-invalid-price.json b/adapters/adhese/adhesetest/supplemental/res-invalid-price.json index 9505af358bf..7fcbc298876 100644 --- a/adapters/adhese/adhesetest/supplemental/res-invalid-price.json +++ b/adapters/adhese/adhesetest/supplemental/res-invalid-price.json @@ -82,7 +82,7 @@ "expectedBidResponses": [], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal number into Go struct field CPMValues.*\\.amount of type string", + "value": "cannot unmarshal adhese.CPMValues.Amount: expects \" or n, but found 1", "comparison": "regex" }, { "value": "Response (.*\n.*)+ could not be parsed as generic Adhese bid", diff --git a/adapters/adhese/adhesetest/supplemental/res-invalid-width.json b/adapters/adhese/adhesetest/supplemental/res-invalid-width.json index b554ed65450..139a5c598a1 100644 --- a/adapters/adhese/adhesetest/supplemental/res-invalid-width.json +++ b/adapters/adhese/adhesetest/supplemental/res-invalid-width.json @@ -82,7 +82,7 @@ "expectedBidResponses": [], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal number into Go struct field AdheseBid.width of type string", + "value": "cannot unmarshal adhese.AdheseBid.Width: expects \" or n, but found 7", "comparison": "literal" }, { "value": "Response (.*\n.*)+ could not be parsed as generic Adhese bid", diff --git a/adapters/adkernel/adkernel.go b/adapters/adkernel/adkernel.go index 2b3df333975..6b575ff540b 100644 --- a/adapters/adkernel/adkernel.go +++ b/adapters/adkernel/adkernel.go @@ -14,6 +14,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) const ( @@ -169,13 +170,13 @@ func splitMultiFormatImp(imp *openrtb2.Imp) []openrtb2.Imp { func getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpAdkernel, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: err.Error(), } } var adkernelExt openrtb_ext.ExtImpAdkernel - if err := json.Unmarshal(bidderExt.Bidder, &adkernelExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &adkernelExt); err != nil { return nil, &errortypes.BadInput{ Message: err.Error(), } @@ -243,7 +244,7 @@ func (adapter *adkernelAdapter) MakeBids(internalRequest *openrtb2.BidRequest, e } } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{ newBadServerResponseError(fmt.Sprintf("Bad server response: %d", err)), } diff --git a/adapters/adkernelAdn/adkernelAdn.go b/adapters/adkernelAdn/adkernelAdn.go index 33e5ee93b05..1f7928f5706 100644 --- a/adapters/adkernelAdn/adkernelAdn.go +++ b/adapters/adkernelAdn/adkernelAdn.go @@ -13,6 +13,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adkernelAdnAdapter struct { @@ -149,13 +150,13 @@ func compatVideoImpression(imp *openrtb2.Imp) error { func getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpAdkernelAdn, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: err.Error(), } } var adkernelAdnExt openrtb_ext.ExtImpAdkernelAdn - if err := json.Unmarshal(bidderExt.Bidder, &adkernelAdnExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &adkernelAdnExt); err != nil { return nil, &errortypes.BadInput{ Message: err.Error(), } @@ -226,7 +227,7 @@ func (adapter *adkernelAdnAdapter) MakeBids(internalRequest *openrtb2.BidRequest } } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{ newBadServerResponseError(fmt.Sprintf("Bad server response: %d", err)), } diff --git a/adapters/adkernelAdn/adkerneladntest/supplemental/wrong-imp-ext-1.json b/adapters/adkernelAdn/adkerneladntest/supplemental/wrong-imp-ext-1.json index 8b2b5837e13..4d5b3228d16 100644 --- a/adapters/adkernelAdn/adkerneladntest/supplemental/wrong-imp-ext-1.json +++ b/adapters/adkernelAdn/adkerneladntest/supplemental/wrong-imp-ext-1.json @@ -18,8 +18,8 @@ "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go struct field ExtImpAdkernelAdn.pubId of type int", - "comparison": "literal" + "value": "cannot unmarshal openrtb_ext.ExtImpAdkernelAdn.PublisherID: unexpected character", + "comparison": "startswith" } ] } diff --git a/adapters/adman/adman.go b/adapters/adman/adman.go index e6a4da712b3..fa9db61be39 100644 --- a/adapters/adman/adman.go +++ b/adapters/adman/adman.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) // AdmanAdapter struct @@ -38,12 +39,12 @@ func (a *AdmanAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapt reqCopy.Imp = []openrtb2.Imp{imp} var bidderExt adapters.ExtImpBidder - if err = json.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { + if err = jsonutil.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { errs = append(errs, err) continue } - if err = json.Unmarshal(bidderExt.Bidder, &admanExt); err != nil { + if err = jsonutil.Unmarshal(bidderExt.Bidder, &admanExt); err != nil { errs = append(errs, err) continue } @@ -98,7 +99,7 @@ func (a *AdmanAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRe var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/adman/admantest/supplemental/bad-imp-ext.json b/adapters/adman/admantest/supplemental/bad-imp-ext.json index db3c8de5767..a4b5cc546f4 100644 --- a/adapters/adman/admantest/supplemental/bad-imp-ext.json +++ b/adapters/adman/admantest/supplemental/bad-imp-ext.json @@ -35,8 +35,8 @@ }, "expectedMakeRequestsErrors": [ { - "value": "unexpected end of JSON input", - "comparison": "literal" + "value": "expect { or n, but found", + "comparison": "startswith" } ] } diff --git a/adapters/adman/admantest/supplemental/bad_response.json b/adapters/adman/admantest/supplemental/bad_response.json index f9920c9069d..96d7a6098ca 100644 --- a/adapters/adman/admantest/supplemental/bad_response.json +++ b/adapters/adman/admantest/supplemental/bad_response.json @@ -79,7 +79,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/adman/admantest/supplemental/no-imp-ext-1.json b/adapters/adman/admantest/supplemental/no-imp-ext-1.json index 8fad5ba5ef0..d93995bb33e 100644 --- a/adapters/adman/admantest/supplemental/no-imp-ext-1.json +++ b/adapters/adman/admantest/supplemental/no-imp-ext-1.json @@ -31,7 +31,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/adman/admantest/supplemental/no-imp-ext-2.json b/adapters/adman/admantest/supplemental/no-imp-ext-2.json index 337dfd044b3..677260f21e4 100644 --- a/adapters/adman/admantest/supplemental/no-imp-ext-2.json +++ b/adapters/adman/admantest/supplemental/no-imp-ext-2.json @@ -31,8 +31,8 @@ }, "expectedMakeRequestsErrors": [ { - "value": "unexpected end of JSON input", - "comparison": "literal" + "value": "expect { or n, but found", + "comparison": "startswith" } ] } diff --git a/adapters/admatic/admatic.go b/adapters/admatic/admatic.go index 94d966dbfbe..40d6c53b2ac 100644 --- a/adapters/admatic/admatic.go +++ b/adapters/admatic/admatic.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -65,14 +66,14 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte func (a *adapter) buildEndpointFromRequest(imp *openrtb2.Imp) (string, error) { var impExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &impExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &impExt); err != nil { return "", &errortypes.BadInput{ Message: fmt.Sprintf("Failed to deserialize bidder impression extension: %v", err), } } var admaticExt openrtb_ext.ImpExtAdmatic - if err := json.Unmarshal(impExt.Bidder, &admaticExt); err != nil { + if err := jsonutil.Unmarshal(impExt.Bidder, &admaticExt); err != nil { return "", &errortypes.BadInput{ Message: fmt.Sprintf("Failed to deserialize AdMatic extension: %v", err), } @@ -95,7 +96,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R return nil, []error{err} } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/admatic/admatictest/supplemental/multiple-imps-with-error.json b/adapters/admatic/admatictest/supplemental/multiple-imps-with-error.json index c080e57c7e5..b23c794c1ba 100644 --- a/adapters/admatic/admatictest/supplemental/multiple-imps-with-error.json +++ b/adapters/admatic/admatictest/supplemental/multiple-imps-with-error.json @@ -93,7 +93,7 @@ ], "expectedMakeRequestsErrors": [ { - "value": "Failed to deserialize AdMatic extension: json: cannot unmarshal object into Go struct field ImpExtAdmatic.host of type string", + "value": "Failed to deserialize AdMatic extension: cannot unmarshal openrtb_ext.ImpExtAdmatic.Host: expects \" or n, but found {", "comparison": "literal" } ], diff --git a/adapters/admatic/admatictest/supplemental/response-200-without-body.json b/adapters/admatic/admatictest/supplemental/response-200-without-body.json index 8db31ad713f..6cded7606e2 100644 --- a/adapters/admatic/admatictest/supplemental/response-200-without-body.json +++ b/adapters/admatic/admatictest/supplemental/response-200-without-body.json @@ -57,8 +57,8 @@ ], "expectedMakeBidsErrors": [ { - "value": "unexpected end of JSON input", - "comparison": "literal" + "value": "expect { or n, but found", + "comparison": "startswith" } ] -} +} \ No newline at end of file diff --git a/adapters/admixer/admixer.go b/adapters/admixer/admixer.go index 968b5954103..a8049bc1ea9 100644 --- a/adapters/admixer/admixer.go +++ b/adapters/admixer/admixer.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type AdmixerAdapter struct { @@ -87,14 +88,14 @@ func (a *AdmixerAdapter) makeRequest(request *openrtb2.BidRequest) (*adapters.Re func preprocess(imp *openrtb2.Imp) error { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return &errortypes.BadInput{ Message: err.Error(), } } var admixerExt openrtb_ext.ExtImpAdmixer - if err := json.Unmarshal(bidderExt.Bidder, &admixerExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &admixerExt); err != nil { return &errortypes.BadInput{ Message: "Wrong Admixer bidder ext", } @@ -154,7 +155,7 @@ func (a *AdmixerAdapter) MakeBids(internalRequest *openrtb2.BidRequest, external } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/adnuntius/adnuntius.go b/adapters/adnuntius/adnuntius.go index a28ac669795..1937f41e3eb 100644 --- a/adapters/adnuntius/adnuntius.go +++ b/adapters/adnuntius/adnuntius.go @@ -14,6 +14,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" "github.com/prebid/prebid-server/v2/util/timeutil" ) @@ -140,7 +141,7 @@ func makeEndpointUrl(ortbRequest openrtb2.BidRequest, a *adapter, noCookies bool if !noCookies { var deviceExt extDeviceAdnuntius if ortbRequest.Device != nil && ortbRequest.Device.Ext != nil { - if err := json.Unmarshal(ortbRequest.Device.Ext, &deviceExt); err != nil { + if err := jsonutil.Unmarshal(ortbRequest.Device.Ext, &deviceExt); err != nil { return "", []error{fmt.Errorf("failed to parse Adnuntius endpoint: %v", err)} } } @@ -211,14 +212,14 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters } var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, []error{&errortypes.BadInput{ Message: fmt.Sprintf("Error unmarshalling ExtImpBidder: %s", err.Error()), }} } var adnuntiusExt openrtb_ext.ImpExtAdnunitus - if err := json.Unmarshal(bidderExt.Bidder, &adnuntiusExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &adnuntiusExt); err != nil { return nil, []error{&errortypes.BadInput{ Message: fmt.Sprintf("Error unmarshalling ExtImpValues: %s", err.Error()), }} @@ -273,7 +274,7 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters var extUser openrtb_ext.ExtUser if ortbRequest.User != nil && ortbRequest.User.Ext != nil { - if err := json.Unmarshal(ortbRequest.User.Ext, &extUser); err != nil { + if err := jsonutil.Unmarshal(ortbRequest.User.Ext, &extUser); err != nil { return nil, []error{fmt.Errorf("failed to parse Ext User: %v", err)} } } @@ -328,7 +329,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, externalRequest *adapte } var adnResponse AdnResponse - if err := json.Unmarshal(response.Body, &adnResponse); err != nil { + if err := jsonutil.Unmarshal(response.Body, &adnResponse); err != nil { return nil, []error{err} } @@ -343,7 +344,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, externalRequest *adapte func getSiteExtAsKv(request *openrtb2.BidRequest) (siteExt, error) { var extSite siteExt if request.Site != nil && request.Site.Ext != nil { - if err := json.Unmarshal(request.Site.Ext, &extSite); err != nil { + if err := jsonutil.Unmarshal(request.Site.Ext, &extSite); err != nil { return extSite, fmt.Errorf("failed to parse ExtSite in Adnuntius: %v", err) } } @@ -355,7 +356,7 @@ func getGDPR(request *openrtb2.BidRequest) (string, string, error) { gdpr := "" var extRegs openrtb_ext.ExtRegs if request.Regs != nil && request.Regs.Ext != nil { - if err := json.Unmarshal(request.Regs.Ext, &extRegs); err != nil { + if err := jsonutil.Unmarshal(request.Regs.Ext, &extRegs); err != nil { return "", "", fmt.Errorf("failed to parse ExtRegs in Adnuntius GDPR check: %v", err) } if extRegs.GDPR != nil && (*extRegs.GDPR == 0 || *extRegs.GDPR == 1) { @@ -366,7 +367,7 @@ func getGDPR(request *openrtb2.BidRequest) (string, string, error) { consent := "" if request.User != nil && request.User.Ext != nil { var extUser openrtb_ext.ExtUser - if err := json.Unmarshal(request.User.Ext, &extUser); err != nil { + if err := jsonutil.Unmarshal(request.User.Ext, &extUser); err != nil { return "", "", fmt.Errorf("failed to parse ExtUser in Adnuntius GDPR check: %v", err) } consent = extUser.Consent @@ -381,7 +382,7 @@ func generateReturnExt(ad Ad, request *openrtb2.BidRequest) (json.RawMessage, er var requestRegsExt *openrtb_ext.ExtRegs if request.Regs != nil && request.Regs.Ext != nil { - if err := json.Unmarshal(request.Regs.Ext, &requestRegsExt); err != nil { + if err := jsonutil.Unmarshal(request.Regs.Ext, &requestRegsExt); err != nil { return nil, fmt.Errorf("Failed to parse Ext information in Adnuntius: %v", err) } @@ -428,14 +429,14 @@ func generateAdResponse(ad Ad, imp openrtb2.Imp, html string, request *openrtb2. price := ad.Bid.Amount var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, []error{&errortypes.BadInput{ Message: fmt.Sprintf("Error unmarshalling ExtImpBidder: %s", err.Error()), }} } var adnuntiusExt openrtb_ext.ImpExtAdnunitus - if err := json.Unmarshal(bidderExt.Bidder, &adnuntiusExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &adnuntiusExt); err != nil { return nil, []error{&errortypes.BadInput{ Message: fmt.Sprintf("Error unmarshalling ExtImpValues: %s", err.Error()), }} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/check-price-type-error.json b/adapters/adnuntius/adnuntiustest/supplemental/check-price-type-error.json index 89016087a43..35129b1ee54 100644 --- a/adapters/adnuntius/adnuntiustest/supplemental/check-price-type-error.json +++ b/adapters/adnuntius/adnuntiustest/supplemental/check-price-type-error.json @@ -31,7 +31,7 @@ "httpCalls": [], "expectedMakeRequestsErrors": [ { - "value": "Error unmarshalling ExtImpValues: json: cannot unmarshal number into Go struct field ImpExtAdnunitus.bidType of type string", + "value": "Error unmarshalling ExtImpValues: cannot unmarshal openrtb_ext.ImpExtAdnunitus.BidType: expects \" or n, but found 1", "comparison": "literal" } ] diff --git a/adapters/adnuntius/adnuntiustest/supplemental/height-error.json b/adapters/adnuntius/adnuntiustest/supplemental/height-error.json index 770f1db032f..4f066aa7e1f 100644 --- a/adapters/adnuntius/adnuntiustest/supplemental/height-error.json +++ b/adapters/adnuntius/adnuntiustest/supplemental/height-error.json @@ -82,7 +82,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal number into Go struct field Ad.AdUnits.Ads.CreativeHeight of type string", + "value": "cannot unmarshal adnuntius.Ad.CreativeHeight: expects \" or n, but found 2", "comparison": "literal" } ] diff --git a/adapters/adnuntius/adnuntiustest/supplemental/invalid-regs-ext.json b/adapters/adnuntius/adnuntiustest/supplemental/invalid-regs-ext.json index bf0365f60a9..27e043de1cb 100644 --- a/adapters/adnuntius/adnuntiustest/supplemental/invalid-regs-ext.json +++ b/adapters/adnuntius/adnuntiustest/supplemental/invalid-regs-ext.json @@ -39,7 +39,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "failed to parse URL: [failed to parse Adnuntius endpoint: failed to parse ExtRegs in Adnuntius GDPR check: json: cannot unmarshal string into Go value of type openrtb_ext.ExtRegs]", + "value": "failed to parse URL: [failed to parse Adnuntius endpoint: failed to parse ExtRegs in Adnuntius GDPR check: expect { or n, but found \"]", "comparison": "literal" } ] diff --git a/adapters/adnuntius/adnuntiustest/supplemental/width-error.json b/adapters/adnuntius/adnuntiustest/supplemental/width-error.json index 63d52302376..96d98a98b85 100644 --- a/adapters/adnuntius/adnuntiustest/supplemental/width-error.json +++ b/adapters/adnuntius/adnuntiustest/supplemental/width-error.json @@ -82,7 +82,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal number into Go struct field Ad.AdUnits.Ads.CreativeWidth of type string", + "value": "cannot unmarshal adnuntius.Ad.CreativeWidth: expects \" or n, but found 9", "comparison": "literal" } ] diff --git a/adapters/adocean/adocean.go b/adapters/adocean/adocean.go index 560df4893b9..2c3b3a3217e 100644 --- a/adapters/adocean/adocean.go +++ b/adapters/adocean/adocean.go @@ -1,7 +1,6 @@ package adocean import ( - "encoding/json" "errors" "fmt" "math/rand" @@ -19,6 +18,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) const adapterVersion = "1.3.0" @@ -91,7 +91,7 @@ func (a *AdOceanAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada consentString := "" if request.User != nil { var extUser openrtb_ext.ExtUser - if err := json.Unmarshal(request.User.Ext, &extUser); err == nil { + if err := jsonutil.Unmarshal(request.User.Ext, &extUser); err == nil { consentString = extUser.Consent } } @@ -126,14 +126,14 @@ func (a *AdOceanAdapter) addNewBid( consentString string, ) ([]*requestData, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return requestsData, &errortypes.BadInput{ Message: "Error parsing bidderExt object", } } var adOceanExt openrtb_ext.ExtImpAdOcean - if err := json.Unmarshal(bidderExt.Bidder, &adOceanExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &adOceanExt); err != nil { return requestsData, &errortypes.BadInput{ Message: "Error parsing adOceanExt parameters", } @@ -349,7 +349,7 @@ func (a *AdOceanAdapter) MakeBids( auctionIDs := queryParams["aid"] bidResponses := make([]ResponseAdUnit, 0) - if err := json.Unmarshal(response.Body, &bidResponses); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResponses); err != nil { return nil, []error{err} } diff --git a/adapters/adocean/adoceantest/supplemental/app.json b/adapters/adocean/adoceantest/supplemental/app.json index b68798d362c..28c67bdf818 100644 --- a/adapters/adocean/adoceantest/supplemental/app.json +++ b/adapters/adocean/adoceantest/supplemental/app.json @@ -65,7 +65,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type []adocean.ResponseAdUnit", + "value": "decode slice: expect [ or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/adocean/adoceantest/supplemental/bad-response.json b/adapters/adocean/adoceantest/supplemental/bad-response.json index 9bf3ab16069..eb1bcb6ef0c 100644 --- a/adapters/adocean/adoceantest/supplemental/bad-response.json +++ b/adapters/adocean/adoceantest/supplemental/bad-response.json @@ -60,7 +60,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type []adocean.ResponseAdUnit", + "value": "decode slice: expect [ or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/adoppler/adoppler.go b/adapters/adoppler/adoppler.go index ff588991493..0755f90faf9 100644 --- a/adapters/adoppler/adoppler.go +++ b/adapters/adoppler/adoppler.go @@ -14,6 +14,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) const DefaultClient = "app" @@ -121,7 +122,7 @@ func (ads *AdopplerAdapter) MakeBids( } var bidResp openrtb2.BidResponse - err := json.Unmarshal(resp.Body, &bidResp) + err := jsonutil.Unmarshal(resp.Body, &bidResp) if err != nil { err := &errortypes.BadServerResponse{ Message: fmt.Sprintf("invalid body: %s", err.Error()), @@ -206,13 +207,13 @@ func (ads *AdopplerAdapter) bidUri(ext *openrtb_ext.ExtImpAdoppler) (string, err func unmarshalExt(ext json.RawMessage) (*openrtb_ext.ExtImpAdoppler, error) { var bext adapters.ExtImpBidder - err := json.Unmarshal(ext, &bext) + err := jsonutil.Unmarshal(ext, &bext) if err != nil { return nil, err } var adsExt openrtb_ext.ExtImpAdoppler - err = json.Unmarshal(bext.Bidder, &adsExt) + err = jsonutil.Unmarshal(bext.Bidder, &adsExt) if err != nil { return nil, err } @@ -228,7 +229,7 @@ func unmarshalAdsExt(ext json.RawMessage) (*adsImpExt, error) { var e struct { Ads *adsImpExt `json:"ads"` } - err := json.Unmarshal(ext, &e) + err := jsonutil.Unmarshal(ext, &e) return e.Ads, err } diff --git a/adapters/adoppler/adopplertest/supplemental/invalid-response.json b/adapters/adoppler/adopplertest/supplemental/invalid-response.json index 14853d68bdc..84342feaa0e 100644 --- a/adapters/adoppler/adopplertest/supplemental/invalid-response.json +++ b/adapters/adoppler/adopplertest/supplemental/invalid-response.json @@ -50,7 +50,7 @@ ], "expectedMakeBidsErrors":[ { - "value":"invalid body: json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value":"invalid body: expect { or n, but found \"", "comparison":"literal" } ] diff --git a/adapters/adoppler/adopplertest/supplemental/invalid-video-ext.json b/adapters/adoppler/adopplertest/supplemental/invalid-video-ext.json index 84af94e2e3f..6bab4036c5c 100644 --- a/adapters/adoppler/adopplertest/supplemental/invalid-video-ext.json +++ b/adapters/adoppler/adopplertest/supplemental/invalid-video-ext.json @@ -140,7 +140,7 @@ "comparison":"literal" }, { - "value":"json: cannot unmarshal string into Go value of type struct { Ads *adoppler.adsImpExt \"json:\\\"ads\\\"\" }", + "value":"expect { or n, but found \"", "comparison":"literal" } ] diff --git a/adapters/adot/adot.go b/adapters/adot/adot.go index f86281bf79e..9b053286d75 100644 --- a/adapters/adot/adot.go +++ b/adapters/adot/adot.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -84,7 +85,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -116,7 +117,7 @@ func getMediaTypeForBid(bid *openrtb2.Bid) (openrtb_ext.BidType, error) { } var impExt adotBidExt - if err := json.Unmarshal(bid.Ext, &impExt); err == nil { + if err := jsonutil.Unmarshal(bid.Ext, &impExt); err == nil { switch impExt.Adot.MediaType { case string(openrtb_ext.BidTypeBanner): return openrtb_ext.BidTypeBanner, nil @@ -144,11 +145,11 @@ func resolveMacros(bid *openrtb2.Bid) { func getImpAdotExt(imp *openrtb2.Imp) *openrtb_ext.ExtImpAdot { var extImpAdot openrtb_ext.ExtImpAdot var extBidder adapters.ExtImpBidder - err := json.Unmarshal(imp.Ext, &extBidder) + err := jsonutil.Unmarshal(imp.Ext, &extBidder) if err != nil { return nil } - err = json.Unmarshal(extBidder.Bidder, &extImpAdot) + err = jsonutil.Unmarshal(extBidder.Bidder, &extImpAdot) if err != nil { return nil } diff --git a/adapters/adot/adottest/supplemental/unmarshal_error.json b/adapters/adot/adottest/supplemental/unmarshal_error.json index c9c6db88ea7..68154164f47 100644 --- a/adapters/adot/adottest/supplemental/unmarshal_error.json +++ b/adapters/adot/adottest/supplemental/unmarshal_error.json @@ -56,7 +56,7 @@ "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/adpone/adpone.go b/adapters/adpone/adpone.go index c4965f927a9..ada174e5ef9 100644 --- a/adapters/adpone/adpone.go +++ b/adapters/adpone/adpone.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/errortypes" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) // Builder builds a new instance of the Adpone adapter for the given bidder with the given config. @@ -35,11 +36,11 @@ func (adapter *adponeAdapter) MakeRequests( if len(openRTBRequest.Imp) > 0 { var imp = &openRTBRequest.Imp[0] var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { errs = append(errs, newBadInputError(err.Error())) } var ttxExt openrtb_ext.ExtAdpone - if err := json.Unmarshal(bidderExt.Bidder, &ttxExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &ttxExt); err != nil { errs = append(errs, newBadInputError(err.Error())) } } @@ -101,7 +102,7 @@ func (adapter *adponeAdapter) MakeBids( } var openRTBBidderResponse openrtb2.BidResponse - if err := json.Unmarshal(bidderRawResponse.Body, &openRTBBidderResponse); err != nil { + if err := jsonutil.Unmarshal(bidderRawResponse.Body, &openRTBBidderResponse); err != nil { return nil, []error{err} } diff --git a/adapters/adpone/adponetest/supplemental/bad_response.json b/adapters/adpone/adponetest/supplemental/bad_response.json index 38714ea78b4..2200f89ecd4 100644 --- a/adapters/adpone/adponetest/supplemental/bad_response.json +++ b/adapters/adpone/adponetest/supplemental/bad_response.json @@ -57,7 +57,7 @@ "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/adprime/adprime.go b/adapters/adprime/adprime.go index 2c6c319ef05..ed624dc4d33 100644 --- a/adapters/adprime/adprime.go +++ b/adapters/adprime/adprime.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) // AdprimeAdapter struct @@ -40,13 +41,13 @@ func (a *AdprimeAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada for _, imp := range request.Imp { reqCopy.Imp = []openrtb2.Imp{imp} - err = json.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt) + err = jsonutil.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt) if err != nil { errs = append(errs, err) return nil, errs } - err = json.Unmarshal(bidderExt.Bidder, &adprimeExt) + err = jsonutil.Unmarshal(bidderExt.Bidder, &adprimeExt) if err != nil { errs = append(errs, err) return nil, errs @@ -141,7 +142,7 @@ func (a *AdprimeAdapter) MakeBids(internalRequest *openrtb2.BidRequest, external var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/adprime/adprimetest/supplemental/bad-imp-ext.json b/adapters/adprime/adprimetest/supplemental/bad-imp-ext.json index 39cd3cd02ce..d2ce5d82cb2 100644 --- a/adapters/adprime/adprimetest/supplemental/bad-imp-ext.json +++ b/adapters/adprime/adprimetest/supplemental/bad-imp-ext.json @@ -35,8 +35,8 @@ }, "expectedMakeRequestsErrors": [ { - "value": "unexpected end of JSON input", - "comparison": "literal" + "value": "expect { or n, but found", + "comparison": "startswith" } ] } \ No newline at end of file diff --git a/adapters/adprime/adprimetest/supplemental/bad_response.json b/adapters/adprime/adprimetest/supplemental/bad_response.json index f28c8864d8e..9893a1a6684 100644 --- a/adapters/adprime/adprimetest/supplemental/bad_response.json +++ b/adapters/adprime/adprimetest/supplemental/bad_response.json @@ -81,7 +81,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/adprime/adprimetest/supplemental/no-imp-ext-1.json b/adapters/adprime/adprimetest/supplemental/no-imp-ext-1.json index 5ba65925a70..ef5c3009a34 100644 --- a/adapters/adprime/adprimetest/supplemental/no-imp-ext-1.json +++ b/adapters/adprime/adprimetest/supplemental/no-imp-ext-1.json @@ -31,7 +31,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/adprime/adprimetest/supplemental/no-imp-ext-2.json b/adapters/adprime/adprimetest/supplemental/no-imp-ext-2.json index e08f5385b88..f9378c48881 100644 --- a/adapters/adprime/adprimetest/supplemental/no-imp-ext-2.json +++ b/adapters/adprime/adprimetest/supplemental/no-imp-ext-2.json @@ -31,8 +31,8 @@ }, "expectedMakeRequestsErrors": [ { - "value": "unexpected end of JSON input", - "comparison": "literal" + "value": "expect { or n, but found", + "comparison": "startswith" } ] } \ No newline at end of file diff --git a/adapters/adquery/adquery.go b/adapters/adquery/adquery.go index f615c6ad27d..1815d9b8cbb 100644 --- a/adapters/adquery/adquery.go +++ b/adapters/adquery/adquery.go @@ -13,6 +13,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) const ( @@ -160,13 +161,13 @@ func buildRequest(bidReq *openrtb2.BidRequest, imp *openrtb2.Imp, ext *openrtb_e func parseExt(ext json.RawMessage) (*openrtb_ext.ImpExtAdQuery, error) { var bext adapters.ExtImpBidder - err := json.Unmarshal(ext, &bext) + err := jsonutil.Unmarshal(ext, &bext) if err != nil { return nil, err } var adsExt openrtb_ext.ImpExtAdQuery - err = json.Unmarshal(bext.Bidder, &adsExt) + err = jsonutil.Unmarshal(bext.Bidder, &adsExt) if err != nil { return nil, err } @@ -177,7 +178,7 @@ func parseExt(ext json.RawMessage) (*openrtb_ext.ImpExtAdQuery, error) { func parseResponseJson(respBody []byte) (*ResponseData, float64, int64, int64, []error) { var response ResponseAdQuery - if err := json.Unmarshal(respBody, &response); err != nil { + if err := jsonutil.Unmarshal(respBody, &response); err != nil { return nil, 0, 0, 0, []error{err} } diff --git a/adapters/adquery/adquerytest/supplemental/malformed-ext.json b/adapters/adquery/adquerytest/supplemental/malformed-ext.json index 46aaaed431d..aa035c5852b 100644 --- a/adapters/adquery/adquerytest/supplemental/malformed-ext.json +++ b/adapters/adquery/adquerytest/supplemental/malformed-ext.json @@ -32,7 +32,7 @@ "bidder": "adquery" }, "expectedMakeRequestsErrors": [{ - "value": "json: cannot unmarshal array into Go struct field ImpExtAdQuery.placementId of type string", + "value": "cannot unmarshal openrtb_ext.ImpExtAdQuery.PlacementID: expects \" or n, but found [", "comparison": "literal" }] } \ No newline at end of file diff --git a/adapters/adquery/adquerytest/supplemental/malformed-resp.json b/adapters/adquery/adquerytest/supplemental/malformed-resp.json index c65c32cb4fb..f485f394c87 100644 --- a/adapters/adquery/adquerytest/supplemental/malformed-resp.json +++ b/adapters/adquery/adquerytest/supplemental/malformed-resp.json @@ -105,8 +105,8 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go struct field ResponseData.data.creationId of type int64", - "comparison": "literal" + "value": "cannot unmarshal adquery.ResponseData.CrID: unexpected character", + "comparison": "startswith" } ] } diff --git a/adapters/adrino/adrino.go b/adapters/adrino/adrino.go index 830d7d3aca3..d5419f95743 100644 --- a/adapters/adrino/adrino.go +++ b/adapters/adrino/adrino.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -58,7 +59,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/adsinteractive/adsinteractive.go b/adapters/adsinteractive/adsinteractive.go index c1b521be9f2..330473032e9 100644 --- a/adapters/adsinteractive/adsinteractive.go +++ b/adapters/adsinteractive/adsinteractive.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -60,7 +61,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/adsinteractive/adsinteractivetest/supplemental/bad-response.json b/adapters/adsinteractive/adsinteractivetest/supplemental/bad-response.json index 1539e000094..3f40cfa3512 100644 --- a/adapters/adsinteractive/adsinteractivetest/supplemental/bad-response.json +++ b/adapters/adsinteractive/adsinteractivetest/supplemental/bad-response.json @@ -57,7 +57,7 @@ "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/adtarget/adtarget.go b/adapters/adtarget/adtarget.go index 7ec92c60a58..9b3b2b55aeb 100644 --- a/adapters/adtarget/adtarget.go +++ b/adapters/adtarget/adtarget.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type AdtargetAdapter struct { @@ -92,7 +93,7 @@ func (a *AdtargetAdapter) MakeBids(bidReq *openrtb2.BidRequest, unused *adapters }} } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(httpRes.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(httpRes.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("error while decoding response, err: %s", err), }} @@ -154,14 +155,14 @@ func validateImpressionAndSetExt(imp *openrtb2.Imp) (int, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return 0, &errortypes.BadInput{ Message: fmt.Sprintf("ignoring imp id=%s, error while decoding extImpBidder, err: %s", imp.ID, err), } } impExt := openrtb_ext.ExtImpAdtarget{} - err := json.Unmarshal(bidderExt.Bidder, &impExt) + err := jsonutil.Unmarshal(bidderExt.Bidder, &impExt) if err != nil { return 0, &errortypes.BadInput{ Message: fmt.Sprintf("ignoring imp id=%s, error while decoding impExt, err: %s", imp.ID, err), diff --git a/adapters/adtarget/adtargettest/supplemental/wrong-impression-ext.json b/adapters/adtarget/adtargettest/supplemental/wrong-impression-ext.json index ee59cf36439..7f2b1e3cfcb 100644 --- a/adapters/adtarget/adtargettest/supplemental/wrong-impression-ext.json +++ b/adapters/adtarget/adtargettest/supplemental/wrong-impression-ext.json @@ -19,7 +19,7 @@ "expectedMakeRequestsErrors": [ { - "value": "ignoring imp id=unsupported-native-imp, error while decoding impExt, err: json: invalid number literal, trying to unmarshal \"\\\"some string instead of int\\\"\" into Number", + "value": "ignoring imp id=unsupported-native-imp, error while encoding impExt, err: json: invalid number literal \"some string instead of int\"", "comparison": "literal" } ] diff --git a/adapters/adtelligent/adtelligent.go b/adapters/adtelligent/adtelligent.go index 3bc27a2e604..f11062e58dc 100644 --- a/adapters/adtelligent/adtelligent.go +++ b/adapters/adtelligent/adtelligent.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type AdtelligentAdapter struct { @@ -93,7 +94,7 @@ func (a *AdtelligentAdapter) MakeBids(bidReq *openrtb2.BidRequest, unused *adapt } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(httpRes.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(httpRes.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("error while decoding response, err: %s", err), }} @@ -155,14 +156,14 @@ func validateImpression(imp *openrtb2.Imp) (int, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return 0, &errortypes.BadInput{ Message: fmt.Sprintf("ignoring imp id=%s, error while decoding extImpBidder, err: %s", imp.ID, err), } } impExt := openrtb_ext.ExtImpAdtelligent{} - err := json.Unmarshal(bidderExt.Bidder, &impExt) + err := jsonutil.Unmarshal(bidderExt.Bidder, &impExt) if err != nil { return 0, &errortypes.BadInput{ Message: fmt.Sprintf("ignoring imp id=%s, error while decoding impExt, err: %s", imp.ID, err), diff --git a/adapters/adtelligent/adtelligenttest/supplemental/wrong-impression-ext.json b/adapters/adtelligent/adtelligenttest/supplemental/wrong-impression-ext.json index ee59cf36439..3d7508d2103 100644 --- a/adapters/adtelligent/adtelligenttest/supplemental/wrong-impression-ext.json +++ b/adapters/adtelligent/adtelligenttest/supplemental/wrong-impression-ext.json @@ -19,7 +19,7 @@ "expectedMakeRequestsErrors": [ { - "value": "ignoring imp id=unsupported-native-imp, error while decoding impExt, err: json: invalid number literal, trying to unmarshal \"\\\"some string instead of int\\\"\" into Number", + "value": "ignoring imp id=unsupported-native-imp, error while marshaling impExt, err: json: invalid number literal \"some string instead of int\"", "comparison": "literal" } ] diff --git a/adapters/adtonos/adtonos.go b/adapters/adtonos/adtonos.go index dff60733955..af1a1bfae32 100644 --- a/adapters/adtonos/adtonos.go +++ b/adapters/adtonos/adtonos.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -32,13 +33,13 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(request.Imp[0].Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(request.Imp[0].Ext, &bidderExt); err != nil { return nil, []error{&errortypes.BadInput{ Message: fmt.Sprintf("Invalid imp.ext for impression index %d. Error Infomation: %s", 0, err.Error()), }} } var impExt openrtb_ext.ImpExtAdTonos - if err := json.Unmarshal(bidderExt.Bidder, &impExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &impExt); err != nil { return nil, []error{&errortypes.BadInput{ Message: fmt.Sprintf("Invalid imp.ext.bidder for impression index %d. Error Infomation: %s", 0, err.Error()), }} @@ -84,7 +85,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/adtrgtme/adtrgtme.go b/adapters/adtrgtme/adtrgtme.go index f2fc09cb322..a9597298591 100644 --- a/adapters/adtrgtme/adtrgtme.go +++ b/adapters/adtrgtme/adtrgtme.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -67,13 +68,13 @@ func (v *adapter) MakeRequests( func getSiteIDFromImp(imp *openrtb2.Imp) (uint64, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return 0, &errortypes.BadInput{ Message: "ext.bidder not provided", } } var ext openrtb_ext.ExtImpAdtrgtme - if err := json.Unmarshal(bidderExt.Bidder, &ext); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &ext); err != nil { return 0, &errortypes.BadInput{ Message: "ext.bidder not provided", } @@ -147,7 +148,7 @@ func (v *adapter) MakeBids( } var response openrtb2.BidResponse - if err := json.Unmarshal(bidderRawResponse.Body, &response); err != nil { + if err := jsonutil.Unmarshal(bidderRawResponse.Body, &response); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Bad Server Response", }} diff --git a/adapters/advangelists/advangelists.go b/adapters/advangelists/advangelists.go index bddb9706c5b..5e38528b24d 100644 --- a/adapters/advangelists/advangelists.go +++ b/adapters/advangelists/advangelists.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type AdvangelistsAdapter struct { @@ -129,13 +130,13 @@ func compatBannerImpression(imp *openrtb2.Imp) error { func getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpAdvangelists, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: err.Error(), } } var advangelistsExt openrtb_ext.ExtImpAdvangelists - if err := json.Unmarshal(bidderExt.Bidder, &advangelistsExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &advangelistsExt); err != nil { return nil, &errortypes.BadInput{ Message: err.Error(), } @@ -208,7 +209,7 @@ func (adapter *AdvangelistsAdapter) MakeBids(internalRequest *openrtb2.BidReques return nil, []error{&errortypes.BadServerResponse{Message: msg}} } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { msg = fmt.Sprintf("Bad server response: %d", err) return nil, []error{&errortypes.BadServerResponse{Message: msg}} } diff --git a/adapters/adview/adview.go b/adapters/adview/adview.go index 69e1f27ac9d..cb5937f4ff8 100644 --- a/adapters/adview/adview.go +++ b/adapters/adview/adview.go @@ -13,6 +13,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -45,7 +46,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte requestCopy := *request for _, imp := range request.Imp { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { errors = append(errors, &errortypes.BadInput{ Message: fmt.Sprintf("invalid imp.ext, %s", err.Error()), }) @@ -53,7 +54,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte } //use adview var advImpExt openrtb_ext.ExtImpAdView - if err := json.Unmarshal(bidderExt.Bidder, &advImpExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &advImpExt); err != nil { errors = append(errors, &errortypes.BadInput{ Message: fmt.Sprintf("invalid bidderExt.Bidder, %s", err.Error()), }) @@ -132,7 +133,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/adview/adviewtest/supplemental/unparsable-response.json b/adapters/adview/adviewtest/supplemental/unparsable-response.json index af126dab8e7..76f95d1cd6d 100644 --- a/adapters/adview/adviewtest/supplemental/unparsable-response.json +++ b/adapters/adview/adviewtest/supplemental/unparsable-response.json @@ -46,7 +46,7 @@ "expectedBidResponses": [], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/adxcg/adxcg.go b/adapters/adxcg/adxcg.go index 3bccf806902..49812518c97 100644 --- a/adapters/adxcg/adxcg.go +++ b/adapters/adxcg/adxcg.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) // Builder builds a new instance of the Adxcg adapter for the given bidder with the given config. @@ -81,7 +82,7 @@ func (adapter *adapter) MakeBids( } var openRTBBidderResponse openrtb2.BidResponse - if err := json.Unmarshal(bidderRawResponse.Body, &openRTBBidderResponse); err != nil { + if err := jsonutil.Unmarshal(bidderRawResponse.Body, &openRTBBidderResponse); err != nil { return nil, []error{err} } diff --git a/adapters/adxcg/adxcgtest/supplemental/bad_response.json b/adapters/adxcg/adxcgtest/supplemental/bad_response.json index b8ce74b28a6..e887a114408 100644 --- a/adapters/adxcg/adxcgtest/supplemental/bad_response.json +++ b/adapters/adxcg/adxcgtest/supplemental/bad_response.json @@ -55,7 +55,7 @@ "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/adyoulike/adyoulike.go b/adapters/adyoulike/adyoulike.go index babc7627949..71791b347a0 100644 --- a/adapters/adyoulike/adyoulike.go +++ b/adapters/adyoulike/adyoulike.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) { @@ -120,7 +121,7 @@ func (a *adapter) MakeBids( } var openRTBBidderResponse openrtb2.BidResponse - if err := json.Unmarshal(bidderRawResponse.Body, &openRTBBidderResponse); err != nil { + if err := jsonutil.Unmarshal(bidderRawResponse.Body, &openRTBBidderResponse); err != nil { return nil, []error{err} } diff --git a/adapters/adyoulike/adyouliketest/supplemental/invalid-bid-response.json b/adapters/adyoulike/adyouliketest/supplemental/invalid-bid-response.json index 2d68274da1a..1b0959a471d 100644 --- a/adapters/adyoulike/adyouliketest/supplemental/invalid-bid-response.json +++ b/adapters/adyoulike/adyouliketest/supplemental/invalid-bid-response.json @@ -60,7 +60,7 @@ "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/aidem/aidem.go b/adapters/aidem/aidem.go index fe1259450ca..a2e52446fed 100644 --- a/adapters/aidem/aidem.go +++ b/adapters/aidem/aidem.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -61,7 +62,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("JSON parsing error: %v", err), }} @@ -122,13 +123,13 @@ func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) { func getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpAidem, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: err.Error(), } } var AIDEMExt openrtb_ext.ExtImpAidem - if err := json.Unmarshal(bidderExt.Bidder, &AIDEMExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &AIDEMExt); err != nil { return nil, &errortypes.BadInput{ Message: err.Error(), } diff --git a/adapters/aja/aja.go b/adapters/aja/aja.go index e65ab357fb3..ac57eed2026 100644 --- a/adapters/aja/aja.go +++ b/adapters/aja/aja.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type AJAAdapter struct { @@ -61,13 +62,13 @@ func parseExtAJA(imp openrtb2.Imp) (openrtb_ext.ExtImpAJA, error) { extAJA openrtb_ext.ExtImpAJA ) - if err := json.Unmarshal(imp.Ext, &extImp); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &extImp); err != nil { return extAJA, &errortypes.BadInput{ Message: fmt.Sprintf("Failed to unmarshal ext impID: %s err: %s", imp.ID, err), } } - if err := json.Unmarshal(extImp.Bidder, &extAJA); err != nil { + if err := jsonutil.Unmarshal(extImp.Bidder, &extAJA); err != nil { return extAJA, &errortypes.BadInput{ Message: fmt.Sprintf("Failed to unmarshal ext.bidder impID: %s err: %s", imp.ID, err), } @@ -92,7 +93,7 @@ func (a *AJAAdapter) MakeBids(bidReq *openrtb2.BidRequest, adapterReq *adapters. } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(adapterResp.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(adapterResp.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Failed to unmarshal bid response: %s", err.Error()), }} diff --git a/adapters/aja/ajatest/supplemental/invalid-ext-bidder.json b/adapters/aja/ajatest/supplemental/invalid-ext-bidder.json index b12b431b0ed..54a774b3240 100644 --- a/adapters/aja/ajatest/supplemental/invalid-ext-bidder.json +++ b/adapters/aja/ajatest/supplemental/invalid-ext-bidder.json @@ -28,7 +28,7 @@ "expectedMakeRequestsErrors": [ { - "value": "Failed to unmarshal ext.bidder impID: test-imp-id err: json: cannot unmarshal number into Go struct field ExtImpAJA.asi of type string", + "value": "Failed to unmarshal ext.bidder impID: test-imp-id err: cannot unmarshal openrtb_ext.ExtImpAJA.AdSpotID: expects \" or n, but found 1", "comparison": "literal" } diff --git a/adapters/aja/ajatest/supplemental/invalid-ext.json b/adapters/aja/ajatest/supplemental/invalid-ext.json index 478222d0ee9..4562da9eea1 100644 --- a/adapters/aja/ajatest/supplemental/invalid-ext.json +++ b/adapters/aja/ajatest/supplemental/invalid-ext.json @@ -24,7 +24,7 @@ "expectedMakeRequestsErrors": [ { - "value": "Failed to unmarshal ext impID: test-imp-id err: json: cannot unmarshal number into Go value of type adapters.ExtImpBidder", + "value": "Failed to unmarshal ext impID: test-imp-id err: expect { or n, but found 1", "comparison": "literal" } diff --git a/adapters/algorix/algorix.go b/adapters/algorix/algorix.go index 28a1a560829..c2e4f434751 100644 --- a/adapters/algorix/algorix.go +++ b/adapters/algorix/algorix.go @@ -13,6 +13,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -88,11 +89,11 @@ func (a *adapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestDa func getImpAlgoriXExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpAlgorix, error) { var extImpAlgoriX openrtb_ext.ExtImpAlgorix var extBidder adapters.ExtImpBidder - err := json.Unmarshal(imp.Ext, &extBidder) + err := jsonutil.Unmarshal(imp.Ext, &extBidder) if err != nil { return nil, err } - err = json.Unmarshal(extBidder.Bidder, &extImpAlgoriX) + err = jsonutil.Unmarshal(extBidder.Bidder, &extImpAlgoriX) if err != nil { return nil, err } @@ -134,7 +135,7 @@ func preProcess(request *openrtb2.BidRequest) { } if request.Imp[i].Video != nil { var impExt adapters.ExtImpBidder - err := json.Unmarshal(request.Imp[i].Ext, &impExt) + err := jsonutil.Unmarshal(request.Imp[i].Ext, &impExt) if err != nil { continue } @@ -169,7 +170,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -195,7 +196,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest func getBidType(bid openrtb2.Bid, imps []openrtb2.Imp) (openrtb_ext.BidType, error) { var bidExt algorixResponseBidExt - err := json.Unmarshal(bid.Ext, &bidExt) + err := jsonutil.Unmarshal(bid.Ext, &bidExt) if err == nil { switch bidExt.MediaType { case "banner": diff --git a/adapters/algorix/algorixtest/supplemental/bad_response.json b/adapters/algorix/algorixtest/supplemental/bad_response.json index 9c5a44b2f14..6a99f748df2 100644 --- a/adapters/algorix/algorixtest/supplemental/bad_response.json +++ b/adapters/algorix/algorixtest/supplemental/bad_response.json @@ -52,7 +52,7 @@ "expectedMakeBidsErrors": [ { "comparison": "literal", - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse" + "value": "expect { or n, but found \"" } ] } diff --git a/adapters/alkimi/alkimi.go b/adapters/alkimi/alkimi.go index 88703073402..76b08cd1286 100644 --- a/adapters/alkimi/alkimi.go +++ b/adapters/alkimi/alkimi.go @@ -15,6 +15,7 @@ import ( "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) const price_macro = "${AUCTION_PRICE}" @@ -69,12 +70,12 @@ func updateImps(bidRequest openrtb2.BidRequest) ([]openrtb2.Imp, []error) { var bidderExt adapters.ExtImpBidder var extImpAlkimi openrtb_ext.ExtImpAlkimi - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { errs = append(errs, err) continue } - if err := json.Unmarshal(bidderExt.Bidder, &extImpAlkimi); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &extImpAlkimi); err != nil { errs = append(errs, err) continue } @@ -134,7 +135,7 @@ func (adapter *adapter) MakeBids(request *openrtb2.BidRequest, externalRequest * } var bidResp openrtb2.BidResponse - err := json.Unmarshal(response.Body, &bidResp) + err := jsonutil.Unmarshal(response.Body, &bidResp) if err != nil { return nil, []error{err} } diff --git a/adapters/alkimi/alkimitest/supplemental/bad_response.json b/adapters/alkimi/alkimitest/supplemental/bad_response.json index 92b8d658968..df66e1eba76 100644 --- a/adapters/alkimi/alkimitest/supplemental/bad_response.json +++ b/adapters/alkimi/alkimitest/supplemental/bad_response.json @@ -95,7 +95,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/amx/amx.go b/adapters/amx/amx.go index 5aaa00694c0..0c3f4a703ef 100644 --- a/adapters/amx/amx.go +++ b/adapters/amx/amx.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) const nbrHeaderName = "x-nbr" @@ -63,7 +64,7 @@ func (adapter *AMXAdapter) MakeRequests(request *openrtb2.BidRequest, req *adapt var publisherID string for idx, imp := range reqCopy.Imp { var params amxExt - if err := json.Unmarshal(imp.Ext, ¶ms); err == nil { + if err := jsonutil.Unmarshal(imp.Ext, ¶ms); err == nil { if params.Bidder.TagID != "" { publisherID = params.Bidder.TagID } @@ -141,7 +142,7 @@ func (adapter *AMXAdapter) MakeBids(request *openrtb2.BidRequest, externalReques } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -188,7 +189,7 @@ func getBidExt(ext json.RawMessage) (amxBidExt, error) { } var bidExt amxBidExt - err := json.Unmarshal(ext, &bidExt) + err := jsonutil.Unmarshal(ext, &bidExt) return bidExt, err } diff --git a/adapters/apacdex/apacdex.go b/adapters/apacdex/apacdex.go index 8eee996c7bd..19951913731 100644 --- a/adapters/apacdex/apacdex.go +++ b/adapters/apacdex/apacdex.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -76,14 +77,14 @@ func preprocess(request *openrtb2.BidRequest) error { var imp = &request.Imp[i] var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return &errortypes.BadInput{ Message: err.Error(), } } var extImp openrtb_ext.ExtImpApacdex - if err := json.Unmarshal(bidderExt.Bidder, &extImp); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &extImp); err != nil { return &errortypes.BadInput{ Message: err.Error(), } @@ -116,7 +117,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: err.Error(), }} @@ -150,7 +151,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) { if bid.Ext != nil { var bidExt openrtb_ext.ExtBid - err := json.Unmarshal(bid.Ext, &bidExt) + err := jsonutil.Unmarshal(bid.Ext, &bidExt) if err == nil && bidExt.Prebid != nil { return openrtb_ext.ParseBidType(string(bidExt.Prebid.Type)) } diff --git a/adapters/apacdex/apacdextest/supplemental/invalid-response-unmarshall-error.json b/adapters/apacdex/apacdextest/supplemental/invalid-response-unmarshall-error.json index 7c162cbfbad..95c471f2e39 100644 --- a/adapters/apacdex/apacdextest/supplemental/invalid-response-unmarshall-error.json +++ b/adapters/apacdex/apacdextest/supplemental/invalid-response-unmarshall-error.json @@ -60,8 +60,8 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go struct field Bid(\\.seatbid\\.bid)?\\.w of type int64", - "comparison": "regex" + "value": "cannot unmarshal openrtb2.Bid.W: unexpected character", + "comparison": "startswith" } ] } \ No newline at end of file diff --git a/adapters/apacdex/apacdextest/supplemental/wrong-impression-ext.json b/adapters/apacdex/apacdextest/supplemental/wrong-impression-ext.json index 09efa59563d..fcb76ddcbf1 100644 --- a/adapters/apacdex/apacdextest/supplemental/wrong-impression-ext.json +++ b/adapters/apacdex/apacdextest/supplemental/wrong-impression-ext.json @@ -19,7 +19,7 @@ "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal number into Go struct field ExtImpApacdex.siteId of type string", + "value": "cannot unmarshal openrtb_ext.ExtImpApacdex.SiteID: expects \" or n, but found 1", "comparison": "literal" } ] diff --git a/adapters/appnexus/appnexus.go b/adapters/appnexus/appnexus.go index f66adaa86eb..fc231380190 100644 --- a/adapters/appnexus/appnexus.go +++ b/adapters/appnexus/appnexus.go @@ -21,6 +21,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/metrics" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) const ( @@ -171,7 +172,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest } var appnexusResponse openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &appnexusResponse); err != nil { + if err := jsonutil.Unmarshal(response.Body, &appnexusResponse); err != nil { return nil, []error{err} } @@ -182,7 +183,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest bid := sb.Bid[i] var bidExt bidExt - if err := json.Unmarshal(bid.Ext, &bidExt); err != nil { + if err := jsonutil.Unmarshal(bid.Ext, &bidExt); err != nil { errs = append(errs, err) continue } @@ -221,7 +222,7 @@ func getRequestExt(ext json.RawMessage) (map[string]json.RawMessage, error) { extMap := make(map[string]json.RawMessage) if len(ext) > 0 { - if err := json.Unmarshal(ext, &extMap); err != nil { + if err := jsonutil.Unmarshal(ext, &extMap); err != nil { return nil, err } } @@ -233,7 +234,7 @@ func (a *adapter) getAppnexusExt(extMap map[string]json.RawMessage, isAMP int, i var appnexusExt bidReqExtAppnexus if appnexusExtJson, exists := extMap["appnexus"]; exists && len(appnexusExtJson) > 0 { - if err := json.Unmarshal(appnexusExtJson, &appnexusExt); err != nil { + if err := jsonutil.Unmarshal(appnexusExtJson, &appnexusExt); err != nil { return appnexusExt, err } } @@ -258,7 +259,7 @@ func (a *adapter) getAppnexusExt(extMap map[string]json.RawMessage, isAMP int, i func validateAndBuildImpExt(imp *openrtb2.Imp) (impExtIncoming, error) { var ext impExtIncoming - if err := json.Unmarshal(imp.Ext, &ext); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &ext); err != nil { return impExtIncoming{}, err } @@ -463,7 +464,7 @@ func moveSupplyChain(request *openrtb2.BidRequest, extMap map[string]json.RawMes } sourceExtMap := make(map[string]json.RawMessage) - if err := json.Unmarshal(request.Source.Ext, &sourceExtMap); err != nil { + if err := jsonutil.Unmarshal(request.Source.Ext, &sourceExtMap); err != nil { return err } diff --git a/adapters/appush/appush.go b/adapters/appush/appush.go index df15f716866..8537cec602c 100644 --- a/adapters/appush/appush.go +++ b/adapters/appush/appush.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -44,10 +45,10 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E var bidderExt adapters.ExtImpBidder var appushExt openrtb_ext.ImpExtAppush - if err = json.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { + if err = jsonutil.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { return nil, []error{err} } - if err = json.Unmarshal(bidderExt.Bidder, &appushExt); err != nil { + if err = jsonutil.Unmarshal(bidderExt.Bidder, &appushExt); err != nil { return nil, []error{err} } @@ -111,7 +112,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/appush/appushtest/supplemental/bad_response.json b/adapters/appush/appushtest/supplemental/bad_response.json index c732ba92c67..5cc4a338ac3 100644 --- a/adapters/appush/appushtest/supplemental/bad_response.json +++ b/adapters/appush/appushtest/supplemental/bad_response.json @@ -78,7 +78,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/aso/aso.go b/adapters/aso/aso.go index 3664b49af2e..b0215b32b32 100644 --- a/adapters/aso/aso.go +++ b/adapters/aso/aso.go @@ -14,6 +14,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -41,7 +42,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte for _, imp := range request.Imp { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { errors = append(errors, &errortypes.BadInput{ Message: fmt.Sprintf("invalid imp.ext, %s", err.Error()), }) @@ -49,7 +50,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte } var impExt openrtb_ext.ExtImpAso - if err := json.Unmarshal(bidderExt.Bidder, &impExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &impExt); err != nil { errors = append(errors, &errortypes.BadInput{ Message: fmt.Sprintf("invalid bidderExt.Bidder, %s", err.Error()), }) @@ -96,7 +97,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } @@ -132,7 +133,7 @@ func (a *adapter) buildEndpointURL(params *openrtb_ext.ExtImpAso) (string, error func getMediaType(bid openrtb2.Bid) (openrtb_ext.BidType, error) { if bid.Ext != nil { var bidExt openrtb_ext.ExtBid - err := json.Unmarshal(bid.Ext, &bidExt) + err := jsonutil.Unmarshal(bid.Ext, &bidExt) if err == nil && bidExt.Prebid != nil { return openrtb_ext.ParseBidType(string(bidExt.Prebid.Type)) } diff --git a/adapters/aso/asotest/supplemental/bad-request-no-bidder.json b/adapters/aso/asotest/supplemental/bad-request-no-bidder.json index c19a7c62a44..711637104eb 100644 --- a/adapters/aso/asotest/supplemental/bad-request-no-bidder.json +++ b/adapters/aso/asotest/supplemental/bad-request-no-bidder.json @@ -18,8 +18,8 @@ "expectedBidResponses": [], "expectedMakeRequestsErrors": [ { - "value": "invalid bidderExt.Bidder, unexpected end of JSON input", - "comparison": "literal" + "value": "invalid bidderExt.Bidder, expect { or n, but found", + "comparison": "startswith" } ] } diff --git a/adapters/aso/asotest/supplemental/bad-request-no-ext.json b/adapters/aso/asotest/supplemental/bad-request-no-ext.json index 9911931d521..1528d1220dd 100644 --- a/adapters/aso/asotest/supplemental/bad-request-no-ext.json +++ b/adapters/aso/asotest/supplemental/bad-request-no-ext.json @@ -15,8 +15,8 @@ "expectedBidResponses": [], "expectedMakeRequestsErrors": [ { - "value": "invalid imp.ext, unexpected end of JSON input", - "comparison": "literal" + "value": "invalid imp.ext, expect { or n, but found", + "comparison": "startswith" } ] } diff --git a/adapters/aso/asotest/supplemental/unparsable-response.json b/adapters/aso/asotest/supplemental/unparsable-response.json index c05b1f4c5e8..7fa10a78219 100644 --- a/adapters/aso/asotest/supplemental/unparsable-response.json +++ b/adapters/aso/asotest/supplemental/unparsable-response.json @@ -42,7 +42,7 @@ "expectedBidResponses": [], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/audienceNetwork/audienceNetworktest/supplemental/invalid-adm.json b/adapters/audienceNetwork/audienceNetworktest/supplemental/invalid-adm.json index f79c88e3e3c..2aef3f5381c 100644 --- a/adapters/audienceNetwork/audienceNetworktest/supplemental/invalid-adm.json +++ b/adapters/audienceNetwork/audienceNetworktest/supplemental/invalid-adm.json @@ -99,7 +99,7 @@ }], "expectedBidResponses": [{"currency":"USD","bids":[]}], "expectedMakeBidsErrors": [{ - "value": "invalid character 'm' looking for beginning of value", + "value": "expect { or n, but found m", "comparison": "literal" }] } diff --git a/adapters/audienceNetwork/facebook.go b/adapters/audienceNetwork/facebook.go index 807fe337cf2..e5162a652c8 100644 --- a/adapters/audienceNetwork/facebook.go +++ b/adapters/audienceNetwork/facebook.go @@ -216,14 +216,14 @@ func modifyImp(out *openrtb2.Imp) error { func extractPlacementAndPublisher(out *openrtb2.Imp) (string, string, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(out.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(out.Ext, &bidderExt); err != nil { return "", "", &errortypes.BadInput{ Message: err.Error(), } } var fbExt openrtb_ext.ExtImpFacebook - if err := json.Unmarshal(bidderExt.Bidder, &fbExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &fbExt); err != nil { return "", "", &errortypes.BadInput{ Message: err.Error(), } @@ -274,7 +274,7 @@ func modifyImpCustom(jsonData []byte, imp *openrtb2.Imp) ([]byte, error) { } var jsonMap map[string]interface{} - if err := json.Unmarshal(jsonData, &jsonMap); err != nil { + if err := jsonutil.Unmarshal(jsonData, &jsonMap); err != nil { return jsonData, err } @@ -338,7 +338,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, adapterRequest *adapter } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -357,7 +357,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, adapterRequest *adapter } var obj facebookAdMarkup - if err := json.Unmarshal([]byte(bid.AdM), &obj); err != nil { + if err := jsonutil.Unmarshal([]byte(bid.AdM), &obj); err != nil { errs = append(errs, &errortypes.BadServerResponse{ Message: err.Error(), }) diff --git a/adapters/automatad/automatad.go b/adapters/automatad/automatad.go index cbb5d2ef2cc..3ebe39c4df3 100644 --- a/adapters/automatad/automatad.go +++ b/adapters/automatad/automatad.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -60,7 +61,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/avocet/avocet.go b/adapters/avocet/avocet.go index 76ce8195219..17f954a93d6 100644 --- a/adapters/avocet/avocet.go +++ b/adapters/avocet/avocet.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) // AvocetAdapter implements a adapters.Bidder compatible with the Avocet advertising platform. @@ -71,7 +72,7 @@ func (a *AvocetAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalR } var br openrtb2.BidResponse - err := json.Unmarshal(response.Body, &br) + err := jsonutil.Unmarshal(response.Body, &br) if err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: err.Error(), @@ -84,7 +85,7 @@ func (a *AvocetAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalR for j := range br.SeatBid[i].Bid { var ext avocetBidExt if len(br.SeatBid[i].Bid[j].Ext) > 0 { - err := json.Unmarshal(br.SeatBid[i].Bid[j].Ext, &ext) + err := jsonutil.Unmarshal(br.SeatBid[i].Bid[j].Ext, &ext) if err != nil { errs = append(errs, err) continue diff --git a/adapters/axis/axis.go b/adapters/axis/axis.go index 4d15e19a4ea..d6fcb46cb24 100644 --- a/adapters/axis/axis.go +++ b/adapters/axis/axis.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -38,7 +39,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E request.Imp = []openrtb2.Imp{currImp} var bidderExt reqBodyExt - if err := json.Unmarshal(currImp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(currImp.Ext, &bidderExt); err != nil { continue } @@ -94,7 +95,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/axis/axistest/supplemental/bad_response.json b/adapters/axis/axistest/supplemental/bad_response.json index fa1b7579f25..bb2d515ec0e 100644 --- a/adapters/axis/axistest/supplemental/bad_response.json +++ b/adapters/axis/axistest/supplemental/bad_response.json @@ -79,7 +79,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/axonix/axonix.go b/adapters/axonix/axonix.go index b57e44057d7..3c92c7abc3c 100644 --- a/adapters/axonix/axonix.go +++ b/adapters/axonix/axonix.go @@ -15,6 +15,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -43,7 +44,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte var errors []error var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(request.Imp[0].Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(request.Imp[0].Ext, &bidderExt); err != nil { errors = append(errors, &errortypes.BadInput{ Message: err.Error(), }) @@ -52,7 +53,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte } var axonixExt openrtb_ext.ExtImpAxonix - if err := json.Unmarshal(bidderExt.Bidder, &axonixExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &axonixExt); err != nil { errors = append(errors, &errortypes.BadInput{ Message: err.Error(), }) @@ -99,7 +100,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/axonix/axonixtest/supplemental/bad-response-no-body.json b/adapters/axonix/axonixtest/supplemental/bad-response-no-body.json index 8fafaa38fed..18f2915f270 100644 --- a/adapters/axonix/axonixtest/supplemental/bad-response-no-body.json +++ b/adapters/axonix/axonixtest/supplemental/bad-response-no-body.json @@ -51,8 +51,8 @@ ], "expectedMakeBidsErrors": [ { - "value": "unexpected end of JSON input", - "comparison": "literal" + "value": "expect { or n, but found", + "comparison": "startswith" } ] } diff --git a/adapters/beachfront/beachfront.go b/adapters/beachfront/beachfront.go index 154a14286cd..a5fe46e8380 100644 --- a/adapters/beachfront/beachfront.go +++ b/adapters/beachfront/beachfront.go @@ -14,6 +14,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" "github.com/prebid/prebid-server/v2/util/ptrutil" ) @@ -273,7 +274,7 @@ func getAppId(ext openrtb_ext.ExtImpBeachfront, media openrtb_ext.BidType) (stri func getSchain(request *openrtb2.BidRequest) (openrtb_ext.ExtRequestPrebidSChain, error) { var schain openrtb_ext.ExtRequestPrebidSChain - return schain, json.Unmarshal(request.Source.Ext, &schain) + return schain, jsonutil.Unmarshal(request.Source.Ext, &schain) } func getBannerRequest(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) (beachfrontBannerRequest, []error) { @@ -540,7 +541,7 @@ func (a *BeachfrontAdapter) MakeBids(internalRequest *openrtb2.BidRequest, exter var errs = make([]error, 0) var xtrnal openrtb2.BidRequest - if err := json.Unmarshal(externalRequest.Body, &xtrnal); err != nil { + if err := jsonutil.Unmarshal(externalRequest.Body, &xtrnal); err != nil { errs = append(errs, err) } else { bids, errs = postprocess(response, xtrnal, externalRequest.Uri, internalRequest.ID) @@ -555,7 +556,7 @@ func (a *BeachfrontAdapter) MakeBids(internalRequest *openrtb2.BidRequest, exter for i := 0; i < len(bids); i++ { - if err := json.Unmarshal(bids[i].Ext, &dur); err == nil && dur.Duration > 0 { + if err := jsonutil.Unmarshal(bids[i].Ext, &dur); err == nil && dur.Duration > 0 { impVideo := openrtb_ext.ExtBidPrebidVideo{ Duration: int(dur.Duration), @@ -642,9 +643,9 @@ func postprocess(response *adapters.ResponseData, xtrnal openrtb2.BidRequest, ur var openrtbResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &openrtbResp); err != nil || len(openrtbResp.SeatBid) == 0 { + if err := jsonutil.Unmarshal(response.Body, &openrtbResp); err != nil || len(openrtbResp.SeatBid) == 0 { - if err := json.Unmarshal(response.Body, &beachfrontResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &beachfrontResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "server response failed to unmarshal as valid rtb. Run with request.debug = 1 for more info", }} @@ -715,13 +716,13 @@ func getBeachfrontExtension(imp openrtb2.Imp) (openrtb_ext.ExtImpBeachfront, err var bidderExt adapters.ExtImpBidder var beachfrontExt openrtb_ext.ExtImpBeachfront - if err = json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err = jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return beachfrontExt, &errortypes.BadInput{ Message: fmt.Sprintf("ignoring imp id=%s, error while decoding extImpBidder, err: %s", imp.ID, err), } } - if err = json.Unmarshal(bidderExt.Bidder, &beachfrontExt); err != nil { + if err = jsonutil.Unmarshal(bidderExt.Bidder, &beachfrontExt); err != nil { return beachfrontExt, &errortypes.BadInput{ Message: fmt.Sprintf("ignoring imp id=%s, error while decoding extImpBeachfront, err: %s", imp.ID, err), } @@ -783,7 +784,7 @@ func getExtraInfo(v string) (ExtraInfo, error) { } var extraInfo ExtraInfo - if err := json.Unmarshal([]byte(v), &extraInfo); err != nil { + if err := jsonutil.Unmarshal([]byte(v), &extraInfo); err != nil { return extraInfo, fmt.Errorf("invalid extra info: %v", err) } diff --git a/adapters/beachfront/beachfronttest/supplemental/unmarshal-error-banner.json b/adapters/beachfront/beachfronttest/supplemental/unmarshal-error-banner.json index 8d07852b1f1..31f313bde64 100644 --- a/adapters/beachfront/beachfronttest/supplemental/unmarshal-error-banner.json +++ b/adapters/beachfront/beachfronttest/supplemental/unmarshal-error-banner.json @@ -28,7 +28,7 @@ "expectedMakeRequestsErrors": [ { - "value": "ignoring imp id=fail, error while decoding extImpBeachfront, err: json: cannot unmarshal number into Go struct field ExtImpBeachfront.appId of type string", + "value": "ignoring imp id=fail, error while decoding extImpBeachfront, err: cannot unmarshal openrtb_ext.ExtImpBeachfront.AppId: expects \" or n, but found 1", "comparison": "literal" } ] diff --git a/adapters/beachfront/beachfronttest/supplemental/unmarshal-error-video.json b/adapters/beachfront/beachfronttest/supplemental/unmarshal-error-video.json index 73ac2032c16..e075697cfb4 100644 --- a/adapters/beachfront/beachfronttest/supplemental/unmarshal-error-video.json +++ b/adapters/beachfront/beachfronttest/supplemental/unmarshal-error-video.json @@ -34,7 +34,7 @@ "expectedMakeRequestsErrors": [ { - "value": "ignoring imp id=looser, error while decoding extImpBeachfront, err: json: cannot unmarshal string into Go struct field ExtImpBeachfront.bidfloor of type float64", + "value": "ignoring imp id=looser, error while decoding extImpBeachfront, err: cannot unmarshal openrtb_ext.ExtImpBeachfront.BidFloor: invalid number", "comparison": "literal" } ] diff --git a/adapters/beintoo/beintoo.go b/adapters/beintoo/beintoo.go index 500e0e4a9df..fb28392d268 100644 --- a/adapters/beintoo/beintoo.go +++ b/adapters/beintoo/beintoo.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type BeintooAdapter struct { @@ -67,14 +68,14 @@ func (a *BeintooAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada func unpackImpExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpBeintoo, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: err.Error(), } } var beintooExt openrtb_ext.ExtImpBeintoo - if err := json.Unmarshal(bidderExt.Bidder, &beintooExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &beintooExt); err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("ignoring imp id=%s, invalid ImpExt", imp.ID), } @@ -192,7 +193,7 @@ func (a *BeintooAdapter) MakeBids(internalRequest *openrtb2.BidRequest, external var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Unable to unpackage bid response. Error: %s", err.Error()), }} diff --git a/adapters/beintoo/beintootest/supplemental/invalid-response-unmarshall-error.json b/adapters/beintoo/beintootest/supplemental/invalid-response-unmarshall-error.json index eb8840d3404..01cc697dbd6 100644 --- a/adapters/beintoo/beintootest/supplemental/invalid-response-unmarshall-error.json +++ b/adapters/beintoo/beintootest/supplemental/invalid-response-unmarshall-error.json @@ -57,8 +57,8 @@ "expectedMakeBidsErrors": [ { - "value": "Unable to unpackage bid response\\. Error: json: cannot unmarshal string into Go struct field (Bid\\.seatbid\\.bid\\.w|Bid\\.w) of type int64", - "comparison": "regex" + "value": "Unable to unpackage bid response. Error: cannot unmarshal openrtb2.Bid.W: unexpected character", + "comparison": "startswith" } ] } diff --git a/adapters/bematterfull/bematterfull.go b/adapters/bematterfull/bematterfull.go index 337bbc1b60c..5663909e0f3 100644 --- a/adapters/bematterfull/bematterfull.go +++ b/adapters/bematterfull/bematterfull.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type bidType struct { @@ -41,14 +42,14 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co func (a *adapter) buildEndpointFromRequest(imp *openrtb2.Imp) (string, error) { var impExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &impExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &impExt); err != nil { return "", &errortypes.BadInput{ Message: fmt.Sprintf("Failed to deserialize bidder impression extension: %v", err), } } var bematterfullExt openrtb_ext.ExtBematterfull - if err := json.Unmarshal(impExt.Bidder, &bematterfullExt); err != nil { + if err := jsonutil.Unmarshal(impExt.Bidder, &bematterfullExt); err != nil { return "", &errortypes.BadInput{ Message: fmt.Sprintf("Failed to deserialize Bematterfull extension: %v", err), } @@ -116,7 +117,7 @@ func (a *adapter) MakeBids(openRTBRequest *openrtb2.BidRequest, requestToBidder } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(bidderRawResponse.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(bidderRawResponse.Body, &bidResp); err != nil { return nil, []error{err} } @@ -136,7 +137,7 @@ func prepareBidResponse(seats []openrtb2.SeatBid) (*adapters.BidderResponse, []e for _, seatBid := range seats { for bidId, bid := range seatBid.Bid { var bidExt bidExt - if err := json.Unmarshal(bid.Ext, &bidExt); err != nil { + if err := jsonutil.Unmarshal(bid.Ext, &bidExt); err != nil { errs = append(errs, &errortypes.BadServerResponse{ Message: fmt.Sprintf("Failed to parse Bid[%d].Ext: %s", bidId, err.Error()), }) diff --git a/adapters/bematterfull/bematterfulltest/supplemental/bad-response.json b/adapters/bematterfull/bematterfulltest/supplemental/bad-response.json index 942c73e7d30..1ef0d08931b 100644 --- a/adapters/bematterfull/bematterfulltest/supplemental/bad-response.json +++ b/adapters/bematterfull/bematterfulltest/supplemental/bad-response.json @@ -99,7 +99,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ], diff --git a/adapters/bematterfull/bematterfulltest/supplemental/invalid-ext-bidder-object.json b/adapters/bematterfull/bematterfulltest/supplemental/invalid-ext-bidder-object.json index 67778fd4b8e..1b4ed00392a 100644 --- a/adapters/bematterfull/bematterfulltest/supplemental/invalid-ext-bidder-object.json +++ b/adapters/bematterfull/bematterfulltest/supplemental/invalid-ext-bidder-object.json @@ -42,7 +42,7 @@ "httpCalls": [], "expectedMakeRequestsErrors": [ { - "value": "Failed to deserialize Bematterfull extension: json: cannot unmarshal array into Go value of type openrtb_ext.ExtBematterfull", + "value": "Failed to deserialize Bematterfull extension: expect { or n, but found [", "comparison": "literal" } ] diff --git a/adapters/bematterfull/bematterfulltest/supplemental/invalid-ext-object.json b/adapters/bematterfull/bematterfulltest/supplemental/invalid-ext-object.json index aa215eb3e34..16cf58bbe54 100644 --- a/adapters/bematterfull/bematterfulltest/supplemental/invalid-ext-object.json +++ b/adapters/bematterfull/bematterfulltest/supplemental/invalid-ext-object.json @@ -40,7 +40,7 @@ "httpCalls": [], "expectedMakeRequestsErrors": [ { - "value": "Failed to deserialize bidder impression extension: json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "value": "Failed to deserialize bidder impression extension: expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/between/between.go b/adapters/between/between.go index a639c219561..75da4d8c7ea 100644 --- a/adapters/between/between.go +++ b/adapters/between/between.go @@ -14,6 +14,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type BetweenAdapter struct { @@ -69,14 +70,14 @@ func (a *BetweenAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada func unpackImpExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpBetween, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("ignoring imp id=%s, invalid BidderExt", imp.ID), } } var betweenExt openrtb_ext.ExtImpBetween - if err := json.Unmarshal(bidderExt.Bidder, &betweenExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &betweenExt); err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("ignoring imp id=%s, invalid ImpExt", imp.ID), } @@ -183,7 +184,7 @@ func (a *BetweenAdapter) MakeBids(internalRequest *openrtb2.BidRequest, external }} } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Unable to unpackage bid response. Error %s", err.Error()), }} diff --git a/adapters/between/betweentest/supplemental/bad-response-body.json b/adapters/between/betweentest/supplemental/bad-response-body.json index 2998f11a2f9..b35d6cec165 100644 --- a/adapters/between/betweentest/supplemental/bad-response-body.json +++ b/adapters/between/betweentest/supplemental/bad-response-body.json @@ -70,7 +70,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "Unable to unpackage bid response. Error json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "Unable to unpackage bid response. Error expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/beyondmedia/beyondmedia.go b/adapters/beyondmedia/beyondmedia.go index bc1e8ea4b69..9d05335140a 100644 --- a/adapters/beyondmedia/beyondmedia.go +++ b/adapters/beyondmedia/beyondmedia.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -43,10 +44,10 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E var bidderExt adapters.ExtImpBidder var beyondMediaExt openrtb_ext.ImpExtBeyondMedia - if err = json.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { + if err = jsonutil.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { return nil, []error{err} } - if err = json.Unmarshal(bidderExt.Bidder, &beyondMediaExt); err != nil { + if err = jsonutil.Unmarshal(bidderExt.Bidder, &beyondMediaExt); err != nil { return nil, []error{err} } @@ -104,7 +105,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/beyondmedia/beyondmediatest/supplemental/bad_response.json b/adapters/beyondmedia/beyondmediatest/supplemental/bad_response.json index 906fe1cadaf..65d1a117c98 100644 --- a/adapters/beyondmedia/beyondmediatest/supplemental/bad_response.json +++ b/adapters/beyondmedia/beyondmediatest/supplemental/bad_response.json @@ -78,7 +78,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/bidmachine/bidmachine.go b/adapters/bidmachine/bidmachine.go index 3ff85b1dd79..4088f737401 100644 --- a/adapters/bidmachine/bidmachine.go +++ b/adapters/bidmachine/bidmachine.go @@ -17,6 +17,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -54,14 +55,14 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, _ *adapters.ExtraRe } var bidderExt adapters.ExtImpBidder - err := json.Unmarshal(impression.Ext, &bidderExt) + err := jsonutil.Unmarshal(impression.Ext, &bidderExt) if err != nil { errs = append(errs, err) continue } var impressionExt openrtb_ext.ExtImpBidmachine - err = json.Unmarshal(bidderExt.Bidder, &impressionExt) + err = jsonutil.Unmarshal(bidderExt.Bidder, &impressionExt) if err != nil { errs = append(errs, err) continue @@ -137,7 +138,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, _ *adapters.RequestData } var bidResponse openrtb2.BidResponse - err := json.Unmarshal(responseData.Body, &bidResponse) + err := jsonutil.Unmarshal(responseData.Body, &bidResponse) if err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: err.Error(), diff --git a/adapters/bidmatic/bidmatic.go b/adapters/bidmatic/bidmatic.go index 950107ea0e0..3a35362b0f6 100644 --- a/adapters/bidmatic/bidmatic.go +++ b/adapters/bidmatic/bidmatic.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -90,7 +91,7 @@ func (a *adapter) MakeBids(bidReq *openrtb2.BidRequest, unused *adapters.Request } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(httpRes.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(httpRes.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("error while decoding response, err: %s", err), }} @@ -161,14 +162,14 @@ func validateImpression(imp *openrtb2.Imp) (int, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return 0, &errortypes.BadInput{ Message: fmt.Sprintf("ignoring imp id=%s, error while decoding extImpBidder, err: %s", imp.ID, err), } } impExt := openrtb_ext.ExtImpBidmatic{} - err := json.Unmarshal(bidderExt.Bidder, &impExt) + err := jsonutil.Unmarshal(bidderExt.Bidder, &impExt) if err != nil { return 0, &errortypes.BadInput{ Message: fmt.Sprintf("ignoring imp id=%s, error while decoding impExt, err: %s", imp.ID, err), @@ -193,7 +194,7 @@ func validateImpression(imp *openrtb2.Imp) (int, error) { imp.Ext = impExtBuffer - source, err := impExt.SourceId.Int64() // json.Unmarshal returns err if it isn't valid + source, err := impExt.SourceId.Int64() // jsonutil.Unmarshal returns err if it isn't valid if err != nil { return 0, err } diff --git a/adapters/bidmatic/bidmatictest/supplemental/wrong-impression-ext.json b/adapters/bidmatic/bidmatictest/supplemental/wrong-impression-ext.json index 8154afed75f..c471560932c 100644 --- a/adapters/bidmatic/bidmatictest/supplemental/wrong-impression-ext.json +++ b/adapters/bidmatic/bidmatictest/supplemental/wrong-impression-ext.json @@ -19,7 +19,7 @@ "expectedMakeRequestsErrors": [ { - "value": "ignoring imp id=unsupported-native-imp, error while decoding impExt, err: json: invalid number literal, trying to unmarshal \"\\\"some string instead of int\\\"\" into Number", + "value": "ignoring imp id=unsupported-native-imp, error while marshaling impExt, err: json: invalid number literal \"some string instead of int\"", "comparison": "literal" } ] diff --git a/adapters/bidmatic/bidmatictest/supplemental/wrong-response.json b/adapters/bidmatic/bidmatictest/supplemental/wrong-response.json index ad09b32cd1a..5daadf6e1e1 100644 --- a/adapters/bidmatic/bidmatictest/supplemental/wrong-response.json +++ b/adapters/bidmatic/bidmatictest/supplemental/wrong-response.json @@ -58,8 +58,8 @@ ], "expectedMakeBidsErrors": [ { - "value": "error while decoding response, err: unexpected end of JSON input", - "comparison": "literal" + "value": "error while decoding response, err: expect { or n, but found", + "comparison": "startswith" } ] } diff --git a/adapters/bidmyadz/bidmyadz.go b/adapters/bidmyadz/bidmyadz.go index 8b9b4cc841b..8f7409f3407 100644 --- a/adapters/bidmyadz/bidmyadz.go +++ b/adapters/bidmyadz/bidmyadz.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -111,7 +112,7 @@ func (a *adapter) MakeBids( responseBody := bidderRawResponse.Body var bidResp openrtb2.BidResponse - if err := json.Unmarshal(responseBody, &bidResp); err != nil { + if err := jsonutil.Unmarshal(responseBody, &bidResp); err != nil { return nil, []error{err} } @@ -136,7 +137,7 @@ func (a *adapter) MakeBids( var bidExt bidExt var bidType openrtb_ext.BidType - if err := json.Unmarshal(bid.Ext, &bidExt); err != nil { + if err := jsonutil.Unmarshal(bid.Ext, &bidExt); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("BidExt parsing error. %s", err.Error()), }} diff --git a/adapters/bidmyadz/bidmyadztest/supplemental/missing-mediatype.json b/adapters/bidmyadz/bidmyadztest/supplemental/missing-mediatype.json index f787bd20cbc..923576a9ba5 100644 --- a/adapters/bidmyadz/bidmyadztest/supplemental/missing-mediatype.json +++ b/adapters/bidmyadz/bidmyadztest/supplemental/missing-mediatype.json @@ -116,8 +116,8 @@ "expectedMakeBidsErrors": [ { - "value": "BidExt parsing error. unexpected end of JSON input", - "comparison": "literal" + "value": "BidExt parsing error. expect { or n, but found", + "comparison": "startswith" } ] } \ No newline at end of file diff --git a/adapters/bidscube/bidscube.go b/adapters/bidscube/bidscube.go index c16d01b5a33..8912b38339f 100644 --- a/adapters/bidscube/bidscube.go +++ b/adapters/bidscube/bidscube.go @@ -13,6 +13,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -29,7 +30,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, _ *adapters.ExtraRe for _, impression := range impressions { var impExt map[string]json.RawMessage - if err := json.Unmarshal(impression.Ext, &impExt); err != nil { + if err := jsonutil.Unmarshal(impression.Ext, &impExt); err != nil { errs = append(errs, err) continue } @@ -79,7 +80,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, _ *adapters.RequestData } var bidResponse openrtb2.BidResponse - err := json.Unmarshal(responseData.Body, &bidResponse) + err := jsonutil.Unmarshal(responseData.Body, &bidResponse) if err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: err.Error(), diff --git a/adapters/bidscube/bidscubetest/supplemental/bad_response.json b/adapters/bidscube/bidscubetest/supplemental/bad_response.json index a6087b506a4..2eaaba4d21a 100644 --- a/adapters/bidscube/bidscubetest/supplemental/bad_response.json +++ b/adapters/bidscube/bidscubetest/supplemental/bad_response.json @@ -77,7 +77,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/bidscube/bidscubetest/supplemental/imp_ext_string.json b/adapters/bidscube/bidscubetest/supplemental/imp_ext_string.json index ad6c2ede6e8..935764f46d9 100644 --- a/adapters/bidscube/bidscubetest/supplemental/imp_ext_string.json +++ b/adapters/bidscube/bidscubetest/supplemental/imp_ext_string.json @@ -30,7 +30,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type map[string]json.RawMessage", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/bidstack/bidstack.go b/adapters/bidstack/bidstack.go index c4396153211..0600ab70d35 100644 --- a/adapters/bidstack/bidstack.go +++ b/adapters/bidstack/bidstack.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) const ( @@ -84,7 +85,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, _ *adapters.RequestData } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{fmt.Errorf("bid response unmarshal: %v", err)} } @@ -117,10 +118,10 @@ func prepareHeaders(request *openrtb2.BidRequest) (headers http.Header, err erro func getBidderExt(imp openrtb2.Imp) (bidderImpExt openrtb_ext.ImpExtBidstack, err error) { var impExt adapters.ExtImpBidder - if err = json.Unmarshal(imp.Ext, &impExt); err != nil { + if err = jsonutil.Unmarshal(imp.Ext, &impExt); err != nil { return bidderImpExt, fmt.Errorf("imp ext: %v", err) } - if err = json.Unmarshal(impExt.Bidder, &bidderImpExt); err != nil { + if err = jsonutil.Unmarshal(impExt.Bidder, &bidderImpExt); err != nil { return bidderImpExt, fmt.Errorf("bidder ext: %v", err) } return bidderImpExt, nil diff --git a/adapters/bigoad/bigoad.go b/adapters/bigoad/bigoad.go index 82a34de0bdb..5df2da70a07 100644 --- a/adapters/bigoad/bigoad.go +++ b/adapters/bigoad/bigoad.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -78,13 +79,13 @@ func addNonEmptyHeaders(headers *http.Header, headerValues map[string]string) { func getImpExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpBigoAd, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("imp %s: unable to unmarshal ext", imp.ID), } } var bigoadExt openrtb_ext.ExtImpBigoAd - if err := json.Unmarshal(bidderExt.Bidder, &bigoadExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &bigoadExt); err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("imp %s: unable to unmarshal ext.bidder: %v", imp.ID, err), } @@ -108,7 +109,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, _ *adapters.RequestData } var bidResponse openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &bidResponse); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &bidResponse); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Bad server response: %d", err), }} diff --git a/adapters/blasto/blasto.go b/adapters/blasto/blasto.go index 628ba0e9cf4..dd9ad7e4e39 100644 --- a/adapters/blasto/blasto.go +++ b/adapters/blasto/blasto.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -89,13 +90,13 @@ func (a *adapter) MakeRequests( func (a *adapter) getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtBlasto, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: "ext.bidder not provided", } } var blastoExt openrtb_ext.ExtBlasto - if err := json.Unmarshal(bidderExt.Bidder, &blastoExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &blastoExt); err != nil { return nil, &errortypes.BadInput{ Message: "ext.bidder not provided", } @@ -151,7 +152,7 @@ func (a *adapter) MakeBids( responseBody := bidderRawResponse.Body var bidResp openrtb2.BidResponse - if err := json.Unmarshal(responseBody, &bidResp); err != nil { + if err := jsonutil.Unmarshal(responseBody, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Bad Server Response", }} diff --git a/adapters/bliink/bliink.go b/adapters/bliink/bliink.go index 51463698597..ef145a7f82f 100644 --- a/adapters/bliink/bliink.go +++ b/adapters/bliink/bliink.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -68,7 +69,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, _ *adapters.RequestData } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/blue/blue.go b/adapters/blue/blue.go index 127adf136c3..c4fa30c9c46 100644 --- a/adapters/blue/blue.go +++ b/adapters/blue/blue.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -66,7 +67,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/blue/bluetest/supplemental/bad_response.json b/adapters/blue/bluetest/supplemental/bad_response.json index c45d6b84517..c239a50f972 100644 --- a/adapters/blue/bluetest/supplemental/bad_response.json +++ b/adapters/blue/bluetest/supplemental/bad_response.json @@ -51,7 +51,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/bluesea/bluesea.go b/adapters/bluesea/bluesea.go index 2e8d50b6e08..c29399ac290 100644 --- a/adapters/bluesea/bluesea.go +++ b/adapters/bluesea/bluesea.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -82,14 +83,14 @@ func extraImpExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpBluesea, error) { var impExt adapters.ExtImpBidder var blueseaImpExt openrtb_ext.ExtImpBluesea - err := json.Unmarshal(imp.Ext, &impExt) + err := jsonutil.Unmarshal(imp.Ext, &impExt) if err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("Error in parsing imp.ext. err = %v, imp.ext = %v", err.Error(), string(imp.Ext)), } } - err = json.Unmarshal(impExt.Bidder, &blueseaImpExt) + err = jsonutil.Unmarshal(impExt.Bidder, &blueseaImpExt) if err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("Error in parsing imp.ext.bidder. err = %v, bidder = %v", err.Error(), string(impExt.Bidder)), @@ -114,7 +115,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest } var blueseaResponse openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &blueseaResponse); err != nil { + if err := jsonutil.Unmarshal(response.Body, &blueseaResponse); err != nil { return nil, []error{fmt.Errorf("Error in parsing bidresponse body")} } @@ -145,7 +146,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest func getMediaTypeForBid(bid *openrtb2.Bid) (openrtb_ext.BidType, error) { var bidExt blueseaBidExt - if err := json.Unmarshal(bid.Ext, &bidExt); err != nil { + if err := jsonutil.Unmarshal(bid.Ext, &bidExt); err != nil { return "", fmt.Errorf("Error in parsing bid.ext") } diff --git a/adapters/bmtm/brightmountainmedia.go b/adapters/bmtm/brightmountainmedia.go index 068021ff337..ba4e0dacbd9 100644 --- a/adapters/bmtm/brightmountainmedia.go +++ b/adapters/bmtm/brightmountainmedia.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -48,14 +49,14 @@ func (a *adapter) makeRequest(ortbRequest openrtb2.BidRequest, ortbImp openrtb2. } var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(ortbImp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(ortbImp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("Error unmarshalling ExtImpBidder: %s", err.Error()), } } var bmtmExt openrtb_ext.ImpExtBmtm - if err := json.Unmarshal(bidderExt.Bidder, &bmtmExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &bmtmExt); err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("Error unmarshalling ExtImpBmtm: %s", err.Error()), } @@ -99,7 +100,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/boldwin/boldwin.go b/adapters/boldwin/boldwin.go index 48de29f3ce2..8745bfa5bdf 100644 --- a/adapters/boldwin/boldwin.go +++ b/adapters/boldwin/boldwin.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -44,10 +45,10 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E var bidderExt adapters.ExtImpBidder var boldwinExt openrtb_ext.ImpExtBoldwin - if err = json.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { + if err = jsonutil.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { return nil, []error{err} } - if err = json.Unmarshal(bidderExt.Bidder, &boldwinExt); err != nil { + if err = jsonutil.Unmarshal(bidderExt.Bidder, &boldwinExt); err != nil { return nil, []error{err} } @@ -111,7 +112,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/boldwin/boldwintest/supplemental/bad_response.json b/adapters/boldwin/boldwintest/supplemental/bad_response.json index 231a089d2ae..c046bd11674 100644 --- a/adapters/boldwin/boldwintest/supplemental/bad_response.json +++ b/adapters/boldwin/boldwintest/supplemental/bad_response.json @@ -78,7 +78,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/brave/brave.go b/adapters/brave/brave.go index a641314813a..929115cb2b5 100755 --- a/adapters/brave/brave.go +++ b/adapters/brave/brave.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -67,13 +68,13 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte func (a *adapter) getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpBrave, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: "ext.bidder not provided", } } var braveExt openrtb_ext.ExtImpBrave - if err := json.Unmarshal(bidderExt.Bidder, &braveExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &braveExt); err != nil { return nil, &errortypes.BadInput{ Message: "ext.bidder not provided", } @@ -118,7 +119,7 @@ func (a *adapter) MakeBids( } var bidResponse openrtb2.BidResponse - if err := json.Unmarshal(bidderResponse.Body, &bidResponse); err != nil { + if err := jsonutil.Unmarshal(bidderResponse.Body, &bidResponse); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Bad Server Response", }} diff --git a/adapters/bwx/bwx.go b/adapters/bwx/bwx.go index baa80498347..a119f59ac9e 100644 --- a/adapters/bwx/bwx.go +++ b/adapters/bwx/bwx.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type bidType struct { @@ -41,14 +42,14 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co func (a *adapter) buildEndpointFromRequest(imp *openrtb2.Imp) (string, error) { var impExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &impExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &impExt); err != nil { return "", &errortypes.BadInput{ Message: fmt.Sprintf("Failed to deserialize bidder impression extension: %v", err), } } var boldwinxExt openrtb_ext.ExtBWX - if err := json.Unmarshal(impExt.Bidder, &boldwinxExt); err != nil { + if err := jsonutil.Unmarshal(impExt.Bidder, &boldwinxExt); err != nil { return "", &errortypes.BadInput{ Message: fmt.Sprintf("Failed to deserialize BoldwinX extension: %v", err), } @@ -110,7 +111,7 @@ func (a *adapter) MakeBids(openRTBRequest *openrtb2.BidRequest, requestToBidder } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(bidderRawResponse.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(bidderRawResponse.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/bwx/bwxtest/supplemental/bad-response.json b/adapters/bwx/bwxtest/supplemental/bad-response.json index 8a26dc6409f..b75b2069abe 100644 --- a/adapters/bwx/bwxtest/supplemental/bad-response.json +++ b/adapters/bwx/bwxtest/supplemental/bad-response.json @@ -99,7 +99,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ], diff --git a/adapters/bwx/bwxtest/supplemental/invalid-ext-bidder-object.json b/adapters/bwx/bwxtest/supplemental/invalid-ext-bidder-object.json index ed081b7912b..4a4c06e2bd3 100644 --- a/adapters/bwx/bwxtest/supplemental/invalid-ext-bidder-object.json +++ b/adapters/bwx/bwxtest/supplemental/invalid-ext-bidder-object.json @@ -42,7 +42,7 @@ "httpCalls": [], "expectedMakeRequestsErrors": [ { - "value": "Failed to deserialize BoldwinX extension: json: cannot unmarshal array into Go value of type openrtb_ext.ExtBWX", + "value": "Failed to deserialize BoldwinX extension: expect { or n, but found [", "comparison": "literal" } ] diff --git a/adapters/bwx/bwxtest/supplemental/invalid-ext-object.json b/adapters/bwx/bwxtest/supplemental/invalid-ext-object.json index aa215eb3e34..16cf58bbe54 100644 --- a/adapters/bwx/bwxtest/supplemental/invalid-ext-object.json +++ b/adapters/bwx/bwxtest/supplemental/invalid-ext-object.json @@ -40,7 +40,7 @@ "httpCalls": [], "expectedMakeRequestsErrors": [ { - "value": "Failed to deserialize bidder impression extension: json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "value": "Failed to deserialize bidder impression extension: expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/cadent_aperture_mx/cadent_aperture_mxtest/supplemental/invalid-response-unmarshall-error.json b/adapters/cadent_aperture_mx/cadent_aperture_mxtest/supplemental/invalid-response-unmarshall-error.json index 5a48518513f..904f54de283 100644 --- a/adapters/cadent_aperture_mx/cadent_aperture_mxtest/supplemental/invalid-response-unmarshall-error.json +++ b/adapters/cadent_aperture_mx/cadent_aperture_mxtest/supplemental/invalid-response-unmarshall-error.json @@ -62,8 +62,8 @@ "expectedMakeBidsErrors": [ { - "value": "Unable to unpackage bid response\\. Error: json: cannot unmarshal string into Go struct field (Bid\\.seatbid\\.bid\\.w|Bid\\.w) of type int64", - "comparison": "regex" + "value": "Unable to unpackage bid response. Error: cannot unmarshal openrtb2.Bid.W: unexpected character", + "comparison": "startswith" } ] } diff --git a/adapters/cadent_aperture_mx/cadentaperturemx.go b/adapters/cadent_aperture_mx/cadentaperturemx.go index ae191469a27..3623fe86f10 100644 --- a/adapters/cadent_aperture_mx/cadentaperturemx.go +++ b/adapters/cadent_aperture_mx/cadentaperturemx.go @@ -15,6 +15,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -84,14 +85,14 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E func unpackImpExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpCadentApertureMX, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: err.Error(), } } var cadentExt openrtb_ext.ExtImpCadentApertureMX - if err := json.Unmarshal(bidderExt.Bidder, &cadentExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &cadentExt); err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("ignoring imp id=%s, invalid ImpExt", imp.ID), } @@ -267,7 +268,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Unable to unpackage bid response. Error: %s", err.Error()), }} diff --git a/adapters/ccx/ccx.go b/adapters/ccx/ccx.go index eb9e3597265..e924362a824 100644 --- a/adapters/ccx/ccx.go +++ b/adapters/ccx/ccx.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/errortypes" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -62,7 +63,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/cointraffic/cointraffic.go b/adapters/cointraffic/cointraffic.go index e5c6b9156ce..5e5df4d378e 100644 --- a/adapters/cointraffic/cointraffic.go +++ b/adapters/cointraffic/cointraffic.go @@ -2,11 +2,13 @@ package cointraffic import ( "encoding/json" + "net/http" + "github.com/prebid/openrtb/v20/openrtb2" "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/openrtb_ext" - "net/http" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -53,7 +55,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/coinzilla/coinzilla.go b/adapters/coinzilla/coinzilla.go index 8939a75cec7..595efa93b38 100644 --- a/adapters/coinzilla/coinzilla.go +++ b/adapters/coinzilla/coinzilla.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/errortypes" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) { @@ -67,7 +68,7 @@ func (adapter *adapter) MakeBids(openRTBRequest *openrtb2.BidRequest, requestToB } var openRTBBidderResponse openrtb2.BidResponse - if err := json.Unmarshal(bidderRawResponse.Body, &openRTBBidderResponse); err != nil { + if err := jsonutil.Unmarshal(bidderRawResponse.Body, &openRTBBidderResponse); err != nil { return nil, []error{err} } diff --git a/adapters/colossus/colossus.go b/adapters/colossus/colossus.go index d66b588ab4e..a8af6686d8e 100644 --- a/adapters/colossus/colossus.go +++ b/adapters/colossus/colossus.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type ColossusAdapter struct { @@ -99,7 +100,7 @@ func (a *ColossusAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externa var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -124,7 +125,7 @@ func (a *ColossusAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externa func getMediaTypeForImp(bid openrtb2.Bid, imps []openrtb2.Imp) (openrtb_ext.BidType, error) { var bidExt ColossusResponseBidExt - err := json.Unmarshal(bid.Ext, &bidExt) + err := jsonutil.Unmarshal(bid.Ext, &bidExt) if err == nil { switch bidExt.MediaType { case "banner": diff --git a/adapters/colossus/colossustest/supplemental/bad_response.json b/adapters/colossus/colossustest/supplemental/bad_response.json index 10efa26e397..038c597d42f 100644 --- a/adapters/colossus/colossustest/supplemental/bad_response.json +++ b/adapters/colossus/colossustest/supplemental/bad_response.json @@ -79,7 +79,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/compass/compass.go b/adapters/compass/compass.go index ff74757d058..d516a971b27 100644 --- a/adapters/compass/compass.go +++ b/adapters/compass/compass.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -44,10 +45,10 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E var bidderExt adapters.ExtImpBidder var compassExt openrtb_ext.ImpExtCompass - if err = json.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { + if err = jsonutil.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { return nil, []error{err} } - if err = json.Unmarshal(bidderExt.Bidder, &compassExt); err != nil { + if err = jsonutil.Unmarshal(bidderExt.Bidder, &compassExt); err != nil { return nil, []error{err} } @@ -111,7 +112,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/compass/compasstest/supplemental/bad_response.json b/adapters/compass/compasstest/supplemental/bad_response.json index 86656d785bc..ca81c4cc167 100644 --- a/adapters/compass/compasstest/supplemental/bad_response.json +++ b/adapters/compass/compasstest/supplemental/bad_response.json @@ -78,7 +78,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/concert/concert.go b/adapters/concert/concert.go index 26bb105842a..24c247da2d2 100644 --- a/adapters/concert/concert.go +++ b/adapters/concert/concert.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -38,7 +39,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte } var requestMap map[string]interface{} - err = json.Unmarshal(requestJSON, &requestMap) + err = jsonutil.Unmarshal(requestJSON, &requestMap) if err != nil { return nil, []error{err} } @@ -78,7 +79,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } @@ -129,10 +130,10 @@ func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) { func getBidderExt(imp openrtb2.Imp) (bidderImpExt openrtb_ext.ImpExtConcert, err error) { var impExt adapters.ExtImpBidder - if err = json.Unmarshal(imp.Ext, &impExt); err != nil { + if err = jsonutil.Unmarshal(imp.Ext, &impExt); err != nil { return bidderImpExt, fmt.Errorf("imp ext: %v", err) } - if err = json.Unmarshal(impExt.Bidder, &bidderImpExt); err != nil { + if err = jsonutil.Unmarshal(impExt.Bidder, &bidderImpExt); err != nil { return bidderImpExt, fmt.Errorf("bidder ext: %v", err) } return bidderImpExt, nil diff --git a/adapters/connectad/connectad.go b/adapters/connectad/connectad.go index 083d6830935..2a934baed71 100644 --- a/adapters/connectad/connectad.go +++ b/adapters/connectad/connectad.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type ConnectAdAdapter struct { @@ -84,7 +85,7 @@ func (a *ConnectAdAdapter) MakeBids(bidReq *openrtb2.BidRequest, unused *adapter var bidResp openrtb2.BidResponse - if err := json.Unmarshal(httpRes.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(httpRes.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Unable to unpackage bid response. Error: %s", err.Error()), }} @@ -156,14 +157,14 @@ func addHeaderIfNonEmpty(headers http.Header, headerName string, headerValue str func unpackImpExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpConnectAd, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("Impression id=%s has an Error: %s", imp.ID, err.Error()), } } var cadExt openrtb_ext.ExtImpConnectAd - if err := json.Unmarshal(bidderExt.Bidder, &cadExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &cadExt); err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("Impression id=%s, has invalid Ext", imp.ID), } diff --git a/adapters/connectad/connectadtest/supplemental/badresponse.json b/adapters/connectad/connectadtest/supplemental/badresponse.json index 9f2761c9044..0b714f44fe6 100644 --- a/adapters/connectad/connectadtest/supplemental/badresponse.json +++ b/adapters/connectad/connectadtest/supplemental/badresponse.json @@ -84,7 +84,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "Unable to unpackage bid response. Error: json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "Unable to unpackage bid response. Error: expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/connectad/connectadtest/supplemental/no_ext.json b/adapters/connectad/connectadtest/supplemental/no_ext.json index af1b671a5b9..e75ec87b243 100644 --- a/adapters/connectad/connectadtest/supplemental/no_ext.json +++ b/adapters/connectad/connectadtest/supplemental/no_ext.json @@ -21,8 +21,8 @@ }, "expectedMakeRequestsErrors": [ { - "value": "Impression id=test-banner-imp-id has an Error: unexpected end of JSON input", - "comparison": "literal" + "value": "Impression id=test-banner-imp-id has an Error: expect { or n, but found", + "comparison": "startswith" }, { "value": "Error in preprocess of Imp", diff --git a/adapters/consumable/consumable.go b/adapters/consumable/consumable.go index 724a3d45721..33e88099cc1 100644 --- a/adapters/consumable/consumable.go +++ b/adapters/consumable/consumable.go @@ -9,6 +9,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" "github.com/prebid/openrtb/v20/openrtb2" ) @@ -83,7 +84,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } @@ -144,14 +145,14 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co func extractExtensions(impression openrtb2.Imp) (*adapters.ExtImpBidder, *openrtb_ext.ExtImpConsumable, []error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(impression.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(impression.Ext, &bidderExt); err != nil { return nil, nil, []error{&errortypes.BadInput{ Message: err.Error(), }} } var consumableExt openrtb_ext.ExtImpConsumable - if err := json.Unmarshal(bidderExt.Bidder, &consumableExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &consumableExt); err != nil { return nil, nil, []error{&errortypes.BadInput{ Message: err.Error(), }} diff --git a/adapters/conversant/conversant.go b/adapters/conversant/conversant.go index b4cf7dcb091..12d40468d9d 100644 --- a/adapters/conversant/conversant.go +++ b/adapters/conversant/conversant.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type ConversantAdapter struct { @@ -25,14 +26,14 @@ func (c *ConversantAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo * } for i := 0; i < len(request.Imp); i++ { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(request.Imp[i].Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(request.Imp[i].Ext, &bidderExt); err != nil { return nil, []error{&errortypes.BadInput{ Message: fmt.Sprintf("Impression[%d] missing ext object", i), }} } var cnvrExt openrtb_ext.ExtImpConversant - if err := json.Unmarshal(bidderExt.Bidder, &cnvrExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &cnvrExt); err != nil { return nil, []error{&errortypes.BadInput{ Message: fmt.Sprintf("Impression[%d] missing ext.bidder object", i), }} @@ -164,7 +165,7 @@ func (c *ConversantAdapter) MakeBids(internalRequest *openrtb2.BidRequest, exter } var resp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &resp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &resp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("bad server response: %d. ", err), }} diff --git a/adapters/copper6ssp/copper6ssp.go b/adapters/copper6ssp/copper6ssp.go index 57ec6bcc17b..a1c2c5a537a 100644 --- a/adapters/copper6ssp/copper6ssp.go +++ b/adapters/copper6ssp/copper6ssp.go @@ -9,6 +9,7 @@ import ( "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -43,11 +44,11 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E var bidderExt adapters.ExtImpBidder var copper6sspExt openrtb_ext.ImpExtCopper6ssp - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { errs = append(errs, err) continue } - if err := json.Unmarshal(bidderExt.Bidder, &copper6sspExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &copper6sspExt); err != nil { errs = append(errs, err) continue } @@ -116,7 +117,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/copper6ssp/copper6ssptest/supplemental/bad_response.json b/adapters/copper6ssp/copper6ssptest/supplemental/bad_response.json index cd4169c9974..476058ed624 100644 --- a/adapters/copper6ssp/copper6ssptest/supplemental/bad_response.json +++ b/adapters/copper6ssp/copper6ssptest/supplemental/bad_response.json @@ -78,7 +78,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/copper6ssp/copper6ssptest/supplemental/no-valid-bidder-param.json b/adapters/copper6ssp/copper6ssptest/supplemental/no-valid-bidder-param.json index fbe564b6a26..d27134c5ab7 100644 --- a/adapters/copper6ssp/copper6ssptest/supplemental/no-valid-bidder-param.json +++ b/adapters/copper6ssp/copper6ssptest/supplemental/no-valid-bidder-param.json @@ -35,7 +35,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal array into Go struct field ImpExtCopper6ssp.endpointId of type string", + "value": "cannot unmarshal openrtb_ext.ImpExtCopper6ssp.EndpointID: expects \" or n, but found [", "comparison": "literal" } ] diff --git a/adapters/copper6ssp/copper6ssptest/supplemental/no-valid-imp-ext.json b/adapters/copper6ssp/copper6ssptest/supplemental/no-valid-imp-ext.json index 9d6710efe37..09108b2d847 100644 --- a/adapters/copper6ssp/copper6ssptest/supplemental/no-valid-imp-ext.json +++ b/adapters/copper6ssp/copper6ssptest/supplemental/no-valid-imp-ext.json @@ -31,7 +31,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/cpmstar/cpmstar.go b/adapters/cpmstar/cpmstar.go index 3449963470f..aa3f1970b3b 100644 --- a/adapters/cpmstar/cpmstar.go +++ b/adapters/cpmstar/cpmstar.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type Adapter struct { @@ -66,7 +67,7 @@ func preprocess(request *openrtb2.BidRequest) error { var imp = &request.Imp[i] var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return &errortypes.BadInput{ Message: err.Error(), } @@ -77,7 +78,7 @@ func preprocess(request *openrtb2.BidRequest) error { } var extImp openrtb_ext.ExtImpCpmstar - if err := json.Unmarshal(bidderExt.Bidder, &extImp); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &extImp); err != nil { return &errortypes.BadInput{ Message: err.Error(), } @@ -112,7 +113,7 @@ func (a *Adapter) MakeBids(bidRequest *openrtb2.BidRequest, unused *adapters.Req var bidResponse openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &bidResponse); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &bidResponse); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: err.Error(), }} diff --git a/adapters/cpmstar/cpmstartest/supplemental/invalid-response-unmarshall-error.json b/adapters/cpmstar/cpmstartest/supplemental/invalid-response-unmarshall-error.json index 141cfc0271c..5447f2573b3 100644 --- a/adapters/cpmstar/cpmstartest/supplemental/invalid-response-unmarshall-error.json +++ b/adapters/cpmstar/cpmstartest/supplemental/invalid-response-unmarshall-error.json @@ -60,8 +60,8 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go struct field Bid(\\.seatbid\\.bid)?\\.w of type int64", - "comparison": "regex" + "value": "cannot unmarshal openrtb2.Bid.W: unexpected character", + "comparison": "startswith" } ] } \ No newline at end of file diff --git a/adapters/cpmstar/cpmstartest/supplemental/wrong-impression-ext.json b/adapters/cpmstar/cpmstartest/supplemental/wrong-impression-ext.json index 1e8de0acc66..dc30faba5d0 100644 --- a/adapters/cpmstar/cpmstartest/supplemental/wrong-impression-ext.json +++ b/adapters/cpmstar/cpmstartest/supplemental/wrong-impression-ext.json @@ -19,8 +19,8 @@ "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go struct field ExtImpCpmstar.placementId of type int", - "comparison": "literal" + "value": "cannot unmarshal openrtb_ext.ExtImpCpmstar.PoolId: unexpected character", + "comparison": "startswith" } ] } diff --git a/adapters/criteo/criteo.go b/adapters/criteo/criteo.go index 7b6a4cfff89..9ec2c601586 100644 --- a/adapters/criteo/criteo.go +++ b/adapters/criteo/criteo.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -83,7 +84,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } @@ -93,7 +94,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R for _, seatBid := range response.SeatBid { for i := range seatBid.Bid { var bidExt BidExt - if err := json.Unmarshal(seatBid.Bid[i].Ext, &bidExt); err != nil { + if err := jsonutil.Unmarshal(seatBid.Bid[i].Ext, &bidExt); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Missing ext.prebid.type in bid for impression : %s.", seatBid.Bid[i].ImpID), }} @@ -116,7 +117,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R func (a *adapter) ParseFledgeAuctionConfigs(response openrtb2.BidResponse) []*openrtb_ext.FledgeAuctionConfig { var responseExt CriteoExt if response.Ext != nil { - if err := json.Unmarshal(response.Ext, &responseExt); err == nil && len(responseExt.Igi) > 0 { + if err := jsonutil.Unmarshal(response.Ext, &responseExt); err == nil && len(responseExt.Igi) > 0 { fledgeAuctionConfigs := make([]*openrtb_ext.FledgeAuctionConfig, 0, len(responseExt.Igi)) for _, igi := range responseExt.Igi { if len(igi.Igs) > 0 && igi.Igs[0].Config != nil { diff --git a/adapters/cwire/cwire.go b/adapters/cwire/cwire.go index 244be129b30..e8143badce0 100644 --- a/adapters/cwire/cwire.go +++ b/adapters/cwire/cwire.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) /* @@ -80,7 +81,7 @@ func (a *adapter) MakeBids(bidReq *openrtb2.BidRequest, unused *adapters.Request } var resp openrtb2.BidResponse - if err := json.Unmarshal(httpRes.Body, &resp); err != nil { + if err := jsonutil.Unmarshal(httpRes.Body, &resp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Error while decoding response, err: %s", err), }} diff --git a/adapters/datablocks/datablocks.go b/adapters/datablocks/datablocks.go index aea4d65cfad..bd0eee0bf7e 100644 --- a/adapters/datablocks/datablocks.go +++ b/adapters/datablocks/datablocks.go @@ -13,6 +13,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type DatablocksAdapter struct { @@ -87,7 +88,7 @@ func (a *DatablocksAdapter) MakeBids( var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -130,13 +131,13 @@ func splitImpressions(imps []openrtb2.Imp) (map[openrtb_ext.ExtImpDatablocks][]o func getBidderParams(imp *openrtb2.Imp) (*openrtb_ext.ExtImpDatablocks, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("Missing bidder ext: %s", err.Error()), } } var datablocksExt openrtb_ext.ExtImpDatablocks - if err := json.Unmarshal(bidderExt.Bidder, &datablocksExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &datablocksExt); err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("Cannot Resolve sourceId: %s", err.Error()), } diff --git a/adapters/datablocks/datablockstest/supplemental/bad-response-body.json b/adapters/datablocks/datablockstest/supplemental/bad-response-body.json index 8e872cca163..b8915dd4e56 100644 --- a/adapters/datablocks/datablockstest/supplemental/bad-response-body.json +++ b/adapters/datablocks/datablockstest/supplemental/bad-response-body.json @@ -82,7 +82,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/datablocks/datablockstest/supplemental/missing-ext.json b/adapters/datablocks/datablockstest/supplemental/missing-ext.json index 68d29e880b9..9e72e3cb6e5 100644 --- a/adapters/datablocks/datablockstest/supplemental/missing-ext.json +++ b/adapters/datablocks/datablockstest/supplemental/missing-ext.json @@ -18,8 +18,8 @@ "expectedMakeRequestsErrors": [ { - "value": "Missing bidder ext: unexpected end of JSON input", - "comparison": "literal" + "value": "Missing bidder ext: expect { or n, but found", + "comparison": "startswith" } ] diff --git a/adapters/decenterads/decenterads.go b/adapters/decenterads/decenterads.go index e4545466d5c..68df1ee2167 100644 --- a/adapters/decenterads/decenterads.go +++ b/adapters/decenterads/decenterads.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -28,7 +29,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, _ *adapters.ExtraRe for _, impression := range impressions { var impExt map[string]json.RawMessage - if err := json.Unmarshal(impression.Ext, &impExt); err != nil { + if err := jsonutil.Unmarshal(impression.Ext, &impExt); err != nil { errs = append(errs, fmt.Errorf("unable to parse bidder parameers: %s", err)) continue } @@ -78,7 +79,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, _ *adapters.RequestData } var bidResponse openrtb2.BidResponse - err := json.Unmarshal(responseData.Body, &bidResponse) + err := jsonutil.Unmarshal(responseData.Body, &bidResponse) if err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: err.Error(), diff --git a/adapters/decenterads/decenteradstest/supplemental/bad_response.json b/adapters/decenterads/decenteradstest/supplemental/bad_response.json index a6087b506a4..2eaaba4d21a 100644 --- a/adapters/decenterads/decenteradstest/supplemental/bad_response.json +++ b/adapters/decenterads/decenteradstest/supplemental/bad_response.json @@ -77,7 +77,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/decenterads/decenteradstest/supplemental/imp_ext_string.json b/adapters/decenterads/decenteradstest/supplemental/imp_ext_string.json index db938d6a652..4554cb531a7 100644 --- a/adapters/decenterads/decenteradstest/supplemental/imp_ext_string.json +++ b/adapters/decenterads/decenteradstest/supplemental/imp_ext_string.json @@ -30,7 +30,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "unable to parse bidder parameers: json: cannot unmarshal string into Go value of type map[string]json.RawMessage", + "value": "unable to parse bidder parameers: expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/deepintent/deepintent.go b/adapters/deepintent/deepintent.go index 32f0d53ddf8..1499c71a2eb 100644 --- a/adapters/deepintent/deepintent.go +++ b/adapters/deepintent/deepintent.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) const displayManager string = "di_prebid" @@ -41,14 +42,14 @@ func (d *DeepintentAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo * reqCopy.Imp = []openrtb2.Imp{imp} var bidderExt adapters.ExtImpBidder - if err = json.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { + if err = jsonutil.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { errs = append(errs, &errortypes.BadInput{ Message: fmt.Sprintf("Impression id=%s has an Error: %s", imp.ID, err.Error()), }) continue } - if err = json.Unmarshal(bidderExt.Bidder, &deepintentExt); err != nil { + if err = jsonutil.Unmarshal(bidderExt.Bidder, &deepintentExt); err != nil { errs = append(errs, &errortypes.BadInput{ Message: fmt.Sprintf("Impression id=%s, has invalid Ext", imp.ID), }) @@ -87,7 +88,7 @@ func (d *DeepintentAdapter) MakeBids(internalRequest *openrtb2.BidRequest, exter var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/deepintent/deepintenttest/supplemental/bad_response.json b/adapters/deepintent/deepintenttest/supplemental/bad_response.json index 7c090732330..c86881f7e36 100644 --- a/adapters/deepintent/deepintenttest/supplemental/bad_response.json +++ b/adapters/deepintent/deepintenttest/supplemental/bad_response.json @@ -85,7 +85,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/deepintent/deepintenttest/supplemental/no_ext-1.json b/adapters/deepintent/deepintenttest/supplemental/no_ext-1.json index 609c08e71ad..ba0c54018d7 100644 --- a/adapters/deepintent/deepintenttest/supplemental/no_ext-1.json +++ b/adapters/deepintent/deepintenttest/supplemental/no_ext-1.json @@ -22,7 +22,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "Impression id=test-banner-imp-id has an Error: json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "value": "Impression id=test-banner-imp-id has an Error: expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/deepintent/deepintenttest/supplemental/no_ext.json b/adapters/deepintent/deepintenttest/supplemental/no_ext.json index f40257e4716..bf2fdf09f29 100644 --- a/adapters/deepintent/deepintenttest/supplemental/no_ext.json +++ b/adapters/deepintent/deepintenttest/supplemental/no_ext.json @@ -21,8 +21,8 @@ }, "expectedMakeRequestsErrors": [ { - "value": "Impression id=test-banner-imp-id has an Error: unexpected end of JSON input", - "comparison": "literal" + "value": "Impression id=test-banner-imp-id has an Error: expect { or n, but found", + "comparison": "startswith" } ] } diff --git a/adapters/definemedia/definemedia.go b/adapters/definemedia/definemedia.go index 0bb4ff79e19..5fe7e116e33 100644 --- a/adapters/definemedia/definemedia.go +++ b/adapters/definemedia/definemedia.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -62,7 +63,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -93,7 +94,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) { if bid.Ext != nil { var bidExt openrtb_ext.ExtBid - err := json.Unmarshal(bid.Ext, &bidExt) + err := jsonutil.Unmarshal(bid.Ext, &bidExt) if err == nil && bidExt.Prebid != nil { if (bidExt.Prebid.Type == openrtb_ext.BidTypeBanner) || (bidExt.Prebid.Type == openrtb_ext.BidTypeNative) { return openrtb_ext.ParseBidType(string(bidExt.Prebid.Type)) diff --git a/adapters/definemedia/definemediatest/supplemental/unmarshal-error.json b/adapters/definemedia/definemediatest/supplemental/unmarshal-error.json index ac03cc6e48c..532fab1224a 100644 --- a/adapters/definemedia/definemediatest/supplemental/unmarshal-error.json +++ b/adapters/definemedia/definemediatest/supplemental/unmarshal-error.json @@ -218,7 +218,7 @@ "expectedBidResponses": [], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/dianomi/dianomi.go b/adapters/dianomi/dianomi.go index 57cd85a27c3..6d8ec0ead64 100644 --- a/adapters/dianomi/dianomi.go +++ b/adapters/dianomi/dianomi.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -36,7 +37,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte for _, imp := range request.Imp { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { errors = append(errors, &errortypes.BadInput{ Message: err.Error(), }) @@ -44,7 +45,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte } var dianomiImpExt openrtb_ext.ExtImpDianomi - if err := json.Unmarshal(bidderExt.Bidder, &dianomiImpExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &dianomiImpExt); err != nil { errors = append(errors, &errortypes.BadInput{ Message: err.Error(), }) @@ -65,7 +66,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte var err error if len(request.Ext) > 0 { - if err = json.Unmarshal(request.Ext, &requestExt); err != nil { + if err = jsonutil.Unmarshal(request.Ext, &requestExt); err != nil { errors = append(errors, err) } } @@ -121,7 +122,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } @@ -148,7 +149,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) { if bid.Ext != nil { var bidExt openrtb_ext.ExtBid - err := json.Unmarshal(bid.Ext, &bidExt) + err := jsonutil.Unmarshal(bid.Ext, &bidExt) if err == nil && bidExt.Prebid != nil { return openrtb_ext.ParseBidType(string(bidExt.Prebid.Type)) } diff --git a/adapters/dianomi/dianomitest/supplemental/unparsable-response.json b/adapters/dianomi/dianomitest/supplemental/unparsable-response.json index cf5ab4fca11..3bca23e3826 100644 --- a/adapters/dianomi/dianomitest/supplemental/unparsable-response.json +++ b/adapters/dianomi/dianomitest/supplemental/unparsable-response.json @@ -43,7 +43,7 @@ "expectedBidResponses": [], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/displayio/displayio.go b/adapters/displayio/displayio.go index b54998553b3..70c8316959b 100644 --- a/adapters/displayio/displayio.go +++ b/adapters/displayio/displayio.go @@ -13,6 +13,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -57,7 +58,7 @@ func (adapter *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo * } var bidderExt adapters.ExtImpBidder - err := json.Unmarshal(impression.Ext, &bidderExt) + err := jsonutil.Unmarshal(impression.Ext, &bidderExt) if err != nil { errs = append(errs, err) @@ -65,7 +66,7 @@ func (adapter *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo * } var impressionExt openrtb_ext.ExtImpDisplayio - err = json.Unmarshal(bidderExt.Bidder, &impressionExt) + err = jsonutil.Unmarshal(bidderExt.Bidder, &impressionExt) if err != nil { errs = append(errs, err) continue @@ -75,7 +76,7 @@ func (adapter *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo * requestCopy := *request - err = json.Unmarshal(requestCopy.Ext, &requestExt) + err = jsonutil.Unmarshal(requestCopy.Ext, &requestExt) if err != nil { requestExt = make(map[string]interface{}) } @@ -128,7 +129,7 @@ func (adapter *adapter) MakeBids(internalRequest *openrtb2.BidRequest, _ *adapte var bidResp openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &bidResp); err != nil { msg := fmt.Sprintf("Bad server response: %d", err) return nil, []error{&errortypes.BadServerResponse{Message: msg}} } diff --git a/adapters/dmx/dmx.go b/adapters/dmx/dmx.go index 0ad522c4398..71a98a903fb 100644 --- a/adapters/dmx/dmx.go +++ b/adapters/dmx/dmx.go @@ -14,6 +14,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type DmxAdapter struct { @@ -75,7 +76,7 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb2.BidRequest, req *adapt } if len(request.Imp) >= 1 { - err := json.Unmarshal(request.Imp[0].Ext, &rootExtInfo) + err := jsonutil.Unmarshal(request.Imp[0].Ext, &rootExtInfo) if err != nil { errs = append(errs, err) } else { @@ -148,7 +149,7 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb2.BidRequest, req *adapt hasNoID = false } if dmxReq.User.Ext != nil { - if err := json.Unmarshal(dmxReq.User.Ext, &userExt); err == nil { + if err := jsonutil.Unmarshal(dmxReq.User.Ext, &userExt); err == nil { if len(userExt.Eids) > 0 { hasNoID = false } @@ -161,7 +162,7 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb2.BidRequest, req *adapt var params dmxExt const intVal int8 = 1 source := (*json.RawMessage)(&inst.Ext) - if err := json.Unmarshal(*source, ¶ms); err != nil { + if err := jsonutil.Unmarshal(*source, ¶ms); err != nil { errs = append(errs, err) } if isDmxParams(params.Bidder) { @@ -236,7 +237,7 @@ func (adapter *DmxAdapter) MakeBids(request *openrtb2.BidRequest, externalReques var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/driftpixel/driftpixel.go b/adapters/driftpixel/driftpixel.go index e756b03de70..30b36ad5327 100644 --- a/adapters/driftpixel/driftpixel.go +++ b/adapters/driftpixel/driftpixel.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type bidType struct { @@ -41,14 +42,14 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co func (a *adapter) buildEndpointFromRequest(imp *openrtb2.Imp) (string, error) { var impExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &impExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &impExt); err != nil { return "", &errortypes.BadInput{ Message: fmt.Sprintf("Failed to deserialize bidder impression extension: %v", err), } } var driftpixelExt openrtb_ext.ExtDriftPixel - if err := json.Unmarshal(impExt.Bidder, &driftpixelExt); err != nil { + if err := jsonutil.Unmarshal(impExt.Bidder, &driftpixelExt); err != nil { return "", &errortypes.BadInput{ Message: fmt.Sprintf("Failed to deserialize DriftPixel extension: %v", err), } @@ -110,7 +111,7 @@ func (a *adapter) MakeBids(openRTBRequest *openrtb2.BidRequest, requestToBidder } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(bidderRawResponse.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(bidderRawResponse.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/driftpixel/driftpixeltest/supplemental/bad-response.json b/adapters/driftpixel/driftpixeltest/supplemental/bad-response.json index 109e51ed4df..b5811eb2e5f 100644 --- a/adapters/driftpixel/driftpixeltest/supplemental/bad-response.json +++ b/adapters/driftpixel/driftpixeltest/supplemental/bad-response.json @@ -99,7 +99,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ], diff --git a/adapters/driftpixel/driftpixeltest/supplemental/invalid-ext-bidder-object.json b/adapters/driftpixel/driftpixeltest/supplemental/invalid-ext-bidder-object.json index 1b812955b1d..685b659ea9a 100644 --- a/adapters/driftpixel/driftpixeltest/supplemental/invalid-ext-bidder-object.json +++ b/adapters/driftpixel/driftpixeltest/supplemental/invalid-ext-bidder-object.json @@ -42,7 +42,7 @@ "httpCalls": [], "expectedMakeRequestsErrors": [ { - "value": "Failed to deserialize DriftPixel extension: json: cannot unmarshal array into Go value of type openrtb_ext.ExtDriftPixel", + "value": "Failed to deserialize DriftPixel extension: expect { or n, but found [", "comparison": "literal" } ] diff --git a/adapters/driftpixel/driftpixeltest/supplemental/invalid-ext-object.json b/adapters/driftpixel/driftpixeltest/supplemental/invalid-ext-object.json index aa215eb3e34..16cf58bbe54 100644 --- a/adapters/driftpixel/driftpixeltest/supplemental/invalid-ext-object.json +++ b/adapters/driftpixel/driftpixeltest/supplemental/invalid-ext-object.json @@ -40,7 +40,7 @@ "httpCalls": [], "expectedMakeRequestsErrors": [ { - "value": "Failed to deserialize bidder impression extension: json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "value": "Failed to deserialize bidder impression extension: expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/dxkulture/dxkulture.go b/adapters/dxkulture/dxkulture.go index 90fb341f533..2d508ca2738 100644 --- a/adapters/dxkulture/dxkulture.go +++ b/adapters/dxkulture/dxkulture.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" "github.com/prebid/openrtb/v20/openrtb2" ) @@ -81,7 +82,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest } var ortbResponse openrtb2.BidResponse - err := json.Unmarshal(response.Body, &ortbResponse) + err := jsonutil.Unmarshal(response.Body, &ortbResponse) if err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Bad Server Response", @@ -122,14 +123,14 @@ func getBidType(bid *openrtb2.Bid) (openrtb_ext.BidType, error) { func parseExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpDXKulture, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("Ignoring imp id=%s, error while decoding extImpBidder, err: %s", imp.ID, err), } } impExt := openrtb_ext.ExtImpDXKulture{} - err := json.Unmarshal(bidderExt.Bidder, &impExt) + err := jsonutil.Unmarshal(bidderExt.Bidder, &impExt) if err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("Ignoring imp id=%s, error while decoding impExt, err: %s", imp.ID, err), diff --git a/adapters/dxkulture/dxkulturetest/supplemental/invalid-imp-ext-bidder.json b/adapters/dxkulture/dxkulturetest/supplemental/invalid-imp-ext-bidder.json index ae30b327030..c60c6080577 100644 --- a/adapters/dxkulture/dxkulturetest/supplemental/invalid-imp-ext-bidder.json +++ b/adapters/dxkulture/dxkulturetest/supplemental/invalid-imp-ext-bidder.json @@ -33,7 +33,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "Ignoring imp id=test-imp-id, error while decoding impExt, err: json: cannot unmarshal string into Go value of type openrtb_ext.ExtImpDXKulture", + "value": "Ignoring imp id=test-imp-id, error while decoding impExt, err: expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/dxkulture/dxkulturetest/supplemental/invalid-imp-ext.json b/adapters/dxkulture/dxkulturetest/supplemental/invalid-imp-ext.json index 2587dc216d2..379acd586cc 100644 --- a/adapters/dxkulture/dxkulturetest/supplemental/invalid-imp-ext.json +++ b/adapters/dxkulture/dxkulturetest/supplemental/invalid-imp-ext.json @@ -31,7 +31,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "Ignoring imp id=test-imp-id, error while decoding extImpBidder, err: json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "value": "Ignoring imp id=test-imp-id, error while decoding extImpBidder, err: expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/e_volution/evolution.go b/adapters/e_volution/evolution.go index 89ab5e0994c..7aac29caf33 100644 --- a/adapters/e_volution/evolution.go +++ b/adapters/e_volution/evolution.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -84,7 +85,7 @@ func (a *adapter) MakeBids( responseBody := bidderRawResponse.Body var bidResp openrtb2.BidResponse - if err := json.Unmarshal(responseBody, &bidResp); err != nil { + if err := jsonutil.Unmarshal(responseBody, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Bad response, %s", err), }} @@ -101,7 +102,7 @@ func (a *adapter) MakeBids( for i := range sb.Bid { var bidType openrtb_ext.BidType var bidExt bidExt - if err := json.Unmarshal(sb.Bid[i].Ext, &bidExt); err != nil { + if err := jsonutil.Unmarshal(sb.Bid[i].Ext, &bidExt); err != nil { bidType = openrtb_ext.BidTypeBanner } else { bidType = bidExt.MediaType diff --git a/adapters/e_volution/evolutiontest/supplemental/bad-response.json b/adapters/e_volution/evolutiontest/supplemental/bad-response.json index d30a01e3158..0878829ca1b 100644 --- a/adapters/e_volution/evolutiontest/supplemental/bad-response.json +++ b/adapters/e_volution/evolutiontest/supplemental/bad-response.json @@ -150,7 +150,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "Bad response, json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "Bad response, expect { or n, but found \"", "comparison": "literal" } ], diff --git a/adapters/edge226/edge226.go b/adapters/edge226/edge226.go index 0859da1df67..1c034cc6c16 100644 --- a/adapters/edge226/edge226.go +++ b/adapters/edge226/edge226.go @@ -9,6 +9,7 @@ import ( "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -43,10 +44,10 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E var bidderExt adapters.ExtImpBidder var edge226Ext openrtb_ext.ImpExtEdge226 - if err = json.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { + if err = jsonutil.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { return nil, []error{err} } - if err = json.Unmarshal(bidderExt.Bidder, &edge226Ext); err != nil { + if err = jsonutil.Unmarshal(bidderExt.Bidder, &edge226Ext); err != nil { return nil, []error{err} } @@ -107,7 +108,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/edge226/edge226test/supplemental/bad_response.json b/adapters/edge226/edge226test/supplemental/bad_response.json index aa37c31f5b1..7ea65762bdb 100644 --- a/adapters/edge226/edge226test/supplemental/bad_response.json +++ b/adapters/edge226/edge226test/supplemental/bad_response.json @@ -78,7 +78,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/emtv/emtv.go b/adapters/emtv/emtv.go index f361010ebbe..3a984b4ae59 100644 --- a/adapters/emtv/emtv.go +++ b/adapters/emtv/emtv.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -45,10 +46,10 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E var bidderExt adapters.ExtImpBidder var emtvExt openrtb_ext.ImpExtEmtv - if err = json.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { + if err = jsonutil.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { return nil, []error{err} } - if err = json.Unmarshal(bidderExt.Bidder, &emtvExt); err != nil { + if err = jsonutil.Unmarshal(bidderExt.Bidder, &emtvExt); err != nil { return nil, []error{err} } @@ -116,7 +117,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/emtv/emtvtest/supplemental/bad_response.json b/adapters/emtv/emtvtest/supplemental/bad_response.json index c732ba92c67..5cc4a338ac3 100644 --- a/adapters/emtv/emtvtest/supplemental/bad_response.json +++ b/adapters/emtv/emtvtest/supplemental/bad_response.json @@ -78,7 +78,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/eplanning/eplanning.go b/adapters/eplanning/eplanning.go index 25a44cdd44f..905cbb29ea4 100644 --- a/adapters/eplanning/eplanning.go +++ b/adapters/eplanning/eplanning.go @@ -1,7 +1,6 @@ package eplanning import ( - "encoding/json" "math/rand" "net/http" "net/url" @@ -17,6 +16,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" "strconv" ) @@ -243,7 +243,7 @@ func cleanName(name string) string { func verifyImp(imp *openrtb2.Imp, isMobile bool, impType int) (*openrtb_ext.ExtImpEPlanning, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("Ignoring imp id=%s, error while decoding extImpBidder, err: %s", imp.ID, err), } @@ -268,7 +268,7 @@ func verifyImp(imp *openrtb2.Imp, isMobile bool, impType int) (*openrtb_ext.ExtI } impExt := openrtb_ext.ExtImpEPlanning{} - err := json.Unmarshal(bidderExt.Bidder, &impExt) + err := jsonutil.Unmarshal(bidderExt.Bidder, &impExt) if err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("Ignoring imp id=%s, error while decoding impExt, err: %s", imp.ID, err), @@ -364,7 +364,7 @@ func (adapter *EPlanningAdapter) MakeBids(internalRequest *openrtb2.BidRequest, } var parsedResponse hbResponse - if err := json.Unmarshal(response.Body, &parsedResponse); err != nil { + if err := jsonutil.Unmarshal(response.Body, &parsedResponse); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Error unmarshaling HB response: %s", err.Error()), }} diff --git a/adapters/eplanning/eplanningtest/supplemental/bad-imp-ext.json b/adapters/eplanning/eplanningtest/supplemental/bad-imp-ext.json index 475adfd95ac..572349a4e1d 100644 --- a/adapters/eplanning/eplanningtest/supplemental/bad-imp-ext.json +++ b/adapters/eplanning/eplanningtest/supplemental/bad-imp-ext.json @@ -19,7 +19,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "Ignoring imp id=test-imp-id, error while decoding impExt, err: json: cannot unmarshal number into Go struct field ExtImpEPlanning.ci of type string", + "value": "Ignoring imp id=test-imp-id, error while decoding impExt, err: cannot unmarshal openrtb_ext.ExtImpEPlanning.ClientID: expects \" or n, but found 1", "comparison": "literal" } ] diff --git a/adapters/eplanning/eplanningtest/supplemental/invalid-response-unmarshall-error.json b/adapters/eplanning/eplanningtest/supplemental/invalid-response-unmarshall-error.json index e507648206d..3c1b08ae6bd 100644 --- a/adapters/eplanning/eplanningtest/supplemental/invalid-response-unmarshall-error.json +++ b/adapters/eplanning/eplanningtest/supplemental/invalid-response-unmarshall-error.json @@ -48,8 +48,8 @@ "expectedMakeBidsErrors": [ { - "value": "Error unmarshaling HB response: json: cannot unmarshal string into Go struct field (hbResponseAd\\.sp\\.a\\.w|hbResponseAd\\.w) of type uint64", - "comparison": "regex" + "value": "Error unmarshaling HB response: cannot unmarshal eplanning.hbResponseAd.Width: unexpected character", + "comparison": "startswith" } ] } diff --git a/adapters/epom/epom.go b/adapters/epom/epom.go index 0bee7c33e3d..d95618a0e39 100644 --- a/adapters/epom/epom.go +++ b/adapters/epom/epom.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -86,7 +87,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/escalax/escalax.go b/adapters/escalax/escalax.go index 87cec5e17a9..24e581ce7bf 100644 --- a/adapters/escalax/escalax.go +++ b/adapters/escalax/escalax.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -82,13 +83,13 @@ func (a *adapter) MakeRequests(openRTBRequest *openrtb2.BidRequest, reqInfo *ada func getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtEscalax, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: "Error parsing escalaxExt - " + err.Error(), } } var escalaxExt openrtb_ext.ExtEscalax - if err := json.Unmarshal(bidderExt.Bidder, &escalaxExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &escalaxExt); err != nil { return nil, &errortypes.BadInput{ Message: "Error parsing bidderExt - " + err.Error(), } @@ -113,7 +114,7 @@ func (a *adapter) MakeBids(openRTBRequest *openrtb2.BidRequest, requestToBidder responseBody := bidderRawResponse.Body var bidResp openrtb2.BidResponse - if err := json.Unmarshal(responseBody, &bidResp); err != nil { + if err := jsonutil.Unmarshal(responseBody, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Bad Server Response", }} diff --git a/adapters/escalax/escalaxtest/supplemental/invalid-bidder-ext-object.json b/adapters/escalax/escalaxtest/supplemental/invalid-bidder-ext-object.json index 96a3037ced0..016fbd43490 100644 --- a/adapters/escalax/escalaxtest/supplemental/invalid-bidder-ext-object.json +++ b/adapters/escalax/escalaxtest/supplemental/invalid-bidder-ext-object.json @@ -1,7 +1,7 @@ { "expectedMakeRequestsErrors": [ { - "value": "Error parsing bidderExt - json: cannot unmarshal string into Go value of type openrtb_ext.ExtEscalax", + "value": "Error parsing bidderExt - expect { or n, but found \"", "comparison": "literal" } ], diff --git a/adapters/escalax/escalaxtest/supplemental/invalid-ext-object.json b/adapters/escalax/escalaxtest/supplemental/invalid-ext-object.json index f3725c1005d..ccc32ed87a6 100644 --- a/adapters/escalax/escalaxtest/supplemental/invalid-ext-object.json +++ b/adapters/escalax/escalaxtest/supplemental/invalid-ext-object.json @@ -1,7 +1,7 @@ { "expectedMakeRequestsErrors": [ { - "value": "Error parsing escalaxExt - json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "value": "Error parsing escalaxExt - expect { or n, but found \"", "comparison": "literal" } ], diff --git a/adapters/flipp/flipp.go b/adapters/flipp/flipp.go index 55a3ce7b3e1..83628da42d7 100644 --- a/adapters/flipp/flipp.go +++ b/adapters/flipp/flipp.go @@ -16,6 +16,7 @@ import ( "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" "github.com/prebid/prebid-server/v2/util/uuidutil" ) @@ -94,7 +95,7 @@ func (a *adapter) processImp(request *openrtb2.BidRequest, imp openrtb2.Imp) (*a if err != nil { return nil, fmt.Errorf("flipp params not found. %v", err) } - err = json.Unmarshal(params, &flippExtParams) + err = jsonutil.Unmarshal(params, &flippExtParams) if err != nil { return nil, fmt.Errorf("unable to extract flipp params. %v", err) } @@ -191,7 +192,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var campaignResponseBody CampaignResponseBody - if err := json.Unmarshal(responseData.Body, &campaignResponseBody); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &campaignResponseBody); err != nil { return nil, []error{err} } @@ -248,7 +249,7 @@ func paramsUserKeyPermitted(request *openrtb2.BidRequest) bool { var extData struct { TransmitEids *bool `json:"transmitEids,omitempty"` } - if err := json.Unmarshal(request.Ext, &extData); err == nil { + if err := jsonutil.Unmarshal(request.Ext, &extData); err == nil { if extData.TransmitEids != nil && !*extData.TransmitEids { return false } diff --git a/adapters/flipp/flipptest/supplemental/bad-response.json b/adapters/flipp/flipptest/supplemental/bad-response.json index f17320bded9..64920da0e55 100644 --- a/adapters/flipp/flipptest/supplemental/bad-response.json +++ b/adapters/flipp/flipptest/supplemental/bad-response.json @@ -82,7 +82,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type flipp.CampaignResponseBody", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/freewheelssp/freewheelssp.go b/adapters/freewheelssp/freewheelssp.go index df6f756bb65..8d3b61f6254 100644 --- a/adapters/freewheelssp/freewheelssp.go +++ b/adapters/freewheelssp/freewheelssp.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -20,14 +21,14 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E for i := 0; i < len(request.Imp); i++ { imp := &request.Imp[i] var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, []error{&errortypes.BadInput{ Message: fmt.Sprintf("Invalid imp.ext for impression index %d. Error Infomation: %s", i, err.Error()), }} } var impExt openrtb_ext.ImpExtFreewheelSSP - if err := json.Unmarshal(bidderExt.Bidder, &impExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &impExt); err != nil { return nil, []error{&errortypes.BadInput{ Message: fmt.Sprintf("Invalid imp.ext for impression index %d. Error Infomation: %s", i, err.Error()), }} @@ -73,7 +74,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/frvradn/frvradn.go b/adapters/frvradn/frvradn.go index 7d71e13e374..11aaaed3fed 100644 --- a/adapters/frvradn/frvradn.go +++ b/adapters/frvradn/frvradn.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -90,7 +91,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } @@ -117,13 +118,13 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R func getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ImpExtFRVRAdn, error) { var extImpBidder adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &extImpBidder); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &extImpBidder); err != nil { return nil, &errortypes.BadInput{ Message: "missing ext", } } var frvrAdnExt openrtb_ext.ImpExtFRVRAdn - if err := json.Unmarshal(extImpBidder.Bidder, &frvrAdnExt); err != nil { + if err := jsonutil.Unmarshal(extImpBidder.Bidder, &frvrAdnExt); err != nil { return nil, &errortypes.BadInput{ Message: "missing ext.bidder", } @@ -139,7 +140,7 @@ func getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ImpExtFRVRAdn, error) { func getBidMediaType(bid *openrtb2.Bid) (openrtb_ext.BidType, error) { var extBid openrtb_ext.ExtBid - err := json.Unmarshal(bid.Ext, &extBid) + err := jsonutil.Unmarshal(bid.Ext, &extBid) if err != nil { return "", fmt.Errorf("unable to deserialize imp %v bid.ext", bid.ImpID) } diff --git a/adapters/gamma/gamma.go b/adapters/gamma/gamma.go index 56153aeedd6..fb731bd1bc3 100644 --- a/adapters/gamma/gamma.go +++ b/adapters/gamma/gamma.go @@ -13,6 +13,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type GammaAdapter struct { @@ -62,7 +63,7 @@ func (a *GammaAdapter) makeRequest(request *openrtb2.BidRequest, imp openrtb2.Im var errors []error var bidderExt adapters.ExtImpBidder - err := json.Unmarshal(imp.Ext, &bidderExt) + err := jsonutil.Unmarshal(imp.Ext, &bidderExt) if err != nil { err = &errortypes.BadInput{ Message: "ext.bidder not provided", @@ -71,7 +72,7 @@ func (a *GammaAdapter) makeRequest(request *openrtb2.BidRequest, imp openrtb2.Im return nil, errors } var gammaExt openrtb_ext.ExtImpGamma - err = json.Unmarshal(bidderExt.Bidder, &gammaExt) + err = jsonutil.Unmarshal(bidderExt.Bidder, &gammaExt) if err != nil { err = &errortypes.BadInput{ Message: "ext.bidder.publisher not provided", @@ -243,7 +244,7 @@ func (a *GammaAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRe } var gammaResp gammaBidResponse - if err := json.Unmarshal(response.Body, &gammaResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &gammaResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("bad server response: %d. ", err), }} diff --git a/adapters/gamma/gammatest/supplemental/bad-response-no-body.json b/adapters/gamma/gammatest/supplemental/bad-response-no-body.json index 7d27e7c8160..86ba810e453 100644 --- a/adapters/gamma/gammatest/supplemental/bad-response-no-body.json +++ b/adapters/gamma/gammatest/supplemental/bad-response-no-body.json @@ -40,8 +40,8 @@ ], "expectedMakeBidsErrors": [ { - "value": "bad server response: &{%!d(string=unexpected end of JSON input) 0}. ", - "comparison": "literal" + "value": "bad server response: &{%!d(string=expect { or n, but found", + "comparison": "startswith" } ] } diff --git a/adapters/gamoshi/gamoshi.go b/adapters/gamoshi/gamoshi.go index 13cf4d8b2fd..bec0df494d6 100644 --- a/adapters/gamoshi/gamoshi.go +++ b/adapters/gamoshi/gamoshi.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type GamoshiAdapter struct { @@ -69,7 +70,7 @@ func (a *GamoshiAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada errors := make([]error, 0, 1) var bidderExt adapters.ExtImpBidder - err = json.Unmarshal(request.Imp[0].Ext, &bidderExt) + err = jsonutil.Unmarshal(request.Imp[0].Ext, &bidderExt) if err != nil { err = &errortypes.BadInput{ @@ -79,7 +80,7 @@ func (a *GamoshiAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada return nil, errors } var gamoshiExt openrtb_ext.ExtImpGamoshi - err = json.Unmarshal(bidderExt.Bidder, &gamoshiExt) + err = jsonutil.Unmarshal(bidderExt.Bidder, &gamoshiExt) if err != nil { err = &errortypes.BadInput{ Message: "ext.bidder.supplyPartnerId not provided", @@ -143,7 +144,7 @@ func (a *GamoshiAdapter) MakeBids(internalRequest *openrtb2.BidRequest, external } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("bad server response: %v. ", err), }} diff --git a/adapters/gamoshi/gamoshitest/supplemental/bad-response-no-body.json b/adapters/gamoshi/gamoshitest/supplemental/bad-response-no-body.json index 897844ff8e4..ddbcf435f46 100644 --- a/adapters/gamoshi/gamoshitest/supplemental/bad-response-no-body.json +++ b/adapters/gamoshi/gamoshitest/supplemental/bad-response-no-body.json @@ -51,8 +51,8 @@ ], "expectedMakeBidsErrors": [ { - "value": "bad server response: unexpected end of JSON input. ", - "comparison": "literal" + "value": "bad server response: expect { or n, but found", + "comparison": "startswith" } ] } diff --git a/adapters/globalsun/globalsun.go b/adapters/globalsun/globalsun.go index 533815f7403..b047ca43172 100644 --- a/adapters/globalsun/globalsun.go +++ b/adapters/globalsun/globalsun.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -100,7 +101,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/globalsun/globalsuntest/supplemental/bad_response.json b/adapters/globalsun/globalsuntest/supplemental/bad_response.json index c732ba92c67..5cc4a338ac3 100644 --- a/adapters/globalsun/globalsuntest/supplemental/bad_response.json +++ b/adapters/globalsun/globalsuntest/supplemental/bad_response.json @@ -78,7 +78,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/gothamads/gothamads.go b/adapters/gothamads/gothamads.go index b4fc8e64cdd..81e7715f4c1 100644 --- a/adapters/gothamads/gothamads.go +++ b/adapters/gothamads/gothamads.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -82,13 +83,13 @@ func (a *adapter) MakeRequests(openRTBRequest *openrtb2.BidRequest, reqInfo *ada func getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtGothamAds, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: err.Error(), } } var gothamadsExt openrtb_ext.ExtGothamAds - if err := json.Unmarshal(bidderExt.Bidder, &gothamadsExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &gothamadsExt); err != nil { return nil, &errortypes.BadInput{ Message: err.Error(), } @@ -124,7 +125,7 @@ func (a *adapter) MakeBids(openRTBRequest *openrtb2.BidRequest, requestToBidder responseBody := bidderRawResponse.Body var bidResp openrtb2.BidResponse - if err := json.Unmarshal(responseBody, &bidResp); err != nil { + if err := jsonutil.Unmarshal(responseBody, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Bad Server Response", }} diff --git a/adapters/gothamads/gothamadstest/supplemental/invalid-bidder-ext-object.json b/adapters/gothamads/gothamadstest/supplemental/invalid-bidder-ext-object.json index e412d39ca2c..ea4091e1489 100644 --- a/adapters/gothamads/gothamadstest/supplemental/invalid-bidder-ext-object.json +++ b/adapters/gothamads/gothamadstest/supplemental/invalid-bidder-ext-object.json @@ -1,7 +1,7 @@ { "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb_ext.ExtGothamAds", + "value": "expect { or n, but found \"", "comparison": "literal" } ], diff --git a/adapters/gothamads/gothamadstest/supplemental/invalid-gotham-ext-object.json b/adapters/gothamads/gothamadstest/supplemental/invalid-gotham-ext-object.json index 6075e2a4b3d..294b6d1406c 100644 --- a/adapters/gothamads/gothamadstest/supplemental/invalid-gotham-ext-object.json +++ b/adapters/gothamads/gothamadstest/supplemental/invalid-gotham-ext-object.json @@ -1,7 +1,7 @@ { "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "value": "expect { or n, but found \"", "comparison": "literal" } ], diff --git a/adapters/grid/grid.go b/adapters/grid/grid.go index 3f521ba5e0a..b7d2cf6e2f2 100644 --- a/adapters/grid/grid.go +++ b/adapters/grid/grid.go @@ -13,6 +13,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" "github.com/prebid/prebid-server/v2/util/maputil" ) @@ -122,7 +123,7 @@ func buildConsolidatedKeywordsReqExt(openRTBUser, openRTBSite string, firstImpEx } func parseExtToMap(ext json.RawMessage) map[string]interface{} { var root map[string]interface{} - if err := json.Unmarshal(ext, &root); err != nil { + if err := jsonutil.Unmarshal(ext, &root); err != nil { return make(map[string]interface{}) } return root @@ -252,10 +253,10 @@ func processImp(imp *openrtb2.Imp) error { // get the grid extension var ext adapters.ExtImpBidder var gridExt openrtb_ext.ExtImpGrid - if err := json.Unmarshal(imp.Ext, &ext); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &ext); err != nil { return err } - if err := json.Unmarshal(ext.Bidder, &gridExt); err != nil { + if err := jsonutil.Unmarshal(ext.Bidder, &gridExt); err != nil { return err } @@ -271,7 +272,7 @@ func processImp(imp *openrtb2.Imp) error { func setImpExtData(imp openrtb2.Imp) openrtb2.Imp { var ext ExtImp - if err := json.Unmarshal(imp.Ext, &ext); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &ext); err != nil { return imp } if ext.Data != nil && ext.Data.AdServer != nil && ext.Data.AdServer.AdSlot != "" { @@ -288,7 +289,7 @@ func fixNative(req json.RawMessage) (json.RawMessage, error) { var gridReq map[string]interface{} var parsedRequest map[string]interface{} - if err := json.Unmarshal(req, &gridReq); err != nil { + if err := jsonutil.Unmarshal(req, &gridReq); err != nil { return req, nil } if imps, exists := maputil.ReadEmbeddedSlice(gridReq, "imp"); exists { @@ -299,7 +300,7 @@ func fixNative(req json.RawMessage) (json.RawMessage, error) { request, hasRequest := maputil.ReadEmbeddedString(native, "request") if hasRequest { delete(native, "request") - if err := json.Unmarshal([]byte(request), &parsedRequest); err == nil { + if err := jsonutil.Unmarshal([]byte(request), &parsedRequest); err == nil { native["request_native"] = parsedRequest } else { native["request_native"] = request @@ -387,7 +388,7 @@ func (a *GridAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalReq } var bidResp GridResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -437,7 +438,7 @@ func getBidMeta(ext json.RawMessage) (*openrtb_ext.ExtBidPrebidMeta, error) { } var bidExt GridBidExt - if err := json.Unmarshal(ext, &bidExt); err != nil { + if err := jsonutil.Unmarshal(ext, &bidExt); err != nil { return nil, err } var bidMeta *openrtb_ext.ExtBidPrebidMeta diff --git a/adapters/grid/gridtest/supplemental/bad_bidder_request.json b/adapters/grid/gridtest/supplemental/bad_bidder_request.json index 347a3091a41..450d2c3f099 100644 --- a/adapters/grid/gridtest/supplemental/bad_bidder_request.json +++ b/adapters/grid/gridtest/supplemental/bad_bidder_request.json @@ -20,7 +20,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb_ext.ExtImpGrid", + "value": "expect { or n, but found \"", "comparison": "literal" }, { diff --git a/adapters/grid/gridtest/supplemental/bad_ext_request.json b/adapters/grid/gridtest/supplemental/bad_ext_request.json index 789db8504f8..cebaad0a800 100644 --- a/adapters/grid/gridtest/supplemental/bad_ext_request.json +++ b/adapters/grid/gridtest/supplemental/bad_ext_request.json @@ -18,7 +18,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "value": "expect { or n, but found \"", "comparison": "literal" }, { diff --git a/adapters/grid/gridtest/supplemental/bad_response.json b/adapters/grid/gridtest/supplemental/bad_response.json index a4c32c017c4..fb9c10a417a 100644 --- a/adapters/grid/gridtest/supplemental/bad_response.json +++ b/adapters/grid/gridtest/supplemental/bad_response.json @@ -57,7 +57,7 @@ "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type grid.GridResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/gumgum/gumgum.go b/adapters/gumgum/gumgum.go index 4e44aacb82e..df903150da3 100644 --- a/adapters/gumgum/gumgum.go +++ b/adapters/gumgum/gumgum.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) // adapter implements Bidder interface. @@ -98,7 +99,7 @@ func (g *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest }} } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Bad server response: %d. ", err), }} @@ -127,7 +128,7 @@ func (g *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest func preprocess(imp *openrtb2.Imp) (*openrtb_ext.ExtImpGumGum, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { err = &errortypes.BadInput{ Message: err.Error(), } @@ -135,7 +136,7 @@ func preprocess(imp *openrtb2.Imp) (*openrtb_ext.ExtImpGumGum, error) { } var gumgumExt openrtb_ext.ExtImpGumGum - if err := json.Unmarshal(bidderExt.Bidder, &gumgumExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &gumgumExt); err != nil { err = &errortypes.BadInput{ Message: err.Error(), } diff --git a/adapters/huaweiads/huaweiads.go b/adapters/huaweiads/huaweiads.go index bc346096437..8415b97c6fb 100644 --- a/adapters/huaweiads/huaweiads.go +++ b/adapters/huaweiads/huaweiads.go @@ -24,6 +24,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" "github.com/prebid/prebid-server/v2/util/ptrutil" ) @@ -362,7 +363,7 @@ func (a *adapter) MakeBids(openRTBRequest *openrtb2.BidRequest, requestToBidder } var huaweiAdsResponse huaweiAdsResponse - if err := json.Unmarshal(bidderRawResponse.Body, &huaweiAdsResponse); err != nil { + if err := jsonutil.Unmarshal(bidderRawResponse.Body, &huaweiAdsResponse); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Unable to parse server response", }} @@ -400,7 +401,7 @@ func getExtraInfo(v string) (ExtraInfo, error) { return extraInfo, nil } - if err := json.Unmarshal([]byte(v), &extraInfo); err != nil { + if err := jsonutil.Unmarshal([]byte(v), &extraInfo); err != nil { return extraInfo, fmt.Errorf("invalid extra info: %v , pls check", err) } @@ -532,7 +533,7 @@ func getNativeFormat(adslot30 *adslot30, openRTBImp *openrtb2.Imp) error { } var nativePayload nativeRequests.Request - if err := json.Unmarshal(json.RawMessage(openRTBImp.Native.Request), &nativePayload); err != nil { + if err := jsonutil.Unmarshal(json.RawMessage(openRTBImp.Native.Request), &nativePayload); err != nil { return err } @@ -856,7 +857,7 @@ func getDeviceIDFromUserExt(device *device, openRTBRequest *openrtb2.BidRequest) } if userObjExist { var extUserDataHuaweiAds openrtb_ext.ExtUserDataHuaweiAds - if err := json.Unmarshal(openRTBRequest.User.Ext, &extUserDataHuaweiAds); err != nil { + if err := jsonutil.Unmarshal(openRTBRequest.User.Ext, &extUserDataHuaweiAds); err != nil { return errors.New("get gaid from openrtb Device.IFA failed, and get device id failed: Unmarshal openRTBRequest.User.Ext -> extUserDataHuaweiAds. Error: " + err.Error()) } @@ -954,7 +955,7 @@ func getReqGeoInfo(request *huaweiAdsRequest, openRTBRequest *openrtb2.BidReques func getReqConsentInfo(request *huaweiAdsRequest, openRTBRequest *openrtb2.BidRequest) { if openRTBRequest.User != nil && openRTBRequest.User.Ext != nil { var extUser openrtb_ext.ExtUser - if err := json.Unmarshal(openRTBRequest.User.Ext, &extUser); err != nil { + if err := jsonutil.Unmarshal(openRTBRequest.User.Ext, &extUser); err != nil { return } request.Consent = extUser.Consent @@ -964,10 +965,10 @@ func getReqConsentInfo(request *huaweiAdsRequest, openRTBRequest *openrtb2.BidRe func unmarshalExtImpHuaweiAds(openRTBImp *openrtb2.Imp) (*openrtb_ext.ExtImpHuaweiAds, error) { var bidderExt adapters.ExtImpBidder var huaweiAdsImpExt openrtb_ext.ExtImpHuaweiAds - if err := json.Unmarshal(openRTBImp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(openRTBImp.Ext, &bidderExt); err != nil { return nil, errors.New("Unmarshal: openRTBImp.Ext -> bidderExt failed") } - if err := json.Unmarshal(bidderExt.Bidder, &huaweiAdsImpExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &huaweiAdsImpExt); err != nil { return nil, errors.New("Unmarshal: bidderExt.Bidder -> huaweiAdsImpExt failed") } if huaweiAdsImpExt.SlotId == "" { @@ -1166,7 +1167,7 @@ func (a *adapter) extractAdmNative(adType int32, content *content, bidType openr } var nativePayload nativeRequests.Request - if err := json.Unmarshal(json.RawMessage(openrtb2Imp.Native.Request), &nativePayload); err != nil { + if err := jsonutil.Unmarshal(json.RawMessage(openrtb2Imp.Native.Request), &nativePayload); err != nil { return "", 0, 0, err } diff --git a/adapters/huaweiads/huaweiadstest/supplemental/missing_deviceid2.json b/adapters/huaweiads/huaweiadstest/supplemental/missing_deviceid2.json index 133282239cf..30028dee2ba 100644 --- a/adapters/huaweiads/huaweiadstest/supplemental/missing_deviceid2.json +++ b/adapters/huaweiads/huaweiadstest/supplemental/missing_deviceid2.json @@ -68,7 +68,7 @@ ], "expectedMakeRequestsErrors": [ { - "value": "get gaid from openrtb Device.IFA failed, and get device id failed: Unmarshal openRTBRequest.User.Ext -> extUserDataHuaweiAds. Error: json: cannot unmarshal object into Go struct field ExtUserDataDeviceIdHuaweiAds.data.gaid of type []string", + "value": "get gaid from openrtb Device.IFA failed, and get device id failed: Unmarshal openRTBRequest.User.Ext -> extUserDataHuaweiAds. Error: cannot unmarshal openrtb_ext.ExtUserDataDeviceIdHuaweiAds.Gaid: decode slice: expect [ or n, but found {", "comparison": "literal" } ] diff --git a/adapters/imds/imds.go b/adapters/imds/imds.go index 1fba38a0c6d..3d2a9c62922 100644 --- a/adapters/imds/imds.go +++ b/adapters/imds/imds.go @@ -13,6 +13,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) const adapterVersion string = "pbs-go/1.0.0" @@ -136,14 +137,14 @@ func (adapter *adapter) buildEndpointURL(params *openrtb_ext.ExtImpImds) (string func getExtImpObj(imp *openrtb2.Imp) (*openrtb_ext.ExtImpImds, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: err.Error(), } } var imdsExt openrtb_ext.ExtImpImds - if err := json.Unmarshal(bidderExt.Bidder, &imdsExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &imdsExt); err != nil { return nil, &errortypes.BadInput{ Message: err.Error(), } @@ -170,7 +171,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/imds/imdstest/supplemental/bad_response.json b/adapters/imds/imdstest/supplemental/bad_response.json index 9860bc7ac0d..ff7c089e53d 100644 --- a/adapters/imds/imdstest/supplemental/bad_response.json +++ b/adapters/imds/imdstest/supplemental/bad_response.json @@ -65,7 +65,7 @@ "expectedMakeBidsErrors": [ { "comparison": "literal", - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse" + "value": "expect { or n, but found \"" } ] } diff --git a/adapters/imds/imdstest/supplemental/bad_seat_id.json b/adapters/imds/imdstest/supplemental/bad_seat_id.json index 18630c592c4..5e4b879540d 100644 --- a/adapters/imds/imdstest/supplemental/bad_seat_id.json +++ b/adapters/imds/imdstest/supplemental/bad_seat_id.json @@ -24,7 +24,7 @@ "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal number into Go struct field ExtImpImds.seatId of type string", + "value": "cannot unmarshal openrtb_ext.ExtImpImds.SeatId: expects \" or n, but found 1", "comparison": "literal" } ] diff --git a/adapters/impactify/impactify.go b/adapters/impactify/impactify.go index 960a29d6c9b..81c3ff9a5bb 100644 --- a/adapters/impactify/impactify.go +++ b/adapters/impactify/impactify.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -47,7 +48,7 @@ func (a *adapter) MakeRequests(bidRequest *openrtb2.BidRequest, reqInfo *adapter var impactifyExt ImpactifyExtBidder var defaultExt DefaultExtBidder - err := json.Unmarshal(bidRequest.Imp[i].Ext, &defaultExt) + err := jsonutil.Unmarshal(bidRequest.Imp[i].Ext, &defaultExt) if err != nil { return nil, []error{&errortypes.BadInput{ Message: fmt.Sprintf("Unable to decode the imp ext : \"%s\"", bidRequest.Imp[i].ID), @@ -128,7 +129,7 @@ func (a *adapter) MakeBids( var openRtbBidResponse openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &openRtbBidResponse); err != nil { + if err := jsonutil.Unmarshal(response.Body, &openRtbBidResponse); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Bad server body response", }} diff --git a/adapters/improvedigital/improvedigital.go b/adapters/improvedigital/improvedigital.go index 08eef9a68f5..c260e368797 100644 --- a/adapters/improvedigital/improvedigital.go +++ b/adapters/improvedigital/improvedigital.go @@ -13,6 +13,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) const ( @@ -109,7 +110,7 @@ func (a *ImprovedigitalAdapter) MakeBids(internalRequest *openrtb2.BidRequest, e var bidResp openrtb2.BidResponse var impMap = make(map[string]openrtb2.Imp) - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -145,7 +146,7 @@ func (a *ImprovedigitalAdapter) MakeBids(internalRequest *openrtb2.BidRequest, e if bid.Ext != nil { var bidExt BidExt - err = json.Unmarshal(bid.Ext, &bidExt) + err = jsonutil.Unmarshal(bid.Ext, &bidExt) if err != nil { return nil, []error{err} } @@ -243,7 +244,7 @@ func isMultiFormatImp(imp openrtb2.Imp) bool { func getImpExtWithRewardedInventory(imp openrtb2.Imp) ([]byte, error) { var ext = make(map[string]json.RawMessage) - if err := json.Unmarshal(imp.Ext, &ext); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &ext); err != nil { return nil, err } @@ -253,7 +254,7 @@ func getImpExtWithRewardedInventory(imp openrtb2.Imp) ([]byte, error) { } var prebidMap = make(map[string]json.RawMessage) - if err := json.Unmarshal(prebidJSONValue, &prebidMap); err != nil { + if err := jsonutil.Unmarshal(prebidJSONValue, &prebidMap); err != nil { return nil, err } @@ -274,7 +275,7 @@ func (a *ImprovedigitalAdapter) buildEndpointURL(imp openrtb2.Imp) string { publisherEndpoint := "" var impBidder ImpExtBidder - err := json.Unmarshal(imp.Ext, &impBidder) + err := jsonutil.Unmarshal(imp.Ext, &impBidder) if err == nil && impBidder.Bidder.PublisherID != 0 { publisherEndpoint = strconv.Itoa(impBidder.Bidder.PublisherID) + "/" } diff --git a/adapters/improvedigital/improvedigitaltest/supplemental/bad_response.json b/adapters/improvedigital/improvedigitaltest/supplemental/bad_response.json index 5edafaaca68..6518f3c0938 100644 --- a/adapters/improvedigital/improvedigitaltest/supplemental/bad_response.json +++ b/adapters/improvedigital/improvedigitaltest/supplemental/bad_response.json @@ -57,7 +57,7 @@ "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/infytv/infytv.go b/adapters/infytv/infytv.go index a5d325e329f..a1c9031b65c 100644 --- a/adapters/infytv/infytv.go +++ b/adapters/infytv/infytv.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -64,7 +65,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Bad response, %s", err), }} diff --git a/adapters/infytv/infytvtest/supplemental/bad-response.json b/adapters/infytv/infytvtest/supplemental/bad-response.json index 01d560cf5e7..05134ef403f 100644 --- a/adapters/infytv/infytvtest/supplemental/bad-response.json +++ b/adapters/infytv/infytvtest/supplemental/bad-response.json @@ -195,7 +195,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "Bad response, json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "Bad response, expect { or n, but found \"", "comparison": "literal" } ], diff --git a/adapters/inmobi/inmobi.go b/adapters/inmobi/inmobi.go index eb69bdf3ec2..53f32697e0a 100644 --- a/adapters/inmobi/inmobi.go +++ b/adapters/inmobi/inmobi.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type InMobiAdapter struct { @@ -69,7 +70,7 @@ func (a *InMobiAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalR } var serverBidResponse openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &serverBidResponse); err != nil { + if err := jsonutil.Unmarshal(response.Body, &serverBidResponse); err != nil { return nil, []error{err} } @@ -93,14 +94,14 @@ func (a *InMobiAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalR func preprocess(imp *openrtb2.Imp) error { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return &errortypes.BadInput{ Message: err.Error(), } } var inMobiExt openrtb_ext.ExtImpInMobi - if err := json.Unmarshal(bidderExt.Bidder, &inMobiExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &inMobiExt); err != nil { return &errortypes.BadInput{Message: "bad InMobi bidder ext"} } diff --git a/adapters/interactiveoffers/interactiveoffers.go b/adapters/interactiveoffers/interactiveoffers.go index 53286aa9cc7..8fc649d10fc 100644 --- a/adapters/interactiveoffers/interactiveoffers.go +++ b/adapters/interactiveoffers/interactiveoffers.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -21,14 +22,14 @@ type adapter struct { func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errors []error var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(request.Imp[0].Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(request.Imp[0].Ext, &bidderExt); err != nil { errors = append(errors, &errortypes.BadInput{ Message: err.Error(), }) return nil, errors } var ioExt *openrtb_ext.ExtImpInteractiveoffers - if err := json.Unmarshal(bidderExt.Bidder, &ioExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &ioExt); err != nil { errors = append(errors, &errortypes.BadInput{ Message: err.Error(), }) @@ -76,7 +77,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/interactiveoffers/interactiveofferstest/supplemental/wrongjsonresponse.json b/adapters/interactiveoffers/interactiveofferstest/supplemental/wrongjsonresponse.json index 3f087a0d79c..750c0a4bb68 100644 --- a/adapters/interactiveoffers/interactiveofferstest/supplemental/wrongjsonresponse.json +++ b/adapters/interactiveoffers/interactiveofferstest/supplemental/wrongjsonresponse.json @@ -54,7 +54,7 @@ "expectedBidResponses": [], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/invibes/invibes.go b/adapters/invibes/invibes.go index ecb3ebae4e8..1d48891a9c1 100644 --- a/adapters/invibes/invibes.go +++ b/adapters/invibes/invibes.go @@ -16,6 +16,7 @@ import ( "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/metrics" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) const adapterVersion = "prebid_1.0.0" @@ -100,14 +101,14 @@ func (a *InvibesAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada for _, imp := range request.Imp { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { tempErrors = append(tempErrors, &errortypes.BadInput{ Message: "Error parsing bidderExt object", }) continue } var invibesExt openrtb_ext.ExtImpInvibes - if err := json.Unmarshal(bidderExt.Bidder, &invibesExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &invibesExt); err != nil { tempErrors = append(tempErrors, &errortypes.BadInput{ Message: "Error parsing invibesExt parameters", }) @@ -159,14 +160,14 @@ func readGDPR(request *openrtb2.BidRequest) (bool, string) { consentString := "" if request.User != nil { var extUser openrtb_ext.ExtUser - if err := json.Unmarshal(request.User.Ext, &extUser); err == nil { + if err := jsonutil.Unmarshal(request.User.Ext, &extUser); err == nil { consentString = extUser.Consent } } gdprApplies := true var extRegs openrtb_ext.ExtRegs if request.Regs != nil { - if err := json.Unmarshal(request.Regs.Ext, &extRegs); err == nil { + if err := jsonutil.Unmarshal(request.Regs.Ext, &extRegs); err == nil { if extRegs.GDPR != nil { gdprApplies = (*extRegs.GDPR == 1) } @@ -315,7 +316,7 @@ func (a *InvibesAdapter) MakeBids( } bidResponse := BidServerBidderResponse{} - if err := json.Unmarshal(response.Body, &bidResponse); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResponse); err != nil { return nil, []error{err} } diff --git a/adapters/iqx/iqx.go b/adapters/iqx/iqx.go index 23da6bc8947..cdc33b06906 100644 --- a/adapters/iqx/iqx.go +++ b/adapters/iqx/iqx.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type bidType struct { @@ -41,14 +42,14 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co func (a *adapter) buildEndpointFromRequest(imp *openrtb2.Imp) (string, error) { var impExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &impExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &impExt); err != nil { return "", &errortypes.BadInput{ Message: fmt.Sprintf("Failed to deserialize bidder impression extension: %v", err), } } var iqzonexExt openrtb_ext.ExtIQX - if err := json.Unmarshal(impExt.Bidder, &iqzonexExt); err != nil { + if err := jsonutil.Unmarshal(impExt.Bidder, &iqzonexExt); err != nil { return "", &errortypes.BadInput{ Message: fmt.Sprintf("Failed to deserialize IQZonex extension: %v", err), } @@ -116,7 +117,7 @@ func (a *adapter) MakeBids(openRTBRequest *openrtb2.BidRequest, requestToBidder } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(bidderRawResponse.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(bidderRawResponse.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/iqx/iqzonextest/supplemental/bad-response.json b/adapters/iqx/iqzonextest/supplemental/bad-response.json index a5cc1f2aeae..a0f8dc8c960 100644 --- a/adapters/iqx/iqzonextest/supplemental/bad-response.json +++ b/adapters/iqx/iqzonextest/supplemental/bad-response.json @@ -99,7 +99,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ], diff --git a/adapters/iqx/iqzonextest/supplemental/invalid-ext-bidder-object.json b/adapters/iqx/iqzonextest/supplemental/invalid-ext-bidder-object.json index 2f124a8cf3b..22612977a87 100644 --- a/adapters/iqx/iqzonextest/supplemental/invalid-ext-bidder-object.json +++ b/adapters/iqx/iqzonextest/supplemental/invalid-ext-bidder-object.json @@ -42,7 +42,7 @@ "httpCalls": [], "expectedMakeRequestsErrors": [ { - "value": "Failed to deserialize IQZonex extension: json: cannot unmarshal array into Go value of type openrtb_ext.ExtIQX", + "value": "Failed to deserialize IQZonex extension: expect { or n, but found [", "comparison": "literal" } ] diff --git a/adapters/iqx/iqzonextest/supplemental/invalid-ext-object.json b/adapters/iqx/iqzonextest/supplemental/invalid-ext-object.json index aa215eb3e34..16cf58bbe54 100644 --- a/adapters/iqx/iqzonextest/supplemental/invalid-ext-object.json +++ b/adapters/iqx/iqzonextest/supplemental/invalid-ext-object.json @@ -40,7 +40,7 @@ "httpCalls": [], "expectedMakeRequestsErrors": [ { - "value": "Failed to deserialize bidder impression extension: json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "value": "Failed to deserialize bidder impression extension: expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/iqzone/iqzone.go b/adapters/iqzone/iqzone.go index db570707ba8..f8d170d2684 100644 --- a/adapters/iqzone/iqzone.go +++ b/adapters/iqzone/iqzone.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -35,10 +36,10 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E var bidderExt adapters.ExtImpBidder var iqzoneExt openrtb_ext.ImpExtIQZone - if err = json.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { + if err = jsonutil.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { return nil, append(errs, err) } - if err = json.Unmarshal(bidderExt.Bidder, &iqzoneExt); err != nil { + if err = jsonutil.Unmarshal(bidderExt.Bidder, &iqzoneExt); err != nil { return nil, append(errs, err) } @@ -104,7 +105,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/iqzone/iqzonetest/supplemental/bad_response.json b/adapters/iqzone/iqzonetest/supplemental/bad_response.json index 6bae2a728a7..03d00712772 100644 --- a/adapters/iqzone/iqzonetest/supplemental/bad_response.json +++ b/adapters/iqzone/iqzonetest/supplemental/bad_response.json @@ -78,7 +78,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/ix/ix.go b/adapters/ix/ix.go index 86f71f58c76..58d4797c5ca 100644 --- a/adapters/ix/ix.go +++ b/adapters/ix/ix.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" "github.com/prebid/prebid-server/v2/util/ptrutil" "github.com/prebid/prebid-server/v2/version" @@ -155,12 +156,12 @@ func setPublisherId(requestCopy *openrtb2.BidRequest, uniqueSiteIDs map[string]s func unmarshalToIxExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpIx, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, err } var ixExt openrtb_ext.ExtImpIx - if err := json.Unmarshal(bidderExt.Bidder, &ixExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &ixExt); err != nil { return nil, err } @@ -203,7 +204,7 @@ func (a *IxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalReque } var bidResponse openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResponse); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResponse); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("JSON parsing error: %v", err), }} @@ -243,7 +244,7 @@ func (a *IxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalReque var bidExtVideo *openrtb_ext.ExtBidPrebidVideo var bidExt openrtb_ext.ExtBid if bidType == openrtb_ext.BidTypeVideo { - unmarshalExtErr := json.Unmarshal(bid.Ext, &bidExt) + unmarshalExtErr := jsonutil.Unmarshal(bid.Ext, &bidExt) if unmarshalExtErr == nil && bidExt.Prebid != nil && bidExt.Prebid.Video != nil { bidExtVideo = &openrtb_ext.ExtBidPrebidVideo{ Duration: bidExt.Prebid.Video.Duration, @@ -256,7 +257,7 @@ func (a *IxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalReque var bidNative1v1 *Native11Wrapper if bidType == openrtb_ext.BidTypeNative { - err := json.Unmarshal([]byte(bid.AdM), &bidNative1v1) + err := jsonutil.Unmarshal([]byte(bid.AdM), &bidNative1v1) if err == nil && len(bidNative1v1.Native.EventTrackers) > 0 { mergeNativeImpTrackers(&bidNative1v1.Native) if json, err := marshalJsonWithoutUnicode(bidNative1v1); err == nil { @@ -267,7 +268,7 @@ func (a *IxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalReque var bidNative1v2 *native1response.Response if bidType == openrtb_ext.BidTypeNative { - err := json.Unmarshal([]byte(bid.AdM), &bidNative1v2) + err := jsonutil.Unmarshal([]byte(bid.AdM), &bidNative1v2) if err == nil && len(bidNative1v2.EventTrackers) > 0 { mergeNativeImpTrackers(bidNative1v2) if json, err := marshalJsonWithoutUnicode(bidNative1v2); err == nil { @@ -286,7 +287,7 @@ func (a *IxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalReque if bidResponse.Ext != nil { var bidRespExt ixRespExt - if err := json.Unmarshal(bidResponse.Ext, &bidRespExt); err != nil { + if err := jsonutil.Unmarshal(bidResponse.Ext, &bidRespExt); err != nil { return nil, append(errs, err) } @@ -321,7 +322,7 @@ func getMediaTypeForBid(bid openrtb2.Bid, impMediaTypeReq map[string]openrtb_ext if bid.Ext != nil { var bidExt openrtb_ext.ExtBid - err := json.Unmarshal(bid.Ext, &bidExt) + err := jsonutil.Unmarshal(bid.Ext, &bidExt) if err == nil && bidExt.Prebid != nil { prebidType := string(bidExt.Prebid.Type) if prebidType != "" { @@ -405,7 +406,7 @@ func extractVersionWithoutCommitHash(ver string) string { func setIxDiagIntoExtRequest(request *openrtb2.BidRequest, ixDiag *IxDiag, ver string) error { extRequest := &ExtRequest{} if request.Ext != nil { - if err := json.Unmarshal(request.Ext, &extRequest); err != nil { + if err := jsonutil.Unmarshal(request.Ext, &extRequest); err != nil { return err } } @@ -422,7 +423,7 @@ func setIxDiagIntoExtRequest(request *openrtb2.BidRequest, ixDiag *IxDiag, ver s if *ixDiag != (IxDiag{}) { extRequest := &ExtRequest{} if request.Ext != nil { - if err := json.Unmarshal(request.Ext, &extRequest); err != nil { + if err := jsonutil.Unmarshal(request.Ext, &extRequest); err != nil { return err } } @@ -444,7 +445,7 @@ func moveSid(imp *openrtb2.Imp, ixExt *openrtb_ext.ExtImpIx) error { if ixExt.Sid != "" { var m map[string]interface{} - if err := json.Unmarshal(imp.Ext, &m); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &m); err != nil { return err } m["sid"] = ixExt.Sid diff --git a/adapters/ix/ixtest/supplemental/bad-ext-bidder.json b/adapters/ix/ixtest/supplemental/bad-ext-bidder.json index e08da1e1a84..87378ca3ce1 100644 --- a/adapters/ix/ixtest/supplemental/bad-ext-bidder.json +++ b/adapters/ix/ixtest/supplemental/bad-ext-bidder.json @@ -15,7 +15,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal number into Go struct field ExtImpBidder.prebid of type openrtb_ext.ExtImpPrebid", + "value": "cannot unmarshal adapters.ExtImpBidder.Prebid: expect { or n, but found 1", "comparison": "literal" } ] diff --git a/adapters/ix/ixtest/supplemental/bad-ext-ix.json b/adapters/ix/ixtest/supplemental/bad-ext-ix.json index a9a0383b1a1..a9d533b9172 100644 --- a/adapters/ix/ixtest/supplemental/bad-ext-ix.json +++ b/adapters/ix/ixtest/supplemental/bad-ext-ix.json @@ -14,8 +14,8 @@ }, "expectedMakeRequestsErrors": [ { - "value": "unexpected end of JSON input", - "comparison": "literal" + "value": "expect { or n, but found", + "comparison": "startswith" } ] } diff --git a/adapters/ix/ixtest/supplemental/bad-fledge.json b/adapters/ix/ixtest/supplemental/bad-fledge.json index 42459148e0a..d835d40a33f 100644 --- a/adapters/ix/ixtest/supplemental/bad-fledge.json +++ b/adapters/ix/ixtest/supplemental/bad-fledge.json @@ -128,7 +128,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal number into Go struct field auctionConfig.protectedAudienceAuctionConfigs.bidId of type string", + "value": "cannot unmarshal ix.auctionConfig.BidId: expects \" or n, but found 1", "comparison": "literal" } ] diff --git a/adapters/ix/ixtest/supplemental/bad-response-body.json b/adapters/ix/ixtest/supplemental/bad-response-body.json index eae3fbdb36b..e416123023f 100644 --- a/adapters/ix/ixtest/supplemental/bad-response-body.json +++ b/adapters/ix/ixtest/supplemental/bad-response-body.json @@ -59,7 +59,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "JSON parsing error: json: cannot unmarshal number into Go struct field BidResponse.id of type string", + "value": "JSON parsing error: cannot unmarshal openrtb2.BidResponse.ID: expects \" or n, but found 1", "comparison": "literal" } ] diff --git a/adapters/ix/ixtest/supplemental/multi-imp-requests-error.json b/adapters/ix/ixtest/supplemental/multi-imp-requests-error.json index 7b43ca7961c..6613dce7169 100644 --- a/adapters/ix/ixtest/supplemental/multi-imp-requests-error.json +++ b/adapters/ix/ixtest/supplemental/multi-imp-requests-error.json @@ -183,7 +183,7 @@ ], "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal number into Go struct field ExtImpIx.sid of type string", + "value": "cannot unmarshal openrtb_ext.ExtImpIx.Sid: expects \" or n, but found 1", "comparison": "literal" } ] diff --git a/adapters/jixie/jixie.go b/adapters/jixie/jixie.go index 7079e403880..a1197491c70 100644 --- a/adapters/jixie/jixie.go +++ b/adapters/jixie/jixie.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -102,7 +103,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Unable to unpackage bid response. Error: %s", err.Error()), }} diff --git a/adapters/kargo/kargo.go b/adapters/kargo/kargo.go index e6a06dea179..89f1b59cbcf 100644 --- a/adapters/kargo/kargo.go +++ b/adapters/kargo/kargo.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -59,7 +60,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } @@ -79,7 +80,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R func getMediaTypeForBid(ext json.RawMessage) openrtb_ext.BidType { var impExt kargoExt - if err := json.Unmarshal(ext, &impExt); err == nil { + if err := jsonutil.Unmarshal(ext, &impExt); err == nil { switch impExt.MediaType { case string(openrtb_ext.BidTypeVideo): return openrtb_ext.BidTypeVideo diff --git a/adapters/kayzen/kayzen.go b/adapters/kayzen/kayzen.go index f3b8153f97f..932e47d9af7 100644 --- a/adapters/kayzen/kayzen.go +++ b/adapters/kayzen/kayzen.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -76,13 +77,13 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E func (a *adapter) getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtKayzen, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: "Bidder extension not provided or can't be unmarshalled", } } var kayzenExt openrtb_ext.ExtKayzen - if err := json.Unmarshal(bidderExt.Bidder, &kayzenExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &kayzenExt); err != nil { return nil, &errortypes.BadInput{ Message: "Error while unmarshaling bidder extension", } @@ -118,7 +119,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Bad Server Response", }} diff --git a/adapters/kidoz/kidoz.go b/adapters/kidoz/kidoz.go index b0406b29e00..c642fb1887c 100644 --- a/adapters/kidoz/kidoz.go +++ b/adapters/kidoz/kidoz.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type KidozAdapter struct { @@ -56,7 +57,7 @@ func (a *KidozAdapter) MakeRequests(request *openrtb2.BidRequest, _ *adapters.Ex continue } var bidderExt adapters.ExtImpBidder - err := json.Unmarshal(impression.Ext, &bidderExt) + err := jsonutil.Unmarshal(impression.Ext, &bidderExt) if err != nil { errs = append(errs, err) continue @@ -66,7 +67,7 @@ func (a *KidozAdapter) MakeRequests(request *openrtb2.BidRequest, _ *adapters.Ex continue } var impressionExt openrtb_ext.ExtImpKidoz - err = json.Unmarshal(bidderExt.Bidder, &impressionExt) + err = jsonutil.Unmarshal(bidderExt.Bidder, &impressionExt) if err != nil { errs = append(errs, err) continue @@ -131,7 +132,7 @@ func (a *KidozAdapter) MakeBids(request *openrtb2.BidRequest, _ *adapters.Reques } var bidResponse openrtb2.BidResponse - err := json.Unmarshal(responseData.Body, &bidResponse) + err := jsonutil.Unmarshal(responseData.Body, &bidResponse) if err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: err.Error(), diff --git a/adapters/kidoz/kidoz_test.go b/adapters/kidoz/kidoz_test.go index 9a36764ee97..9e9c071e9d4 100644 --- a/adapters/kidoz/kidoz_test.go +++ b/adapters/kidoz/kidoz_test.go @@ -83,7 +83,7 @@ func TestMakeBids(t *testing.T) { resp, errs := bidder.MakeBids(request, requestData, responseData) // cant assert message its different on different versions of go assert.Equal(t, 1, len(errs)) - assert.Contains(t, errs[0].Error(), "JSON") + assert.Contains(t, errs[0].Error(), "expect { or n, but found") assert.Nil(t, resp) }) } diff --git a/adapters/kidoz/kidoztest/supplemental/bidder-marshal.json b/adapters/kidoz/kidoztest/supplemental/bidder-marshal.json index 8a8a5e76844..94d189db370 100644 --- a/adapters/kidoz/kidoztest/supplemental/bidder-marshal.json +++ b/adapters/kidoz/kidoztest/supplemental/bidder-marshal.json @@ -22,7 +22,7 @@ "expectedBidResponses": [], "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb_ext.ExtImpKidoz", + "value": "expect { or n, but found \"", "comparison": "literal" } ], diff --git a/adapters/kidoz/kidoztest/supplemental/ext-marshal.json b/adapters/kidoz/kidoztest/supplemental/ext-marshal.json index eaab459461a..4aefbdac2e8 100644 --- a/adapters/kidoz/kidoztest/supplemental/ext-marshal.json +++ b/adapters/kidoz/kidoztest/supplemental/ext-marshal.json @@ -20,7 +20,7 @@ "expectedBidResponses": [], "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "value": "expect { or n, but found \"", "comparison": "literal" } ], diff --git a/adapters/kiviads/kiviads.go b/adapters/kiviads/kiviads.go index a102234e860..360d2b11e39 100644 --- a/adapters/kiviads/kiviads.go +++ b/adapters/kiviads/kiviads.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -44,10 +45,10 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E var bidderExt adapters.ExtImpBidder var kiviadsExt openrtb_ext.ImpExtKiviads - if err = json.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { + if err = jsonutil.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { return nil, []error{err} } - if err = json.Unmarshal(bidderExt.Bidder, &kiviadsExt); err != nil { + if err = jsonutil.Unmarshal(bidderExt.Bidder, &kiviadsExt); err != nil { return nil, []error{err} } @@ -111,7 +112,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/kiviads/kiviadstest/supplemental/bad_response.json b/adapters/kiviads/kiviadstest/supplemental/bad_response.json index d1dbf00134e..3f7eb4945a5 100644 --- a/adapters/kiviads/kiviadstest/supplemental/bad_response.json +++ b/adapters/kiviads/kiviadstest/supplemental/bad_response.json @@ -78,7 +78,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/krushmedia/krushmedia.go b/adapters/krushmedia/krushmedia.go index aa87033052f..bde67554195 100644 --- a/adapters/krushmedia/krushmedia.go +++ b/adapters/krushmedia/krushmedia.go @@ -13,6 +13,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type KrushmediaAdapter struct { @@ -110,13 +111,13 @@ func (a *KrushmediaAdapter) MakeRequests( func (a *KrushmediaAdapter) getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtKrushmedia, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: "Bidder extension not provided or can't be unmarshalled", } } var krushmediaExt openrtb_ext.ExtKrushmedia - if err := json.Unmarshal(bidderExt.Bidder, &krushmediaExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &krushmediaExt); err != nil { return nil, &errortypes.BadInput{ Message: "Error while unmarshaling bidder extension", } @@ -159,7 +160,7 @@ func (a *KrushmediaAdapter) MakeBids( responseBody := bidderRawResponse.Body var bidResp openrtb2.BidResponse - if err := json.Unmarshal(responseBody, &bidResp); err != nil { + if err := jsonutil.Unmarshal(responseBody, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Bad Server Response", }} diff --git a/adapters/lemmadigital/lemmadigital.go b/adapters/lemmadigital/lemmadigital.go index 281cd2e1f0f..1ccb136c4d0 100644 --- a/adapters/lemmadigital/lemmadigital.go +++ b/adapters/lemmadigital/lemmadigital.go @@ -13,6 +13,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -38,14 +39,14 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte } var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(request.Imp[0].Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(request.Imp[0].Ext, &bidderExt); err != nil { return nil, []error{&errortypes.BadInput{ Message: fmt.Sprintf("Invalid imp.ext for impression index %d. Error Infomation: %s", 0, err.Error()), }} } var impExt openrtb_ext.ImpExtLemmaDigital - if err := json.Unmarshal(bidderExt.Bidder, &impExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &impExt); err != nil { return nil, []error{&errortypes.BadInput{ Message: fmt.Sprintf("Invalid imp.ext.bidder for impression index %d. Error Infomation: %s", 0, err.Error()), }} @@ -81,7 +82,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/lemmadigital/lemmadigitaltest/supplemental/invalid-ld-ext-bidder-object.json b/adapters/lemmadigital/lemmadigitaltest/supplemental/invalid-ld-ext-bidder-object.json index ba46d76b598..8b078eddd6e 100644 --- a/adapters/lemmadigital/lemmadigitaltest/supplemental/invalid-ld-ext-bidder-object.json +++ b/adapters/lemmadigital/lemmadigitaltest/supplemental/invalid-ld-ext-bidder-object.json @@ -1,7 +1,7 @@ { "expectedMakeRequestsErrors": [{ - "value": "Invalid imp.ext.bidder for impression index 0. Error Infomation: json: cannot unmarshal string into Go struct field ImpExtLemmaDigital.pid of type int", - "comparison": "literal" + "value": "Invalid imp.ext.bidder for impression index 0. Error Infomation: cannot unmarshal openrtb_ext.ImpExtLemmaDigital.PublisherId: unexpected character", + "comparison": "startswith" }], "mockBidRequest": { "app": { diff --git a/adapters/lemmadigital/lemmadigitaltest/supplemental/invalid-ld-ext-object.json b/adapters/lemmadigital/lemmadigitaltest/supplemental/invalid-ld-ext-object.json index 4d3d795c185..690cf1e6b10 100644 --- a/adapters/lemmadigital/lemmadigitaltest/supplemental/invalid-ld-ext-object.json +++ b/adapters/lemmadigital/lemmadigitaltest/supplemental/invalid-ld-ext-object.json @@ -1,7 +1,7 @@ { "expectedMakeRequestsErrors": [{ - "value": "Invalid imp.ext for impression index 0. Error Infomation: unexpected end of JSON input", - "comparison": "literal" + "value": "Invalid imp.ext for impression index 0. Error Infomation: expect { or n, but found", + "comparison": "startswith" }], "mockBidRequest": { "app": { diff --git a/adapters/lemmadigital/lemmadigitaltest/supplemental/invalid-response.json b/adapters/lemmadigital/lemmadigitaltest/supplemental/invalid-response.json index 7b703721881..74e418c92c3 100644 --- a/adapters/lemmadigital/lemmadigitaltest/supplemental/invalid-response.json +++ b/adapters/lemmadigital/lemmadigitaltest/supplemental/invalid-response.json @@ -57,7 +57,7 @@ } }], "expectedMakeBidsErrors": [{ - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" }] } \ No newline at end of file diff --git a/adapters/limelightDigital/limelightDigital.go b/adapters/limelightDigital/limelightDigital.go index b4c327e8475..d94f50aff51 100644 --- a/adapters/limelightDigital/limelightDigital.go +++ b/adapters/limelightDigital/limelightDigital.go @@ -15,6 +15,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -115,7 +116,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } @@ -141,13 +142,13 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R func getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ImpExtLimelightDigital, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: "ext.bidder is not provided", } } var limelightDigitalExt openrtb_ext.ImpExtLimelightDigital - if err := json.Unmarshal(bidderExt.Bidder, &limelightDigitalExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &limelightDigitalExt); err != nil { return nil, &errortypes.BadInput{ Message: "ext.bidder is not provided", } diff --git a/adapters/lm_kiviads/lmkiviads.go b/adapters/lm_kiviads/lmkiviads.go index e5f9723c34d..604b0a68d9b 100644 --- a/adapters/lm_kiviads/lmkiviads.go +++ b/adapters/lm_kiviads/lmkiviads.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type bidType struct { @@ -41,14 +42,14 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co func (a *adapter) buildEndpointFromRequest(imp *openrtb2.Imp) (string, error) { var impExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &impExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &impExt); err != nil { return "", &errortypes.BadInput{ Message: fmt.Sprintf("Failed to deserialize bidder impression extension: %v", err), } } var kiviExt openrtb_ext.ExtLmKiviads - if err := json.Unmarshal(impExt.Bidder, &kiviExt); err != nil { + if err := jsonutil.Unmarshal(impExt.Bidder, &kiviExt); err != nil { return "", &errortypes.BadInput{ Message: fmt.Sprintf("Failed to deserialize LmKiviads extension: %v", err), } @@ -116,7 +117,7 @@ func (a *adapter) MakeBids(openRTBRequest *openrtb2.BidRequest, requestToBidder } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(bidderRawResponse.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(bidderRawResponse.Body, &bidResp); err != nil { return nil, []error{err} } @@ -136,7 +137,7 @@ func prepareBidResponse(seats []openrtb2.SeatBid) (*adapters.BidderResponse, []e for _, seatBid := range seats { for bidId, bid := range seatBid.Bid { var bidExt bidExt - if err := json.Unmarshal(bid.Ext, &bidExt); err != nil { + if err := jsonutil.Unmarshal(bid.Ext, &bidExt); err != nil { errs = append(errs, &errortypes.BadServerResponse{ Message: fmt.Sprintf("Failed to parse Bid[%d].Ext: %s", bidId, err.Error()), }) diff --git a/adapters/lm_kiviads/lmkiviadstest/supplemental/bad-response.json b/adapters/lm_kiviads/lmkiviadstest/supplemental/bad-response.json index 87f917e58ab..b913e93293a 100644 --- a/adapters/lm_kiviads/lmkiviadstest/supplemental/bad-response.json +++ b/adapters/lm_kiviads/lmkiviadstest/supplemental/bad-response.json @@ -99,7 +99,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ], diff --git a/adapters/lm_kiviads/lmkiviadstest/supplemental/invalid-ext-bidder-object.json b/adapters/lm_kiviads/lmkiviadstest/supplemental/invalid-ext-bidder-object.json index 87ade656d2d..ec20948c77c 100644 --- a/adapters/lm_kiviads/lmkiviadstest/supplemental/invalid-ext-bidder-object.json +++ b/adapters/lm_kiviads/lmkiviadstest/supplemental/invalid-ext-bidder-object.json @@ -42,7 +42,7 @@ "httpCalls": [], "expectedMakeRequestsErrors": [ { - "value": "Failed to deserialize LmKiviads extension: json: cannot unmarshal array into Go value of type openrtb_ext.ExtLmKiviads", + "value": "Failed to deserialize LmKiviads extension: expect { or n, but found [", "comparison": "literal" } ] diff --git a/adapters/lm_kiviads/lmkiviadstest/supplemental/invalid-ext-object.json b/adapters/lm_kiviads/lmkiviadstest/supplemental/invalid-ext-object.json index aa215eb3e34..16cf58bbe54 100644 --- a/adapters/lm_kiviads/lmkiviadstest/supplemental/invalid-ext-object.json +++ b/adapters/lm_kiviads/lmkiviadstest/supplemental/invalid-ext-object.json @@ -40,7 +40,7 @@ "httpCalls": [], "expectedMakeRequestsErrors": [ { - "value": "Failed to deserialize bidder impression extension: json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "value": "Failed to deserialize bidder impression extension: expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/lockerdome/lockerdome.go b/adapters/lockerdome/lockerdome.go index 3e483fad646..57a0c125946 100644 --- a/adapters/lockerdome/lockerdome.go +++ b/adapters/lockerdome/lockerdome.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) const unexpectedStatusCodeMessage = "Unexpected status code: %d. Run with request.debug = 1 for more info" @@ -43,7 +44,7 @@ func (adapter *LockerDomeAdapter) MakeRequests(openRTBRequest *openrtb2.BidReque continue } var bidderExt adapters.ExtImpBidder - err := json.Unmarshal(openRTBRequest.Imp[i].Ext, &bidderExt) + err := jsonutil.Unmarshal(openRTBRequest.Imp[i].Ext, &bidderExt) if err != nil { // lockerdometest/supplemental/no_ext.json err = &errortypes.BadInput{ Message: "ext was not provided.", @@ -52,7 +53,7 @@ func (adapter *LockerDomeAdapter) MakeRequests(openRTBRequest *openrtb2.BidReque continue } var lockerdomeExt openrtb_ext.ExtImpLockerDome - err = json.Unmarshal(bidderExt.Bidder, &lockerdomeExt) + err = jsonutil.Unmarshal(bidderExt.Bidder, &lockerdomeExt) if err != nil { // lockerdometest/supplemental/no_adUnitId_param.json err = &errortypes.BadInput{ Message: "ext.bidder.adUnitId was not provided.", @@ -129,7 +130,7 @@ func (adapter *LockerDomeAdapter) MakeBids(openRTBRequest *openrtb2.BidRequest, } var openRTBBidderResponse openrtb2.BidResponse - if err := json.Unmarshal(bidderRawResponse.Body, &openRTBBidderResponse); err != nil { + if err := jsonutil.Unmarshal(bidderRawResponse.Body, &openRTBBidderResponse); err != nil { return nil, []error{ fmt.Errorf("Error unmarshaling LockerDome bid response - %s", err.Error()), } diff --git a/adapters/lockerdome/lockerdometest/supplemental/bad_response.json b/adapters/lockerdome/lockerdometest/supplemental/bad_response.json index c3b0045e275..b90eb3f1e0e 100644 --- a/adapters/lockerdome/lockerdometest/supplemental/bad_response.json +++ b/adapters/lockerdome/lockerdometest/supplemental/bad_response.json @@ -57,7 +57,7 @@ "expectedMakeBidsErrors": [ { - "value": "Error unmarshaling LockerDome bid response - json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "Error unmarshaling LockerDome bid response - expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/logan/logan.go b/adapters/logan/logan.go index 73e602f5632..f8d1432b66c 100644 --- a/adapters/logan/logan.go +++ b/adapters/logan/logan.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -43,7 +44,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E request.Imp = []openrtb2.Imp{currImp} var bidderExt reqBodyExt - if err := json.Unmarshal(currImp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(currImp.Ext, &bidderExt); err != nil { errors = append(errors, &errortypes.BadInput{ Message: err.Error(), }) @@ -103,7 +104,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/logan/logantest/supplemental/bad_response.json b/adapters/logan/logantest/supplemental/bad_response.json index d71deaddfb8..1653abee0a8 100644 --- a/adapters/logan/logantest/supplemental/bad_response.json +++ b/adapters/logan/logantest/supplemental/bad_response.json @@ -78,7 +78,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/logicad/logicad.go b/adapters/logicad/logicad.go index 5ce3d0ac7e1..e575fa3cf53 100644 --- a/adapters/logicad/logicad.go +++ b/adapters/logicad/logicad.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type LogicadAdapter struct { @@ -74,12 +75,12 @@ func getImpressionExt(imp *openrtb2.Imp) (openrtb_ext.ExtImpLogicad, error) { var bidderExt adapters.ExtImpBidder var logicadExt openrtb_ext.ExtImpLogicad - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return logicadExt, &errortypes.BadInput{ Message: err.Error(), } } - if err := json.Unmarshal(bidderExt.Bidder, &logicadExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &logicadExt); err != nil { return logicadExt, &errortypes.BadInput{ Message: err.Error(), } @@ -128,7 +129,7 @@ func (adapter *LogicadAdapter) MakeBids(internalRequest *openrtb2.BidRequest, ex } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { msg := fmt.Sprintf("Bad server response: %d", err) return nil, []error{&errortypes.BadServerResponse{Message: msg}} } diff --git a/adapters/logicad/logicadtest/supplemental/ext.json b/adapters/logicad/logicadtest/supplemental/ext.json index ad35892086b..97b5ff61cfa 100644 --- a/adapters/logicad/logicadtest/supplemental/ext.json +++ b/adapters/logicad/logicadtest/supplemental/ext.json @@ -24,8 +24,8 @@ }, "expectedMakeRequestsErrors": [ { - "value": "unexpected end of JSON input", - "comparison": "literal" + "value": "expect { or n, but found", + "comparison": "startswith" } ] } \ No newline at end of file diff --git a/adapters/loyal/loyal.go b/adapters/loyal/loyal.go index 4c1bf4dc59e..f54c0fe2eb3 100644 --- a/adapters/loyal/loyal.go +++ b/adapters/loyal/loyal.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -44,11 +45,11 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E var bidderExt adapters.ExtImpBidder var loyalExt openrtb_ext.ImpExtLoyal - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { errs = append(errs, err) continue } - if err := json.Unmarshal(bidderExt.Bidder, &loyalExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &loyalExt); err != nil { errs = append(errs, err) continue } @@ -118,7 +119,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } @@ -146,7 +147,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R func getBidMediaType(bid *openrtb2.Bid) (openrtb_ext.BidType, error) { var extBid openrtb_ext.ExtBid - err := json.Unmarshal(bid.Ext, &extBid) + err := jsonutil.Unmarshal(bid.Ext, &extBid) if err != nil { return "", fmt.Errorf("unable to deserialize imp %v bid.ext, error: %v", bid.ImpID, err) } diff --git a/adapters/loyal/loyaltest/supplemental/bad_response.json b/adapters/loyal/loyaltest/supplemental/bad_response.json index 58d5c71fa52..30fa65e95d9 100644 --- a/adapters/loyal/loyaltest/supplemental/bad_response.json +++ b/adapters/loyal/loyaltest/supplemental/bad_response.json @@ -78,7 +78,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/lunamedia/lunamedia.go b/adapters/lunamedia/lunamedia.go index bc663d31fdb..327a5106763 100644 --- a/adapters/lunamedia/lunamedia.go +++ b/adapters/lunamedia/lunamedia.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type LunaMediaAdapter struct { @@ -116,13 +117,13 @@ func compatBannerImpression(imp *openrtb2.Imp) error { func getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpLunaMedia, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: err.Error(), } } var LunaMediaExt openrtb_ext.ExtImpLunaMedia - if err := json.Unmarshal(bidderExt.Bidder, &LunaMediaExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &LunaMediaExt); err != nil { return nil, &errortypes.BadInput{ Message: err.Error(), } @@ -196,7 +197,7 @@ func (adapter *LunaMediaAdapter) MakeBids(internalRequest *openrtb2.BidRequest, } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { msg = fmt.Sprintf("Bad server response: %d", err) return nil, []error{&errortypes.BadServerResponse{Message: msg}} } diff --git a/adapters/lunamedia/lunamediatest/supplemental/ext.json b/adapters/lunamedia/lunamediatest/supplemental/ext.json index 3cfb878bd47..285c8b11ed2 100644 --- a/adapters/lunamedia/lunamediatest/supplemental/ext.json +++ b/adapters/lunamedia/lunamediatest/supplemental/ext.json @@ -27,7 +27,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "unexpected end of JSON input", - "comparison": "literal" + "value": "expect { or n, but found", + "comparison": "startswith" }] } \ No newline at end of file diff --git a/adapters/mabidder/mabidder.go b/adapters/mabidder/mabidder.go index 8e636e2281c..7505b5e5c9e 100644 --- a/adapters/mabidder/mabidder.go +++ b/adapters/mabidder/mabidder.go @@ -7,6 +7,7 @@ import ( "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type serverResponse struct { @@ -71,7 +72,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response serverResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/mabidder/mabiddertest/supplemental/bad-response-malformed.json b/adapters/mabidder/mabiddertest/supplemental/bad-response-malformed.json index fb59513192d..2638f5415f7 100644 --- a/adapters/mabidder/mabiddertest/supplemental/bad-response-malformed.json +++ b/adapters/mabidder/mabiddertest/supplemental/bad-response-malformed.json @@ -66,8 +66,8 @@ ], "expectedMakeBidsErrors": [ { - "value": "unexpected end of JSON input", - "comparison": "literal" + "value": "expect { or n, but found", + "comparison": "startswith" } ] } diff --git a/adapters/madvertise/madvertise.go b/adapters/madvertise/madvertise.go index 3c1ffa4ae55..8feabe36117 100644 --- a/adapters/madvertise/madvertise.go +++ b/adapters/madvertise/madvertise.go @@ -13,6 +13,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -93,13 +94,13 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte func getImpressionExt(imp openrtb2.Imp) (*openrtb_ext.ExtImpMadvertise, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("%s; ImpID=%s", err.Error(), imp.ID), } } var madvertiseExt openrtb_ext.ExtImpMadvertise - if err := json.Unmarshal(bidderExt.Bidder, &madvertiseExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &madvertiseExt); err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("%s; ImpID=%s", err.Error(), imp.ID), } @@ -131,7 +132,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/madvertise/madvertisetest/supplemental/required-ext.json b/adapters/madvertise/madvertisetest/supplemental/required-ext.json index 8989a8dc4e1..6d953811244 100644 --- a/adapters/madvertise/madvertisetest/supplemental/required-ext.json +++ b/adapters/madvertise/madvertisetest/supplemental/required-ext.json @@ -12,8 +12,8 @@ }, "expectedMakeRequestsErrors": [ { - "value": "unexpected end of JSON input; ImpID=test-imp-id-1", - "comparison": "literal" + "value": "expect { or n, but found", + "comparison": "startswith" } ] } diff --git a/adapters/marsmedia/marsmedia.go b/adapters/marsmedia/marsmedia.go index f47ba557d88..a35dcac781a 100644 --- a/adapters/marsmedia/marsmedia.go +++ b/adapters/marsmedia/marsmedia.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type MarsmediaAdapter struct { @@ -28,14 +29,14 @@ func (a *MarsmediaAdapter) MakeRequests(requestIn *openrtb2.BidRequest, reqInfo } var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(request.Imp[0].Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(request.Imp[0].Ext, &bidderExt); err != nil { return nil, []error{&errortypes.BadInput{ Message: "ext.bidder not provided", }} } var marsmediaExt openrtb_ext.ExtImpMarsmedia - if err := json.Unmarshal(bidderExt.Bidder, &marsmediaExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &marsmediaExt); err != nil { return nil, []error{&errortypes.BadInput{ Message: "ext.bidder.zoneId not provided", }} @@ -126,7 +127,7 @@ func (a *MarsmediaAdapter) MakeBids(internalRequest *openrtb2.BidRequest, extern } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Bad server response: %d. ", err), }} diff --git a/adapters/marsmedia/marsmediatest/supplemental/missing-param.json b/adapters/marsmedia/marsmediatest/supplemental/missing-param.json index e68b3f529e0..b88fba5a8a1 100644 --- a/adapters/marsmedia/marsmediatest/supplemental/missing-param.json +++ b/adapters/marsmedia/marsmediatest/supplemental/missing-param.json @@ -27,7 +27,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "ext.bidder.zoneId not provided", + "value": "zoneId is empty", "comparison": "literal" } ] diff --git a/adapters/mediago/mediago.go b/adapters/mediago/mediago.go index 2ef46310bd0..3f15e18af8b 100644 --- a/adapters/mediago/mediago.go +++ b/adapters/mediago/mediago.go @@ -14,6 +14,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -87,9 +88,9 @@ func getMediaGoExt(request *openrtb2.BidRequest) (*openrtb_ext.ExtMediaGo, error // first get the mediago ext from ext.bidderparams reqExt := &openrtb_ext.ExtRequest{} - err := json.Unmarshal(request.Ext, &reqExt) + err := jsonutil.Unmarshal(request.Ext, &reqExt) if err != nil { - err = json.Unmarshal(reqExt.Prebid.BidderParams, &extMediaGo) + err = jsonutil.Unmarshal(reqExt.Prebid.BidderParams, &extMediaGo) if err != nil && extMediaGo.Token != "" { return &extMediaGo, nil } @@ -97,13 +98,13 @@ func getMediaGoExt(request *openrtb2.BidRequest) (*openrtb_ext.ExtMediaGo, error // fallback to get token and region from first imp imp := request.Imp[0] - err = json.Unmarshal(imp.Ext, &extBidder) + err = jsonutil.Unmarshal(imp.Ext, &extBidder) if err != nil { return nil, err } var extImpMediaGo openrtb_ext.ExtImpMediaGo - err = json.Unmarshal(extBidder.Bidder, &extImpMediaGo) + err = jsonutil.Unmarshal(extBidder.Bidder, &extImpMediaGo) if err != nil { return nil, err } @@ -161,7 +162,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/mediago/mediagotest/supplemental/bad_imp_ext.json b/adapters/mediago/mediagotest/supplemental/bad_imp_ext.json index 191e4e33077..9c510cf16f2 100644 --- a/adapters/mediago/mediagotest/supplemental/bad_imp_ext.json +++ b/adapters/mediago/mediagotest/supplemental/bad_imp_ext.json @@ -18,7 +18,7 @@ "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/mediago/mediagotest/supplemental/bad_impext_bidder.json b/adapters/mediago/mediagotest/supplemental/bad_impext_bidder.json index 08e652b5cae..a5776adaed7 100644 --- a/adapters/mediago/mediagotest/supplemental/bad_impext_bidder.json +++ b/adapters/mediago/mediagotest/supplemental/bad_impext_bidder.json @@ -20,7 +20,7 @@ "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb_ext.ExtImpMediaGo", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/mediago/mediagotest/supplemental/bad_response.json b/adapters/mediago/mediagotest/supplemental/bad_response.json index d72ea408d39..922e1debf40 100644 --- a/adapters/mediago/mediagotest/supplemental/bad_response.json +++ b/adapters/mediago/mediagotest/supplemental/bad_response.json @@ -60,7 +60,7 @@ "expectedMakeBidsErrors": [ { "comparison": "literal", - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse" + "value": "expect { or n, but found \"" } ] } diff --git a/adapters/medianet/medianet.go b/adapters/medianet/medianet.go index a6a3bd4709a..20915c43973 100644 --- a/adapters/medianet/medianet.go +++ b/adapters/medianet/medianet.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -59,7 +60,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/melozen/melozen.go b/adapters/melozen/melozen.go index cb76274865b..bbe83cb9729 100644 --- a/adapters/melozen/melozen.go +++ b/adapters/melozen/melozen.go @@ -13,6 +13,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -44,12 +45,12 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E for _, imp := range request.Imp { // Extract Melozen Params var strImpExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &strImpExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &strImpExt); err != nil { errors = append(errors, err) continue } var strImpParams openrtb_ext.ImpExtMeloZen - if err := json.Unmarshal(strImpExt.Bidder, &strImpParams); err != nil { + if err := jsonutil.Unmarshal(strImpExt.Bidder, &strImpParams); err != nil { errors = append(errors, err) continue } @@ -109,12 +110,12 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var bidReq openrtb2.BidRequest - if err := json.Unmarshal(requestData.Body, &bidReq); err != nil { + if err := jsonutil.Unmarshal(requestData.Body, &bidReq); err != nil { return nil, []error{err} } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -173,7 +174,7 @@ func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) { if bid.Ext != nil { var bidExt openrtb_ext.ExtBid - err := json.Unmarshal(bid.Ext, &bidExt) + err := jsonutil.Unmarshal(bid.Ext, &bidExt) if err == nil && bidExt.Prebid != nil { return openrtb_ext.ParseBidType(string(bidExt.Prebid.Type)) } diff --git a/adapters/metax/metax.go b/adapters/metax/metax.go index d10c426434c..597346244cc 100644 --- a/adapters/metax/metax.go +++ b/adapters/metax/metax.go @@ -14,6 +14,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" "github.com/prebid/prebid-server/v2/util/ptrutil" ) @@ -77,7 +78,7 @@ func (a *adapter) MakeBids(bidReq *openrtb2.BidRequest, reqData *adapters.Reques } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(respData.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(respData.Body, &bidResp); err != nil { return nil, []error{err} } @@ -116,12 +117,12 @@ func (a *adapter) getEndpoint(ext *openrtb_ext.ExtImpMetaX) (string, error) { func parseBidderExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpMetaX, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, err } var metaxExt openrtb_ext.ExtImpMetaX - if err := json.Unmarshal(bidderExt.Bidder, &metaxExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &metaxExt); err != nil { return nil, errors.New("Wrong MetaX bidder ext") } diff --git a/adapters/metax/metaxtest/supplemental/invalid-ext.json b/adapters/metax/metaxtest/supplemental/invalid-ext.json index 54d6d9f2c05..7386b9ba62e 100644 --- a/adapters/metax/metaxtest/supplemental/invalid-ext.json +++ b/adapters/metax/metaxtest/supplemental/invalid-ext.json @@ -23,8 +23,8 @@ }, "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal*", - "comparison": "regex" + "value": "expect { or n, but found \"", + "comparison": "literal" } ] } diff --git a/adapters/metax/metaxtest/supplemental/resp-bad-json.json b/adapters/metax/metaxtest/supplemental/resp-bad-json.json index cc51b14e050..5879dad6cab 100644 --- a/adapters/metax/metaxtest/supplemental/resp-bad-json.json +++ b/adapters/metax/metaxtest/supplemental/resp-bad-json.json @@ -73,8 +73,8 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal*", - "comparison": "regex" + "value": "expect { or n, but found \"", + "comparison": "literal" } ] } diff --git a/adapters/mgid/mgid.go b/adapters/mgid/mgid.go index 93398905da1..f32e4730e4b 100644 --- a/adapters/mgid/mgid.go +++ b/adapters/mgid/mgid.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type MgidAdapter struct { @@ -74,7 +75,7 @@ func preprocess(request *openrtb2.BidRequest) (path string, err error) { var imp = request.Imp[i] var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return "", &errortypes.BadInput{ Message: err.Error(), } @@ -82,7 +83,7 @@ func preprocess(request *openrtb2.BidRequest) (path string, err error) { var mgidExt openrtb_ext.ExtImpMgid - if err := json.Unmarshal(bidderExt.Bidder, &mgidExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &mgidExt); err != nil { return "", &errortypes.BadInput{ Message: err.Error(), } @@ -143,7 +144,7 @@ func (a *MgidAdapter) MakeBids(bidReq *openrtb2.BidRequest, unused *adapters.Req var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -156,7 +157,7 @@ func (a *MgidAdapter) MakeBids(bidReq *openrtb2.BidRequest, unused *adapters.Req bidType := openrtb_ext.BidTypeBanner if len(sb.Bid[i].Ext) > 0 && bytes.Contains(sb.Bid[i].Ext, []byte("crtype")) { ext := RespBidExt{} - if err := json.Unmarshal(sb.Bid[i].Ext, &ext); err == nil && len(ext.CreativeType) > 0 { + if err := jsonutil.Unmarshal(sb.Bid[i].Ext, &ext); err == nil && len(ext.CreativeType) > 0 { bidType = ext.CreativeType } } diff --git a/adapters/mgidX/mgidX.go b/adapters/mgidX/mgidX.go index 6e6a3427fca..bf0b6d2e202 100644 --- a/adapters/mgidX/mgidX.go +++ b/adapters/mgidX/mgidX.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -44,10 +45,10 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E var bidderExt adapters.ExtImpBidder var mgidXExt openrtb_ext.ImpExtMgidX - if err = json.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { + if err = jsonutil.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { return nil, []error{err} } - if err = json.Unmarshal(bidderExt.Bidder, &mgidXExt); err != nil { + if err = jsonutil.Unmarshal(bidderExt.Bidder, &mgidXExt); err != nil { return nil, []error{err} } @@ -115,7 +116,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } @@ -146,7 +147,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R func getBidMediaType(bid *openrtb2.Bid) (openrtb_ext.BidType, error) { var extBid openrtb_ext.ExtBid - err := json.Unmarshal(bid.Ext, &extBid) + err := jsonutil.Unmarshal(bid.Ext, &extBid) if err != nil { return "", fmt.Errorf("unable to deserialize imp %v bid.ext", bid.ImpID) } diff --git a/adapters/mgidX/mgidXtest/supplemental/bad_response.json b/adapters/mgidX/mgidXtest/supplemental/bad_response.json index c732ba92c67..5cc4a338ac3 100644 --- a/adapters/mgidX/mgidXtest/supplemental/bad_response.json +++ b/adapters/mgidX/mgidXtest/supplemental/bad_response.json @@ -78,7 +78,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/minutemedia/minutemedia.go b/adapters/minutemedia/minutemedia.go index 796f9ec6e6b..af78d5dcc5e 100644 --- a/adapters/minutemedia/minutemedia.go +++ b/adapters/minutemedia/minutemedia.go @@ -14,6 +14,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) // adapter is a MinuteMedia implementation of the adapters.Bidder interface. @@ -62,7 +63,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, _ *adapters.RequestData } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } @@ -96,12 +97,12 @@ func extractOrg(openRTBRequest *openrtb2.BidRequest) (string, error) { } var bidderExt adapters.ExtImpBidder - if err = json.Unmarshal(openRTBRequest.Imp[0].Ext, &bidderExt); err != nil { + if err = jsonutil.Unmarshal(openRTBRequest.Imp[0].Ext, &bidderExt); err != nil { return "", fmt.Errorf("failed to unmarshal bidderExt: %w", err) } var impExt openrtb_ext.ImpExtMinuteMedia - if err = json.Unmarshal(bidderExt.Bidder, &impExt); err != nil { + if err = jsonutil.Unmarshal(bidderExt.Bidder, &impExt); err != nil { return "", fmt.Errorf("failed to unmarshal ImpExtMinuteMedia: %w", err) } diff --git a/adapters/minutemedia/minutemediatest/supplemental/missing-bidder.json b/adapters/minutemedia/minutemediatest/supplemental/missing-bidder.json index c5724e88738..6ed87bbf7ec 100644 --- a/adapters/minutemedia/minutemediatest/supplemental/missing-bidder.json +++ b/adapters/minutemedia/minutemediatest/supplemental/missing-bidder.json @@ -41,8 +41,8 @@ }, "expectedMakeRequestsErrors": [ { - "value": "failed to extract org: failed to unmarshal ImpExtMinuteMedia: unexpected end of JSON input", - "comparison": "literal" + "value": "failed to extract org: failed to unmarshal ImpExtMinuteMedia: expect { or n, but found", + "comparison": "startswith" } ] } diff --git a/adapters/minutemedia/minutemediatest/supplemental/missing-extension.json b/adapters/minutemedia/minutemediatest/supplemental/missing-extension.json index bd0f87c3e59..02783e0b2d3 100644 --- a/adapters/minutemedia/minutemediatest/supplemental/missing-extension.json +++ b/adapters/minutemedia/minutemediatest/supplemental/missing-extension.json @@ -40,8 +40,8 @@ }, "expectedMakeRequestsErrors": [ { - "value": "failed to extract org: failed to unmarshal bidderExt: unexpected end of JSON input", - "comparison": "literal" + "value": "failed to extract org: failed to unmarshal bidderExt: expect { or n, but found", + "comparison": "startswith" } ] } diff --git a/adapters/missena/missena.go b/adapters/missena/missena.go index 93d4c2ba1cb..41e8bc383c8 100644 --- a/adapters/missena/missena.go +++ b/adapters/missena/missena.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -116,7 +117,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte for _, imp := range request.Imp { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { errors = append(errors, &errortypes.BadInput{ Message: "Error parsing bidderExt object", }) @@ -124,7 +125,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte } var missenaExt openrtb_ext.ExtImpMissena - if err := json.Unmarshal(bidderExt.Bidder, &missenaExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &missenaExt); err != nil { errors = append(errors, &errortypes.BadInput{ Message: "Error parsing missenaExt parameters", }) @@ -153,14 +154,14 @@ func readGDPR(request *openrtb2.BidRequest) (bool, string) { consentString := "" if request.User != nil { var extUser openrtb_ext.ExtUser - if err := json.Unmarshal(request.User.Ext, &extUser); err == nil { + if err := jsonutil.Unmarshal(request.User.Ext, &extUser); err == nil { consentString = extUser.Consent } } gdprApplies := false var extRegs openrtb_ext.ExtRegs if request.Regs != nil { - if err := json.Unmarshal(request.Regs.Ext, &extRegs); err == nil { + if err := jsonutil.Unmarshal(request.Regs.Ext, &extRegs); err == nil { if extRegs.GDPR != nil { gdprApplies = (*extRegs.GDPR == 1) } @@ -189,7 +190,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var missenaResponse MissenaBidServerResponse - if err := json.Unmarshal(responseData.Body, &missenaResponse); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &missenaResponse); err != nil { return nil, []error{err} } diff --git a/adapters/mobfoxpb/mobfoxpb.go b/adapters/mobfoxpb/mobfoxpb.go index b7630d7f9e1..da2e1f12c0d 100644 --- a/adapters/mobfoxpb/mobfoxpb.go +++ b/adapters/mobfoxpb/mobfoxpb.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) const ( @@ -113,7 +114,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/mobfoxpb/mobfoxpbtest/supplemental/bad_response.json b/adapters/mobfoxpb/mobfoxpbtest/supplemental/bad_response.json index e4f246e7e0d..51a4eae8ef4 100644 --- a/adapters/mobfoxpb/mobfoxpbtest/supplemental/bad_response.json +++ b/adapters/mobfoxpb/mobfoxpbtest/supplemental/bad_response.json @@ -79,7 +79,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/mobilefuse/mobilefuse.go b/adapters/mobilefuse/mobilefuse.go index 6d0ab2ec3f5..dbf62241e88 100644 --- a/adapters/mobilefuse/mobilefuse.go +++ b/adapters/mobilefuse/mobilefuse.go @@ -13,6 +13,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type MobileFuseAdapter struct { @@ -75,7 +76,7 @@ func (adapter *MobileFuseAdapter) MakeBids(incomingRequest *openrtb2.BidRequest, var incomingBidResponse openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &incomingBidResponse); err != nil { + if err := jsonutil.Unmarshal(response.Body, &incomingBidResponse); err != nil { return nil, []error{err} } @@ -142,14 +143,14 @@ func getFirstMobileFuseExtension(request *openrtb2.BidRequest) (*openrtb_ext.Ext for _, imp := range request.Imp { var bidder_imp_extension adapters.ExtImpBidder - err := json.Unmarshal(imp.Ext, &bidder_imp_extension) + err := jsonutil.Unmarshal(imp.Ext, &bidder_imp_extension) if err != nil { errs = append(errs, err) continue } - err = json.Unmarshal(bidder_imp_extension.Bidder, &mobileFuseImpExtension) + err = jsonutil.Unmarshal(bidder_imp_extension.Bidder, &mobileFuseImpExtension) if err != nil { errs = append(errs, err) @@ -165,12 +166,12 @@ func getFirstMobileFuseExtension(request *openrtb2.BidRequest) (*openrtb_ext.Ext func getMobileFuseExtensionForImp(imp *openrtb2.Imp, mobileFuseImpExtension *openrtb_ext.ExtImpMobileFuse) error { var bidder_imp_extension adapters.ExtImpBidder - err := json.Unmarshal(imp.Ext, &bidder_imp_extension) + err := jsonutil.Unmarshal(imp.Ext, &bidder_imp_extension) if err != nil { return err } - return json.Unmarshal(bidder_imp_extension.Bidder, &mobileFuseImpExtension) + return jsonutil.Unmarshal(bidder_imp_extension.Bidder, &mobileFuseImpExtension) } func (adapter *MobileFuseAdapter) getEndpoint(ext *openrtb_ext.ExtImpMobileFuse) (string, error) { @@ -201,7 +202,7 @@ func getValidImps(bidRequest *openrtb2.BidRequest, ext *openrtb_ext.ExtImpMobile imp.TagID = strconv.Itoa(ext.PlacementId) var extSkadn ExtSkadn - err = json.Unmarshal(imp.Ext, &extSkadn) + err = jsonutil.Unmarshal(imp.Ext, &extSkadn) if err != nil { return nil, err } @@ -229,7 +230,7 @@ func getValidImps(bidRequest *openrtb2.BidRequest, ext *openrtb_ext.ExtImpMobile func getBidType(bid openrtb2.Bid) openrtb_ext.BidType { if bid.Ext != nil { var bidExt BidExt - err := json.Unmarshal(bid.Ext, &bidExt) + err := jsonutil.Unmarshal(bid.Ext, &bidExt) if err == nil { if bidExt.Mf.MediaType == "video" { return openrtb_ext.BidTypeVideo diff --git a/adapters/mobilefuse/mobilefusetest/supplemental/bad-ext-bidder.json b/adapters/mobilefuse/mobilefusetest/supplemental/bad-ext-bidder.json index 61cf115faea..759fffc7e8a 100644 --- a/adapters/mobilefuse/mobilefusetest/supplemental/bad-ext-bidder.json +++ b/adapters/mobilefuse/mobilefusetest/supplemental/bad-ext-bidder.json @@ -1,7 +1,7 @@ { "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb_ext.ExtImpMobileFuse", + "value": "expect { or n, but found \"", "comparison": "literal" } ], diff --git a/adapters/mobilefuse/mobilefusetest/supplemental/bad-ext.json b/adapters/mobilefuse/mobilefusetest/supplemental/bad-ext.json index f0c23aa27e3..598f1606796 100644 --- a/adapters/mobilefuse/mobilefusetest/supplemental/bad-ext.json +++ b/adapters/mobilefuse/mobilefusetest/supplemental/bad-ext.json @@ -1,7 +1,7 @@ { "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "value": "expect { or n, but found \"", "comparison": "literal" } ], diff --git a/adapters/motorik/motorik.go b/adapters/motorik/motorik.go index 73cfccde107..afd0b015f16 100644 --- a/adapters/motorik/motorik.go +++ b/adapters/motorik/motorik.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -82,13 +83,13 @@ func (a *adapter) MakeRequests(openRTBRequest *openrtb2.BidRequest, reqInfo *ada func getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtMotorik, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: "Error parsing motorikExt - " + err.Error(), } } var motorikExt openrtb_ext.ExtMotorik - if err := json.Unmarshal(bidderExt.Bidder, &motorikExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &motorikExt); err != nil { return nil, &errortypes.BadInput{ Message: "Error parsing bidderExt - " + err.Error(), } @@ -124,7 +125,7 @@ func (a *adapter) MakeBids(openRTBRequest *openrtb2.BidRequest, requestToBidder responseBody := bidderRawResponse.Body var bidResp openrtb2.BidResponse - if err := json.Unmarshal(responseBody, &bidResp); err != nil { + if err := jsonutil.Unmarshal(responseBody, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Bad Server Response", }} diff --git a/adapters/motorik/motoriktest/supplemental/invalid-bidder-ext-object.json b/adapters/motorik/motoriktest/supplemental/invalid-bidder-ext-object.json index fb89a5894a5..016fbd43490 100644 --- a/adapters/motorik/motoriktest/supplemental/invalid-bidder-ext-object.json +++ b/adapters/motorik/motoriktest/supplemental/invalid-bidder-ext-object.json @@ -1,7 +1,7 @@ { "expectedMakeRequestsErrors": [ { - "value": "Error parsing bidderExt - json: cannot unmarshal string into Go value of type openrtb_ext.ExtMotorik", + "value": "Error parsing bidderExt - expect { or n, but found \"", "comparison": "literal" } ], diff --git a/adapters/motorik/motoriktest/supplemental/invalid-motorik-ext-object.json b/adapters/motorik/motoriktest/supplemental/invalid-motorik-ext-object.json index 1b2cce8db49..ee1d473feab 100644 --- a/adapters/motorik/motoriktest/supplemental/invalid-motorik-ext-object.json +++ b/adapters/motorik/motoriktest/supplemental/invalid-motorik-ext-object.json @@ -1,7 +1,7 @@ { "expectedMakeRequestsErrors": [ { - "value": "Error parsing motorikExt - json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "value": "Error parsing motorikExt - expect { or n, but found \"", "comparison": "literal" } ], diff --git a/adapters/nextmillennium/nextmillennium.go b/adapters/nextmillennium/nextmillennium.go index 38d1c72549e..68e7c6aa61d 100644 --- a/adapters/nextmillennium/nextmillennium.go +++ b/adapters/nextmillennium/nextmillennium.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -74,13 +75,13 @@ func getImpressionsInfo(imps []openrtb2.Imp) (resImps []*openrtb_ext.ImpExtNextM func getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ImpExtNextMillennium, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: err.Error(), } } var nextMillenniumExt openrtb_ext.ImpExtNextMillennium - if err := json.Unmarshal(bidderExt.Bidder, &nextMillenniumExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &nextMillenniumExt); err != nil { return nil, &errortypes.BadInput{ Message: err.Error(), } @@ -169,7 +170,7 @@ func (adapter *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalR } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { msg = fmt.Sprintf("Bad server response: %d", err) return nil, []error{&errortypes.BadServerResponse{Message: msg}} } @@ -200,7 +201,7 @@ func (adapter *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalR func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) { var info nmExtNMM if config.ExtraAdapterInfo != "" { - if err := json.Unmarshal([]byte(config.ExtraAdapterInfo), &info); err != nil { + if err := jsonutil.Unmarshal([]byte(config.ExtraAdapterInfo), &info); err != nil { return nil, fmt.Errorf("invalid extra info: %v", err) } } diff --git a/adapters/nextmillennium/nextmillenniumtest/supplemental/ext.json b/adapters/nextmillennium/nextmillenniumtest/supplemental/ext.json index 58fefc6349f..68584236617 100644 --- a/adapters/nextmillennium/nextmillenniumtest/supplemental/ext.json +++ b/adapters/nextmillennium/nextmillenniumtest/supplemental/ext.json @@ -26,8 +26,8 @@ }, "expectedMakeRequestsErrors": [ { - "value": "unexpected end of JSON input", - "comparison": "literal" + "value": "expect { or n, but found", + "comparison": "startswith" } ] } diff --git a/adapters/nobid/nobid.go b/adapters/nobid/nobid.go index 9c91c78dd2b..b3225cfd530 100644 --- a/adapters/nobid/nobid.go +++ b/adapters/nobid/nobid.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) // NoBidAdapter - NoBid Adapter definition @@ -73,7 +74,7 @@ func (a *NoBidAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRe var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/oms/oms.go b/adapters/oms/oms.go index c2e7c394cb5..8fcecf527dc 100644 --- a/adapters/oms/oms.go +++ b/adapters/oms/oms.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -61,7 +62,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/onetag/onetag.go b/adapters/onetag/onetag.go index 938414c2759..581a8342b5e 100644 --- a/adapters/onetag/onetag.go +++ b/adapters/onetag/onetag.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -76,14 +77,14 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte func getImpressionExt(imp openrtb2.Imp) (*openrtb_ext.ExtImpOnetag, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: "Bidder extension not provided or can't be unmarshalled", } } var onetagExt openrtb_ext.ExtImpOnetag - if err := json.Unmarshal(bidderExt.Bidder, &onetagExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &onetagExt); err != nil { return nil, &errortypes.BadInput{ Message: "Error while unmarshaling bidder extension", } @@ -110,7 +111,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/openweb/openweb.go b/adapters/openweb/openweb.go index a1996d056b2..65807399237 100644 --- a/adapters/openweb/openweb.go +++ b/adapters/openweb/openweb.go @@ -14,6 +14,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -50,12 +51,12 @@ func checkExtAndExtractOrg(request *openrtb2.BidRequest) (string, error) { var err error for _, imp := range request.Imp { var bidderExt adapters.ExtImpBidder - if err = json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err = jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return "", fmt.Errorf("unmarshal bidderExt: %w", err) } var impExt openrtb_ext.ExtImpOpenWeb - if err = json.Unmarshal(bidderExt.Bidder, &impExt); err != nil { + if err = jsonutil.Unmarshal(bidderExt.Bidder, &impExt); err != nil { return "", fmt.Errorf("unmarshal ExtImpOpenWeb: %w", err) } @@ -85,7 +86,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, _ *adapters.RequestData } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/openx/openx.go b/adapters/openx/openx.go index 9e16b3438b8..fd437967e93 100644 --- a/adapters/openx/openx.go +++ b/adapters/openx/openx.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) const hbconfig = "hb_pbs_1.0.0" @@ -117,14 +118,14 @@ func (a *OpenxAdapter) makeRequest(request *openrtb2.BidRequest) (*adapters.Requ // Mutate the imp to get it ready to send to openx. func preprocess(imp *openrtb2.Imp, reqExt *openxReqExt) error { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return &errortypes.BadInput{ Message: err.Error(), } } var openxExt openrtb_ext.ExtImpOpenx - if err := json.Unmarshal(bidderExt.Bidder, &openxExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &openxExt); err != nil { return &errortypes.BadInput{ Message: err.Error(), } @@ -143,7 +144,7 @@ func preprocess(imp *openrtb2.Imp, reqExt *openxReqExt) error { // outgoing imp.ext should be same as incoming imp.ext minus prebid and bidder impExt := openxImpExt{} - if err := json.Unmarshal(imp.Ext, &impExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &impExt); err != nil { return &errortypes.BadInput{ Message: err.Error(), } @@ -202,7 +203,7 @@ func (a *OpenxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRe } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -215,7 +216,7 @@ func (a *OpenxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRe if bidResp.Ext != nil { var bidRespExt openxRespExt - if err := json.Unmarshal(bidResp.Ext, &bidRespExt); err == nil && bidRespExt.FledgeAuctionConfigs != nil { + if err := jsonutil.Unmarshal(bidResp.Ext, &bidRespExt); err == nil && bidRespExt.FledgeAuctionConfigs != nil { bidResponse.FledgeAuctionConfigs = make([]*openrtb_ext.FledgeAuctionConfig, 0, len(bidRespExt.FledgeAuctionConfigs)) for impId, config := range bidRespExt.FledgeAuctionConfigs { fledgeAuctionConfig := &openrtb_ext.FledgeAuctionConfig{ diff --git a/adapters/operaads/operaads.go b/adapters/operaads/operaads.go index 21aecd63226..2f1acc9a1db 100644 --- a/adapters/operaads/operaads.go +++ b/adapters/operaads/operaads.go @@ -13,6 +13,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" "github.com/prebid/prebid-server/v2/util/ptrutil" "github.com/prebid/openrtb/v20/openrtb2" @@ -57,14 +58,14 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E for _, imp := range request.Imp { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { errs = append(errs, &errortypes.BadInput{ Message: err.Error(), }) continue } var operaadsExt openrtb_ext.ImpExtOperaads - if err := json.Unmarshal(bidderExt.Bidder, &operaadsExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &operaadsExt); err != nil { errs = append(errs, &errortypes.BadInput{ Message: err.Error(), }) @@ -158,7 +159,7 @@ func convertImpression(imp *openrtb2.Imp) error { } if imp.Native != nil && imp.Native.Request != "" { v := make(map[string]interface{}) - err := json.Unmarshal([]byte(imp.Native.Request), &v) + err := jsonutil.Unmarshal([]byte(imp.Native.Request), &v) if err != nil { return err } @@ -214,7 +215,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest } var parsedResponse openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &parsedResponse); err != nil { + if err := jsonutil.Unmarshal(response.Body, &parsedResponse); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: err.Error(), }} diff --git a/adapters/oraki/oraki.go b/adapters/oraki/oraki.go index 0e29aa9bd5e..acd89a3a3b5 100644 --- a/adapters/oraki/oraki.go +++ b/adapters/oraki/oraki.go @@ -9,6 +9,7 @@ import ( "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -43,11 +44,11 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E var bidderExt adapters.ExtImpBidder var orakiExt openrtb_ext.ImpExtOraki - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { errs = append(errs, err) continue } - if err := json.Unmarshal(bidderExt.Bidder, &orakiExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &orakiExt); err != nil { errs = append(errs, err) continue } @@ -110,7 +111,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/oraki/orakitest/supplemental/bad_response.json b/adapters/oraki/orakitest/supplemental/bad_response.json index d8029b5ed6b..4fe8d572c46 100644 --- a/adapters/oraki/orakitest/supplemental/bad_response.json +++ b/adapters/oraki/orakitest/supplemental/bad_response.json @@ -78,7 +78,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/orbidder/orbidder.go b/adapters/orbidder/orbidder.go index 0e8edaeb0bb..e0b07696510 100644 --- a/adapters/orbidder/orbidder.go +++ b/adapters/orbidder/orbidder.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type OrbidderAdapter struct { @@ -68,14 +69,14 @@ func getValidImpressions(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRe func preprocessExtensions(imp *openrtb2.Imp) error { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return &errortypes.BadInput{ Message: err.Error(), } } var orbidderExt openrtb_ext.ExtImpOrbidder - if err := json.Unmarshal(bidderExt.Bidder, &orbidderExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &orbidderExt); err != nil { return &errortypes.BadInput{ Message: "Wrong orbidder bidder ext: " + err.Error(), } @@ -122,7 +123,7 @@ func (rcv OrbidderAdapter) MakeBids(_ *openrtb2.BidRequest, _ *adapters.RequestD } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/orbidder/orbiddertest/supplemental/ext-unmarshall-error.json b/adapters/orbidder/orbiddertest/supplemental/ext-unmarshall-error.json index 447e2985f92..6f9372baa9c 100644 --- a/adapters/orbidder/orbiddertest/supplemental/ext-unmarshall-error.json +++ b/adapters/orbidder/orbiddertest/supplemental/ext-unmarshall-error.json @@ -25,7 +25,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "Wrong orbidder bidder ext: json: cannot unmarshal array into Go struct field ExtImpOrbidder.accountId of type string", + "value": "Wrong orbidder bidder ext: cannot unmarshal openrtb_ext.ExtImpOrbidder.AccountId: expects \" or n, but found [", "comparison": "literal" } ] diff --git a/adapters/orbidder/orbiddertest/supplemental/valid-and-invalid-imps.json b/adapters/orbidder/orbiddertest/supplemental/valid-and-invalid-imps.json index f12e26e18e2..8f95e6c5ec9 100644 --- a/adapters/orbidder/orbiddertest/supplemental/valid-and-invalid-imps.json +++ b/adapters/orbidder/orbiddertest/supplemental/valid-and-invalid-imps.json @@ -120,8 +120,8 @@ ], "expectedMakeRequestsErrors": [ { - "value": "unexpected end of JSON input", - "comparison": "literal" + "value": "expect { or n, but found", + "comparison": "startswith" } ] } diff --git a/adapters/outbrain/outbrain.go b/adapters/outbrain/outbrain.go index 9e588d8640c..4a2163f8f3e 100644 --- a/adapters/outbrain/outbrain.go +++ b/adapters/outbrain/outbrain.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -35,11 +36,11 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte imp := reqCopy.Imp[i] var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { errs = append(errs, err) continue } - if err := json.Unmarshal(bidderExt.Bidder, &outbrainExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &outbrainExt); err != nil { errs = append(errs, err) continue } @@ -107,7 +108,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } @@ -125,7 +126,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } if bidType == openrtb_ext.BidTypeNative { var nativePayload nativeResponse.Response - if err := json.Unmarshal(json.RawMessage(bid.AdM), &nativePayload); err != nil { + if err := jsonutil.Unmarshal(json.RawMessage(bid.AdM), &nativePayload); err != nil { errs = append(errs, err) continue } diff --git a/adapters/ownadx/ownadx.go b/adapters/ownadx/ownadx.go index 59bc0b68fab..fcc068dee0f 100644 --- a/adapters/ownadx/ownadx.go +++ b/adapters/ownadx/ownadx.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -65,14 +66,14 @@ func (adapter *adapter) buildEndpointURL(params *openrtb_ext.ExtImpOwnAdx) (stri func getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpOwnAdx, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: "Bidder extension not valid or can't be unmarshalled", } } var ownAdxExt openrtb_ext.ExtImpOwnAdx - if err := json.Unmarshal(bidderExt.Bidder, &ownAdxExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &ownAdxExt); err != nil { return nil, &errortypes.BadInput{ Message: "Error while unmarshaling bidder extension", } @@ -143,7 +144,7 @@ func (adapter *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalR } } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{ &errortypes.BadServerResponse{ Message: "Bad server response ", diff --git a/adapters/pangle/pangle.go b/adapters/pangle/pangle.go index b46e2c669b7..a992e1732cb 100644 --- a/adapters/pangle/pangle.go +++ b/adapters/pangle/pangle.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -81,13 +82,13 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte requestCopy := *request for _, imp := range request.Imp { var impExt wrappedExtImpBidder - if err := json.Unmarshal(imp.Ext, &impExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &impExt); err != nil { errs = append(errs, fmt.Errorf("failed unmarshalling imp ext (err)%s", err.Error())) continue } // get token & networkIDs var bidderImpExt openrtb_ext.ImpExtPangle - if err := json.Unmarshal(impExt.Bidder, &bidderImpExt); err != nil { + if err := jsonutil.Unmarshal(impExt.Bidder, &bidderImpExt); err != nil { errs = append(errs, fmt.Errorf("failed unmarshalling bidder imp ext (err)%s", err.Error())) continue } @@ -147,7 +148,7 @@ func getMediaTypeForBid(bid *openrtb2.Bid) (openrtb_ext.BidType, error) { } var bidExt pangleBidExt - if err := json.Unmarshal(bid.Ext, &bidExt); err != nil { + if err := jsonutil.Unmarshal(bid.Ext, &bidExt); err != nil { return "", fmt.Errorf("invalid bid ext") } else if bidExt.Pangle == nil || bidExt.Pangle.AdType == nil { return "", fmt.Errorf("missing pangleExt/adtype in bid ext") @@ -189,7 +190,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/pgamssp/pgamssp.go b/adapters/pgamssp/pgamssp.go index 2f8360fb2e8..4c71c4acf17 100644 --- a/adapters/pgamssp/pgamssp.go +++ b/adapters/pgamssp/pgamssp.go @@ -9,6 +9,7 @@ import ( "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -43,10 +44,10 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E var bidderExt adapters.ExtImpBidder var pgamExt openrtb_ext.ImpExtPgamSsp - if err = json.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { + if err = jsonutil.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { return nil, []error{err} } - if err = json.Unmarshal(bidderExt.Bidder, &pgamExt); err != nil { + if err = jsonutil.Unmarshal(bidderExt.Bidder, &pgamExt); err != nil { return nil, []error{err} } @@ -107,7 +108,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/pgamssp/pgamssptest/supplemental/bad_response.json b/adapters/pgamssp/pgamssptest/supplemental/bad_response.json index 53446fb8ab9..36f5e7ba4d0 100644 --- a/adapters/pgamssp/pgamssptest/supplemental/bad_response.json +++ b/adapters/pgamssp/pgamssptest/supplemental/bad_response.json @@ -78,7 +78,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/playdigo/playdigo.go b/adapters/playdigo/playdigo.go index d8450bdd798..da049b38492 100644 --- a/adapters/playdigo/playdigo.go +++ b/adapters/playdigo/playdigo.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -44,11 +45,11 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E var bidderExt adapters.ExtImpBidder var playdigoExt openrtb_ext.ImpExtPlaydigo - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { errs = append(errs, err) continue } - if err := json.Unmarshal(bidderExt.Bidder, &playdigoExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &playdigoExt); err != nil { errs = append(errs, err) continue } @@ -116,7 +117,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/playdigo/playdigotest/supplemental/bad_response.json b/adapters/playdigo/playdigotest/supplemental/bad_response.json index afa17aa2e87..4e4b3ef9671 100644 --- a/adapters/playdigo/playdigotest/supplemental/bad_response.json +++ b/adapters/playdigo/playdigotest/supplemental/bad_response.json @@ -78,7 +78,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/pubmatic/pubmatic.go b/adapters/pubmatic/pubmatic.go index 9c5799eece7..b28dc8fd60a 100644 --- a/adapters/pubmatic/pubmatic.go +++ b/adapters/pubmatic/pubmatic.go @@ -13,6 +13,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" "github.com/prebid/prebid-server/v2/util/ptrutil" "github.com/buger/jsonparser" @@ -260,12 +261,12 @@ func parseImpressionObject(imp *openrtb2.Imp, extractWrapperExtFromImp, extractP } var bidderExt ExtImpBidderPubmatic - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return wrapExt, pubID, err } var pubmaticExt openrtb_ext.ExtImpPubmatic - if err := json.Unmarshal(bidderExt.Bidder, &pubmaticExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &pubmaticExt); err != nil { return wrapExt, pubID, err } @@ -275,7 +276,7 @@ func parseImpressionObject(imp *openrtb2.Imp, extractWrapperExtFromImp, extractP // Parse Wrapper Extension only once per request if extractWrapperExtFromImp && len(pubmaticExt.WrapExt) != 0 { - err := json.Unmarshal([]byte(pubmaticExt.WrapExt), &wrapExt) + err := jsonutil.Unmarshal([]byte(pubmaticExt.WrapExt), &wrapExt) if err != nil { return wrapExt, pubID, fmt.Errorf("Error in Wrapper Parameters = %v for ImpID = %v WrapperExt = %v", err.Error(), imp.ID, string(pubmaticExt.WrapExt)) } @@ -346,7 +347,7 @@ func extractPubmaticExtFromRequest(request *openrtb2.BidRequest) (extRequestAdSe } reqExt := &openrtb_ext.ExtRequest{} - err := json.Unmarshal(request.Ext, &reqExt) + err := jsonutil.Unmarshal(request.Ext, &reqExt) if err != nil { return pmReqExt, fmt.Errorf("error decoding Request.ext : %s", err.Error()) } @@ -354,7 +355,7 @@ func extractPubmaticExtFromRequest(request *openrtb2.BidRequest) (extRequestAdSe reqExtBidderParams := make(map[string]json.RawMessage) if reqExt.Prebid.BidderParams != nil { - err = json.Unmarshal(reqExt.Prebid.BidderParams, &reqExtBidderParams) + err = jsonutil.Unmarshal(reqExt.Prebid.BidderParams, &reqExtBidderParams) if err != nil { return pmReqExt, err } @@ -363,7 +364,7 @@ func extractPubmaticExtFromRequest(request *openrtb2.BidRequest) (extRequestAdSe //get request ext bidder params if wrapperObj, present := reqExtBidderParams["wrapper"]; present && len(wrapperObj) != 0 { wrpExt := &pubmaticWrapperExt{} - err = json.Unmarshal(wrapperObj, wrpExt) + err = jsonutil.Unmarshal(wrapperObj, wrpExt) if err != nil { return pmReqExt, err } @@ -372,7 +373,7 @@ func extractPubmaticExtFromRequest(request *openrtb2.BidRequest) (extRequestAdSe if acatBytes, ok := reqExtBidderParams["acat"]; ok { var acat []string - err = json.Unmarshal(acatBytes, &acat) + err = jsonutil.Unmarshal(acatBytes, &acat) if err != nil { return pmReqExt, err } @@ -437,7 +438,7 @@ func (a *PubmaticAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externa } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -458,7 +459,7 @@ func (a *PubmaticAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externa } var bidExt *pubmaticBidExt - err := json.Unmarshal(bid.Ext, &bidExt) + err := jsonutil.Unmarshal(bid.Ext, &bidExt) if err != nil { errs = append(errs, err) } else if bidExt != nil { @@ -489,7 +490,7 @@ func (a *PubmaticAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externa if bidResp.Ext != nil { var bidRespExt respExt - if err := json.Unmarshal(bidResp.Ext, &bidRespExt); err == nil && bidRespExt.FledgeAuctionConfigs != nil { + if err := jsonutil.Unmarshal(bidResp.Ext, &bidRespExt); err == nil && bidRespExt.FledgeAuctionConfigs != nil { bidResponse.FledgeAuctionConfigs = make([]*openrtb_ext.FledgeAuctionConfig, 0, len(bidRespExt.FledgeAuctionConfigs)) for impId, config := range bidRespExt.FledgeAuctionConfigs { fledgeAuctionConfig := &openrtb_ext.FledgeAuctionConfig{ @@ -506,7 +507,7 @@ func (a *PubmaticAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externa func getNativeAdm(adm string) (string, error) { var err error nativeAdm := make(map[string]interface{}) - err = json.Unmarshal([]byte(adm), &nativeAdm) + err = jsonutil.Unmarshal([]byte(adm), &nativeAdm) if err != nil { return adm, errors.New("unable to unmarshal native adm") } @@ -528,7 +529,7 @@ func getNativeAdm(adm string) (string, error) { func getMapFromJSON(source json.RawMessage) map[string]interface{} { if source != nil { dataMap := make(map[string]interface{}) - err := json.Unmarshal(source, &dataMap) + err := jsonutil.Unmarshal(source, &dataMap) if err == nil { return dataMap } diff --git a/adapters/pubmatic/pubmatictest/supplemental/app.json b/adapters/pubmatic/pubmatictest/supplemental/app.json index abe79bbe31d..67be496c5df 100644 --- a/adapters/pubmatic/pubmatictest/supplemental/app.json +++ b/adapters/pubmatic/pubmatictest/supplemental/app.json @@ -139,8 +139,8 @@ ], "expectedMakeBidsErrors": [ { - "value": "unexpected end of JSON input", - "comparison": "literal" + "value": "expect { or n, but found", + "comparison": "startswith" } ] } \ No newline at end of file diff --git a/adapters/pubnative/pubnative.go b/adapters/pubnative/pubnative.go index 89d8f9e9e77..aa4beb4eb92 100644 --- a/adapters/pubnative/pubnative.go +++ b/adapters/pubnative/pubnative.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" "github.com/prebid/prebid-server/v2/util/ptrutil" ) @@ -37,13 +38,13 @@ func (a *PubnativeAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *a for _, imp := range request.Imp { requestCopy := *request var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { errs = append(errs, err) continue } var pubnativeExt openrtb_ext.ExtImpPubnative - if err := json.Unmarshal(bidderExt.Bidder, &pubnativeExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &pubnativeExt); err != nil { errs = append(errs, err) continue } @@ -145,7 +146,7 @@ func (a *PubnativeAdapter) MakeBids(internalRequest *openrtb2.BidRequest, extern } var parsedResponse openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &parsedResponse); err != nil { + if err := jsonutil.Unmarshal(response.Body, &parsedResponse); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: err.Error(), }} diff --git a/adapters/pubrise/pubrise.go b/adapters/pubrise/pubrise.go index 9d71f2e1439..a3957bc18fd 100644 --- a/adapters/pubrise/pubrise.go +++ b/adapters/pubrise/pubrise.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -44,11 +45,11 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E var bidderExt adapters.ExtImpBidder var pubriseExt openrtb_ext.ImpExtPubrise - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { errs = append(errs, err) continue } - if err := json.Unmarshal(bidderExt.Bidder, &pubriseExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &pubriseExt); err != nil { errs = append(errs, err) continue } @@ -118,7 +119,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/pubrise/pubrisetest/supplemental/bad_response.json b/adapters/pubrise/pubrisetest/supplemental/bad_response.json index 08b58d888ed..9bc9c2de35a 100644 --- a/adapters/pubrise/pubrisetest/supplemental/bad_response.json +++ b/adapters/pubrise/pubrisetest/supplemental/bad_response.json @@ -78,7 +78,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/pulsepoint/pulsepoint.go b/adapters/pulsepoint/pulsepoint.go index dffe2754110..c8b645f70f6 100644 --- a/adapters/pulsepoint/pulsepoint.go +++ b/adapters/pulsepoint/pulsepoint.go @@ -37,14 +37,14 @@ func (a *PulsePointAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo * for i := 0; i < len(request.Imp); i++ { imp := request.Imp[i] var bidderExt adapters.ExtImpBidder - if err = json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err = jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { errs = append(errs, &errortypes.BadInput{ Message: err.Error(), }) continue } var pulsepointExt openrtb_ext.ExtImpPulsePoint - if err = json.Unmarshal(bidderExt.Bidder, &pulsepointExt); err != nil { + if err = jsonutil.Unmarshal(bidderExt.Bidder, &pulsepointExt); err != nil { errs = append(errs, &errortypes.BadInput{ Message: err.Error(), }) @@ -138,7 +138,7 @@ func (a *PulsePointAdapter) MakeBids(internalRequest *openrtb2.BidRequest, exter } // parse response var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/pulsepoint/pulsepointtest/supplemental/bad-bid-data.json b/adapters/pulsepoint/pulsepointtest/supplemental/bad-bid-data.json index 182bddc7137..8949960cb29 100644 --- a/adapters/pulsepoint/pulsepointtest/supplemental/bad-bid-data.json +++ b/adapters/pulsepoint/pulsepointtest/supplemental/bad-bid-data.json @@ -84,8 +84,8 @@ }], "expectedBidResponses": [], "expectedMakeBidsErrors": [{ - "value": "json: cannot unmarshal string into Go struct field Bid.seatbid.bid.w of type int64", - "comparison": "literal" + "value": "cannot unmarshal openrtb2.Bid.W: unexpected character", + "comparison": "startswith" } ] } \ No newline at end of file diff --git a/adapters/pulsepoint/pulsepointtest/supplemental/bad-prebid-params.json b/adapters/pulsepoint/pulsepointtest/supplemental/bad-prebid-params.json index 060ffb1ad88..aee3d444912 100644 --- a/adapters/pulsepoint/pulsepointtest/supplemental/bad-prebid-params.json +++ b/adapters/pulsepoint/pulsepointtest/supplemental/bad-prebid-params.json @@ -24,7 +24,7 @@ }, "httpCalls": [], "expectedMakeRequestsErrors": [{ - "value": "Value looks like Number/Boolean/None, but can't find its end: ',' or '}' symbol", + "value": "cannot unmarshal openrtb_ext.ExtImpPulsePoint.TagID: Value looks like Number/Boolean/None, but can't find its end: ',' or '}' symbol", "comparison": "literal" }], "expectedBidResponses": [], diff --git a/adapters/pulsepoint/pulsepointtest/supplemental/bad-prebid.ext.json b/adapters/pulsepoint/pulsepointtest/supplemental/bad-prebid.ext.json index 7de9bd3c264..74825c2c018 100644 --- a/adapters/pulsepoint/pulsepointtest/supplemental/bad-prebid.ext.json +++ b/adapters/pulsepoint/pulsepointtest/supplemental/bad-prebid.ext.json @@ -19,7 +19,7 @@ }, "httpCalls": [], "expectedMakeRequestsErrors": [{ - "value": "json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "value": "expect { or n, but found \"", "comparison": "literal" }], "expectedBidResponses": [], diff --git a/adapters/pwbid/pwbid.go b/adapters/pwbid/pwbid.go index 19b182562c6..726e77d8de1 100644 --- a/adapters/pwbid/pwbid.go +++ b/adapters/pwbid/pwbid.go @@ -9,6 +9,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -51,7 +52,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/pwbid/pwbidtest/supplemental/response-200-without-body.json b/adapters/pwbid/pwbidtest/supplemental/response-200-without-body.json index 6b4effd139e..ffb61b548b7 100644 --- a/adapters/pwbid/pwbidtest/supplemental/response-200-without-body.json +++ b/adapters/pwbid/pwbidtest/supplemental/response-200-without-body.json @@ -45,8 +45,8 @@ ], "expectedMakeBidsErrors": [ { - "value": "unexpected end of JSON input", - "comparison": "literal" + "value": "expect { or n, but found", + "comparison": "startswith" } ] } diff --git a/adapters/qt/qt.go b/adapters/qt/qt.go index ddb306beb91..5974bd79f5b 100644 --- a/adapters/qt/qt.go +++ b/adapters/qt/qt.go @@ -9,6 +9,7 @@ import ( "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -43,11 +44,11 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E var bidderExt adapters.ExtImpBidder var qtExt openrtb_ext.ImpExtQT - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { errs = append(errs, err) continue } - if err := json.Unmarshal(bidderExt.Bidder, &qtExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &qtExt); err != nil { errs = append(errs, err) continue } @@ -110,7 +111,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/qt/qttest/supplemental/bad_response.json b/adapters/qt/qttest/supplemental/bad_response.json index d8029b5ed6b..4fe8d572c46 100644 --- a/adapters/qt/qttest/supplemental/bad_response.json +++ b/adapters/qt/qttest/supplemental/bad_response.json @@ -78,7 +78,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/readpeak/readpeak.go b/adapters/readpeak/readpeak.go index dd7e30ccb81..e1bb55cbbb8 100644 --- a/adapters/readpeak/readpeak.go +++ b/adapters/readpeak/readpeak.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -33,11 +34,11 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte var imps []openrtb2.Imp for i := 0; i < len(requestCopy.Imp); i++ { var impExt adapters.ExtImpBidder - if err := json.Unmarshal(requestCopy.Imp[i].Ext, &impExt); err != nil { + if err := jsonutil.Unmarshal(requestCopy.Imp[i].Ext, &impExt); err != nil { errors = append(errors, err) continue } - if err := json.Unmarshal(impExt.Bidder, &rpExt); err != nil { + if err := jsonutil.Unmarshal(impExt.Bidder, &rpExt); err != nil { errors = append(errors, err) continue } @@ -108,7 +109,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/relevantdigital/relevantdigital.go b/adapters/relevantdigital/relevantdigital.go index 134bdf5e4d5..1bd4cd585ea 100644 --- a/adapters/relevantdigital/relevantdigital.go +++ b/adapters/relevantdigital/relevantdigital.go @@ -15,6 +15,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" jsonpatch "gopkg.in/evanphx/json-patch.v4" ) @@ -56,7 +57,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co func patchBidRequestExt(prebidBidRequest *openrtb2.BidRequest, id string) error { var bidRequestExt relevantExt if len(prebidBidRequest.Ext) != 0 { - if err := json.Unmarshal(prebidBidRequest.Ext, &bidRequestExt); err != nil { + if err := jsonutil.Unmarshal(prebidBidRequest.Ext, &bidRequestExt); err != nil { return &errortypes.FailedToRequestBids{ Message: fmt.Sprintf("failed to unmarshal ext, %s", prebidBidRequest.Ext), } @@ -158,13 +159,13 @@ func createJSONRequest(bidRequest *openrtb2.BidRequest) ([]byte, error) { func getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtRelevantDigital, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: "imp.ext not provided", } } relevantExt := openrtb_ext.ExtRelevantDigital{PbsBufferMs: default_bufffer_ms} - if err := json.Unmarshal(bidderExt.Bidder, &relevantExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &relevantExt); err != nil { return nil, &errortypes.BadInput{ Message: "ext.bidder not provided", } @@ -254,7 +255,7 @@ func getHeaders(request *openrtb2.BidRequest) http.Header { func getMediaTypeForBidFromExt(bid openrtb2.Bid) (openrtb_ext.BidType, error) { if bid.Ext != nil { var bidExt openrtb_ext.ExtBid - err := json.Unmarshal(bid.Ext, &bidExt) + err := jsonutil.Unmarshal(bid.Ext, &bidExt) if err == nil && bidExt.Prebid != nil { return openrtb_ext.ParseBidType(string(bidExt.Prebid.Type)) } @@ -301,7 +302,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/revcontent/revcontent.go b/adapters/revcontent/revcontent.go index e2a74c9311c..1ef43c4d5dc 100644 --- a/adapters/revcontent/revcontent.go +++ b/adapters/revcontent/revcontent.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -78,7 +79,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/revcontent/revcontenttest/supplemental/bad_response.json b/adapters/revcontent/revcontenttest/supplemental/bad_response.json index cf9450c533d..b9922f7d38b 100644 --- a/adapters/revcontent/revcontenttest/supplemental/bad_response.json +++ b/adapters/revcontent/revcontenttest/supplemental/bad_response.json @@ -44,7 +44,7 @@ "expectedMakeBidsErrors": [ { "comparison": "literal", - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse" + "value": "expect { or n, but found \"" } ] } diff --git a/adapters/richaudience/richaudience.go b/adapters/richaudience/richaudience.go index 7955e3577c8..f935eb8182a 100644 --- a/adapters/richaudience/richaudience.go +++ b/adapters/richaudience/richaudience.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -157,14 +158,14 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var bidReq openrtb2.BidRequest - if err := json.Unmarshal(requestData.Body, &bidReq); err != nil { + if err := jsonutil.Unmarshal(requestData.Body, &bidReq); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: err.Error(), }} } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: err.Error(), }} @@ -230,7 +231,7 @@ func validateDevice(request *openrtb2.BidRequest) (err error) { func parseImpExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpRichaudience, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { err = &errortypes.BadInput{ Message: fmt.Sprintf("not found parameters ext in ImpID : %s", imp.ID), } @@ -238,7 +239,7 @@ func parseImpExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpRichaudience, error) { } var richaudienceExt openrtb_ext.ExtImpRichaudience - if err := json.Unmarshal(bidderExt.Bidder, &richaudienceExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &richaudienceExt); err != nil { err = &errortypes.BadInput{ Message: fmt.Sprintf("invalid parameters ext in ImpID: %s", imp.ID), } diff --git a/adapters/rise/rise.go b/adapters/rise/rise.go index 3742f768ee4..de8c806ca79 100644 --- a/adapters/rise/rise.go +++ b/adapters/rise/rise.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) // adapter is a Rise implementation of the adapters.Bidder interface. @@ -62,7 +63,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, _ *adapters.RequestData } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } @@ -93,12 +94,12 @@ 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 { + if err = jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return "", fmt.Errorf("unmarshal bidderExt: %w", err) } var impExt openrtb_ext.ImpExtRise - if err = json.Unmarshal(bidderExt.Bidder, &impExt); err != nil { + if err = jsonutil.Unmarshal(bidderExt.Bidder, &impExt); err != nil { return "", fmt.Errorf("unmarshal ImpExtRise: %w", err) } diff --git a/adapters/rise/risetest/supplemental/missing-bidder.json b/adapters/rise/risetest/supplemental/missing-bidder.json index 0a7cc67ca08..5cde70f5719 100644 --- a/adapters/rise/risetest/supplemental/missing-bidder.json +++ b/adapters/rise/risetest/supplemental/missing-bidder.json @@ -28,8 +28,8 @@ }, "expectedMakeRequestsErrors": [ { - "value": "extractOrg: unmarshal ImpExtRise: unexpected end of JSON input", - "comparison": "literal" + "value": "extractOrg: unmarshal ImpExtRise: expect { or n, but found", + "comparison": "startswith" } ] } diff --git a/adapters/rise/risetest/supplemental/missing-extension.json b/adapters/rise/risetest/supplemental/missing-extension.json index 74e94f45c79..6bb8594d152 100644 --- a/adapters/rise/risetest/supplemental/missing-extension.json +++ b/adapters/rise/risetest/supplemental/missing-extension.json @@ -27,8 +27,8 @@ }, "expectedMakeRequestsErrors": [ { - "value": "extractOrg: unmarshal bidderExt: unexpected end of JSON input", - "comparison": "literal" + "value": "extractOrg: unmarshal bidderExt: expect { or n, but found", + "comparison": "startswith" } ] } diff --git a/adapters/roulax/roulax.go b/adapters/roulax/roulax.go index 959aa57eca9..3ca099af64b 100644 --- a/adapters/roulax/roulax.go +++ b/adapters/roulax/roulax.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -33,11 +34,11 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co // getImpAdotExt parses and return first imp ext or nil func getImpRoulaxExt(imp *openrtb2.Imp) (openrtb_ext.ExtImpRoulax, error) { var extBidder adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &extBidder); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &extBidder); err != nil { return openrtb_ext.ExtImpRoulax{}, err } var extImpRoulax openrtb_ext.ExtImpRoulax - if err := json.Unmarshal(extBidder.Bidder, &extImpRoulax); err != nil { + if err := jsonutil.Unmarshal(extBidder.Bidder, &extImpRoulax); err != nil { return openrtb_ext.ExtImpRoulax{}, err } return extImpRoulax, nil @@ -80,7 +81,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, _ *adapters.RequestData return nil, []error{err} } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp)) diff --git a/adapters/rtbhouse/rtbhouse.go b/adapters/rtbhouse/rtbhouse.go index daca87bc961..d0df5eaf221 100644 --- a/adapters/rtbhouse/rtbhouse.go +++ b/adapters/rtbhouse/rtbhouse.go @@ -14,6 +14,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) const ( @@ -107,14 +108,14 @@ func (adapter *RTBHouseAdapter) MakeRequests( func getImpressionExt(imp openrtb2.Imp) (*openrtb_ext.ExtImpRTBHouse, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: "Bidder extension not provided or can't be unmarshalled", } } var rtbhouseExt openrtb_ext.ExtImpRTBHouse - if err := json.Unmarshal(bidderExt.Bidder, &rtbhouseExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &rtbhouseExt); err != nil { return nil, &errortypes.BadInput{ Message: "Error while unmarshaling bidder extension", } @@ -153,7 +154,7 @@ func (adapter *RTBHouseAdapter) MakeBids( } var openRTBBidderResponse openrtb2.BidResponse - if err := json.Unmarshal(bidderRawResponse.Body, &openRTBBidderResponse); err != nil { + if err := jsonutil.Unmarshal(bidderRawResponse.Body, &openRTBBidderResponse); err != nil { return nil, []error{err} } @@ -207,7 +208,7 @@ func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) { func getNativeAdm(adm string) (string, error) { nativeAdm := make(map[string]interface{}) - err := json.Unmarshal([]byte(adm), &nativeAdm) + err := jsonutil.Unmarshal([]byte(adm), &nativeAdm) if err != nil { return adm, errors.New("unable to unmarshal native adm") } diff --git a/adapters/rtbhouse/rtbhousetest/supplemental/bad_response.json b/adapters/rtbhouse/rtbhousetest/supplemental/bad_response.json index 6eb776e48aa..a2d0c8da3d4 100644 --- a/adapters/rtbhouse/rtbhousetest/supplemental/bad_response.json +++ b/adapters/rtbhouse/rtbhousetest/supplemental/bad_response.json @@ -56,7 +56,7 @@ "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/rubicon/rubicon.go b/adapters/rubicon/rubicon.go index 9cf8eb6ff20..a0cf754cba6 100644 --- a/adapters/rubicon/rubicon.go +++ b/adapters/rubicon/rubicon.go @@ -3,16 +3,18 @@ package rubicon import ( "encoding/json" "fmt" - "github.com/prebid/prebid-server/v2/version" "net/http" "net/url" "strconv" "strings" + "github.com/prebid/prebid-server/v2/version" + "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" "github.com/prebid/prebid-server/v2/util/maputil" "github.com/buger/jsonparser" @@ -479,7 +481,7 @@ func (a *RubiconAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada if sourceCopy.SChain != nil { var sourceCopyExt openrtb_ext.ExtSource if sourceCopy.Ext != nil { - if err = json.Unmarshal(sourceCopy.Ext, &sourceCopyExt); err != nil { + if err = jsonutil.Unmarshal(sourceCopy.Ext, &sourceCopyExt); err != nil { errs = append(errs, &errortypes.BadInput{Message: err.Error()}) continue } @@ -509,7 +511,7 @@ func (a *RubiconAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada var regsCopyExt openrtb_ext.ExtRegs if regsCopy.Ext != nil { - if err = json.Unmarshal(regsCopy.Ext, ®sCopyExt); err != nil { + if err = jsonutil.Unmarshal(regsCopy.Ext, ®sCopyExt); err != nil { errs = append(errs, &errortypes.BadInput{Message: err.Error()}) continue } @@ -577,7 +579,7 @@ func createImpsToExtMap(imps []openrtb2.Imp) (map[*openrtb2.Imp]rubiconExtImpBid for _, imp := range imps { impCopy := imp var bidderExt rubiconExtImpBidder - if err = json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err = jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { errs = append(errs, &errortypes.BadInput{ Message: err.Error(), }) @@ -721,14 +723,14 @@ func (a *RubiconAdapter) updateImpRpTarget(extImp rubiconExtImpBidder, extImpRub var data rubiconData if len(extImp.Data) > 0 { - err := json.Unmarshal(extImp.Data, &data) + err := jsonutil.Unmarshal(extImp.Data, &data) if err != nil { return nil, err } } var contextData rubiconData if len(extImp.Context.Data) > 0 { - err := json.Unmarshal(extImp.Context.Data, &contextData) + err := jsonutil.Unmarshal(extImp.Context.Data, &contextData) if err != nil { return nil, err } @@ -888,7 +890,7 @@ func rawJSONToMap(message json.RawMessage) (map[string]interface{}, error) { func mapFromRawJSON(message json.RawMessage) (map[string]interface{}, error) { targetAsMap := make(map[string]interface{}) - err := json.Unmarshal(message, &targetAsMap) + err := jsonutil.Unmarshal(message, &targetAsMap) if err != nil { return nil, err } @@ -901,7 +903,7 @@ func getSegmentIdsToCopy(data []openrtb2.Data, segTaxValues []int) []string { for _, dataRecord := range data { if dataRecord.Ext != nil { var dataExtObject rubiconDataExt - err := json.Unmarshal(dataRecord.Ext, &dataExtObject) + err := jsonutil.Unmarshal(dataRecord.Ext, &dataExtObject) if err != nil { continue } @@ -947,7 +949,7 @@ func resolveNativeObject(native *openrtb2.Native, target map[string]interface{}) return native, nil } - err := json.Unmarshal([]byte(native.Request), &target) + err := jsonutil.Unmarshal([]byte(native.Request), &target) if err != nil { return nil, err } @@ -972,7 +974,7 @@ func resolveNativeObject(native *openrtb2.Native, target map[string]interface{}) func setImpNative(jsonData []byte, requestNative map[string]interface{}) ([]byte, error) { var jsonMap map[string]interface{} - if err := json.Unmarshal(jsonData, &jsonMap); err != nil { + if err := jsonutil.Unmarshal(jsonData, &jsonMap); err != nil { return jsonData, err } @@ -1017,14 +1019,14 @@ func (a *RubiconAdapter) MakeBids(internalRequest *openrtb2.BidRequest, external } var bidResp rubiconBidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: err.Error(), }} } var bidReq openrtb2.BidRequest - if err := json.Unmarshal(externalRequest.Body, &bidReq); err != nil { + if err := jsonutil.Unmarshal(externalRequest.Body, &bidReq); err != nil { return nil, []error{err} } @@ -1079,7 +1081,7 @@ func (a *RubiconAdapter) MakeBids(internalRequest *openrtb2.BidRequest, external rubiconBidAsBytes, _ := json.Marshal(bid) if len(rubiconBidAsBytes) > 0 { - err = json.Unmarshal(rubiconBidAsBytes, &ortbBid) + err = jsonutil.Unmarshal(rubiconBidAsBytes, &ortbBid) if err != nil { return nil, []error{err} } @@ -1103,12 +1105,12 @@ func mapImpIdToCpmOverride(imps []openrtb2.Imp) map[string]float64 { impIdToCmpOverride := make(map[string]float64) for _, imp := range imps { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { continue } var rubiconExt openrtb_ext.ExtImpRubicon - if err := json.Unmarshal(bidderExt.Bidder, &rubiconExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &rubiconExt); err != nil { continue } @@ -1134,7 +1136,7 @@ func resolveAdm(bid rubiconBid) string { func cmpOverrideFromBidRequest(bidRequest *openrtb2.BidRequest) float64 { var bidRequestExt bidRequestExt - if err := json.Unmarshal(bidRequest.Ext, &bidRequestExt); err != nil { + if err := jsonutil.Unmarshal(bidRequest.Ext, &bidRequestExt); err != nil { return 0 } @@ -1147,7 +1149,7 @@ func updateBidExtWithMetaNetworkId(bid rubiconBid, buyer int) json.RawMessage { } var bidExt *extPrebid if bid.Ext != nil { - if err := json.Unmarshal(bid.Ext, &bidExt); err != nil { + if err := jsonutil.Unmarshal(bid.Ext, &bidExt); err != nil { return nil } } diff --git a/adapters/rubicon/rubicontest/supplemental/invalid-bidder-ext.json b/adapters/rubicon/rubicontest/supplemental/invalid-bidder-ext.json index c9114d1d4d4..08141bf6065 100644 --- a/adapters/rubicon/rubicontest/supplemental/invalid-bidder-ext.json +++ b/adapters/rubicon/rubicontest/supplemental/invalid-bidder-ext.json @@ -25,7 +25,7 @@ "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal array into Go struct field rubiconExtImpBidder.bidder of type openrtb_ext.ExtImpRubicon", + "value": "cannot unmarshal rubicon.rubiconExtImpBidder.Bidder: expect { or n, but found [", "comparison": "literal" } ] diff --git a/adapters/sa_lunamedia/salunamedia.go b/adapters/sa_lunamedia/salunamedia.go index 89d5d9f691a..b4734d5ce5b 100644 --- a/adapters/sa_lunamedia/salunamedia.go +++ b/adapters/sa_lunamedia/salunamedia.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -86,7 +87,7 @@ func (a *adapter) MakeBids( responseBody := bidderRawResponse.Body var bidResp openrtb2.BidResponse - if err := json.Unmarshal(responseBody, &bidResp); err != nil { + if err := jsonutil.Unmarshal(responseBody, &bidResp); err != nil { return nil, []error{err} } @@ -111,7 +112,7 @@ func (a *adapter) MakeBids( var bidExt bidExt var bidType openrtb_ext.BidType - if err := json.Unmarshal(bid.Ext, &bidExt); err != nil { + if err := jsonutil.Unmarshal(bid.Ext, &bidExt); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Missing BidExt", }} diff --git a/adapters/sa_lunamedia/salunamediatest/supplemental/bad-response.json b/adapters/sa_lunamedia/salunamediatest/supplemental/bad-response.json index 72262b5d533..33020bc6d3c 100644 --- a/adapters/sa_lunamedia/salunamediatest/supplemental/bad-response.json +++ b/adapters/sa_lunamedia/salunamediatest/supplemental/bad-response.json @@ -90,7 +90,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ], diff --git a/adapters/screencore/screencore.go b/adapters/screencore/screencore.go index 6011b9bbd80..43352c31c0b 100644 --- a/adapters/screencore/screencore.go +++ b/adapters/screencore/screencore.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -88,13 +89,13 @@ func (a *adapter) MakeRequests(openRTBRequest *openrtb2.BidRequest, reqInfo *ada func getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtScreencore, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: "Error parsing screencoreExt - " + err.Error(), } } var screencoreExt openrtb_ext.ExtScreencore - if err := json.Unmarshal(bidderExt.Bidder, &screencoreExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &screencoreExt); err != nil { return nil, &errortypes.BadInput{ Message: "Error parsing bidderExt - " + err.Error(), } @@ -130,7 +131,7 @@ func (a *adapter) MakeBids(openRTBRequest *openrtb2.BidRequest, requestToBidder responseBody := bidderRawResponse.Body var bidResp openrtb2.BidResponse - if err := json.Unmarshal(responseBody, &bidResp); err != nil { + if err := jsonutil.Unmarshal(responseBody, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Bad Server Response", }} diff --git a/adapters/screencore/screencoretest/supplemental/invalid-bidder-ext-object.json b/adapters/screencore/screencoretest/supplemental/invalid-bidder-ext-object.json index 4dc5c5a62bc..016fbd43490 100644 --- a/adapters/screencore/screencoretest/supplemental/invalid-bidder-ext-object.json +++ b/adapters/screencore/screencoretest/supplemental/invalid-bidder-ext-object.json @@ -1,7 +1,7 @@ { "expectedMakeRequestsErrors": [ { - "value": "Error parsing bidderExt - json: cannot unmarshal string into Go value of type openrtb_ext.ExtScreencore", + "value": "Error parsing bidderExt - expect { or n, but found \"", "comparison": "literal" } ], diff --git a/adapters/screencore/screencoretest/supplemental/invalid-screencore-ext-object.json b/adapters/screencore/screencoretest/supplemental/invalid-screencore-ext-object.json index b52e18fab50..4c3c9d95055 100644 --- a/adapters/screencore/screencoretest/supplemental/invalid-screencore-ext-object.json +++ b/adapters/screencore/screencoretest/supplemental/invalid-screencore-ext-object.json @@ -1,7 +1,7 @@ { "expectedMakeRequestsErrors": [ { - "value": "Error parsing screencoreExt - json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "value": "Error parsing screencoreExt - expect { or n, but found \"", "comparison": "literal" } ], diff --git a/adapters/seedingAlliance/seedingAlliance.go b/adapters/seedingAlliance/seedingAlliance.go index 1d6e9a8fb12..3883ddd3c31 100644 --- a/adapters/seedingAlliance/seedingAlliance.go +++ b/adapters/seedingAlliance/seedingAlliance.go @@ -14,6 +14,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -86,7 +87,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } @@ -123,7 +124,7 @@ func resolvePriceMacro(bid *openrtb2.Bid) { func getMediaTypeForBid(ext json.RawMessage) (openrtb_ext.BidType, error) { var bidExt openrtb_ext.ExtBid - if err := json.Unmarshal(ext, &bidExt); err != nil { + if err := jsonutil.Unmarshal(ext, &bidExt); err != nil { return "", fmt.Errorf("could not unmarshal openrtb_ext.ExtBid: %w", err) } @@ -149,11 +150,11 @@ func getExtInfo(imp *openrtb2.Imp) (string, error) { accountId := "pbs" - if err := json.Unmarshal(imp.Ext, &ext); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &ext); err != nil { return "", fmt.Errorf("could not unmarshal adapters.ExtImpBidder: %w", err) } - if err := json.Unmarshal(ext.Bidder, &extSA); err != nil { + if err := jsonutil.Unmarshal(ext.Bidder, &extSA); err != nil { return "", fmt.Errorf("could not unmarshal openrtb_ext.ImpExtSeedingAlliance: %w", err) } diff --git a/adapters/seedingAlliance/seedingAlliancetest/supplemental/invalid_tag_id.json b/adapters/seedingAlliance/seedingAlliancetest/supplemental/invalid_tag_id.json index c79795e48e2..7d4c212d611 100644 --- a/adapters/seedingAlliance/seedingAlliancetest/supplemental/invalid_tag_id.json +++ b/adapters/seedingAlliance/seedingAlliancetest/supplemental/invalid_tag_id.json @@ -1,7 +1,7 @@ { "expectedMakeRequestsErrors": [ { - "value": "could not unmarshal openrtb_ext.ImpExtSeedingAlliance: json: cannot unmarshal number into Go struct field ImpExtSeedingAlliance.adUnitId of type string", + "value": "could not unmarshal openrtb_ext.ImpExtSeedingAlliance: cannot unmarshal openrtb_ext.ImpExtSeedingAlliance.AdUnitID: expects \" or n, but found 1", "comparison": "literal" } ], diff --git a/adapters/sharethrough/sharethrough.go b/adapters/sharethrough/sharethrough.go index fd303c6feff..fa07c0f57ee 100644 --- a/adapters/sharethrough/sharethrough.go +++ b/adapters/sharethrough/sharethrough.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" "github.com/prebid/prebid-server/v2/version" ) @@ -41,7 +42,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E modifiableSource = *request.Source } var sourceExt map[string]interface{} - if err := json.Unmarshal(modifiableSource.Ext, &sourceExt); err == nil { + if err := jsonutil.Unmarshal(modifiableSource.Ext, &sourceExt); err == nil { sourceExt["str"] = adapterVersion sourceExt["version"] = version.Ver } else { @@ -58,12 +59,12 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E for _, imp := range request.Imp { // Extract Sharethrough Params var strImpExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &strImpExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &strImpExt); err != nil { errors = append(errors, err) continue } var strImpParams openrtb_ext.ExtImpSharethrough - if err := json.Unmarshal(strImpExt.Bidder, &strImpParams); err != nil { + if err := jsonutil.Unmarshal(strImpExt.Bidder, &strImpParams); err != nil { errors = append(errors, err) continue } @@ -128,12 +129,12 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var bidReq openrtb2.BidRequest - if err := json.Unmarshal(requestData.Body, &bidReq); err != nil { + if err := jsonutil.Unmarshal(requestData.Body, &bidReq); err != nil { return nil, []error{err} } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -197,7 +198,7 @@ func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) { if bid.Ext != nil { var bidExt openrtb_ext.ExtBid - err := json.Unmarshal(bid.Ext, &bidExt) + err := jsonutil.Unmarshal(bid.Ext, &bidExt) if err == nil && bidExt.Prebid != nil { return openrtb_ext.ParseBidType(string(bidExt.Prebid.Type)) } diff --git a/adapters/silvermob/silvermob.go b/adapters/silvermob/silvermob.go index 636f126147a..2b6fec20e3a 100644 --- a/adapters/silvermob/silvermob.go +++ b/adapters/silvermob/silvermob.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type SilverMobAdapter struct { @@ -111,13 +112,13 @@ func (a *SilverMobAdapter) MakeRequests( func (a *SilverMobAdapter) getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtSilverMob, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("error unmarshaling imp.ext: %s", err.Error()), } } var silvermobExt openrtb_ext.ExtSilverMob - if err := json.Unmarshal(bidderExt.Bidder, &silvermobExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &silvermobExt); err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("error unmarshaling imp.ext.bidder: %s", err.Error()), } @@ -161,7 +162,7 @@ func (a *SilverMobAdapter) MakeBids( responseBody := bidderRawResponse.Body var bidResp openrtb2.BidResponse - if err := json.Unmarshal(responseBody, &bidResp); err != nil { + if err := jsonutil.Unmarshal(responseBody, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Error unmarshaling server Response: %s", err), }} diff --git a/adapters/silvermob/silvermobtest/supplemental/invalid-response.json b/adapters/silvermob/silvermobtest/supplemental/invalid-response.json index f78979db334..353adb84f85 100644 --- a/adapters/silvermob/silvermobtest/supplemental/invalid-response.json +++ b/adapters/silvermob/silvermobtest/supplemental/invalid-response.json @@ -112,7 +112,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "Error unmarshaling server Response: json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "Error unmarshaling server Response: expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/silvermob/silvermobtest/supplemental/invalid-silvermob-ext-object.json b/adapters/silvermob/silvermobtest/supplemental/invalid-silvermob-ext-object.json index 090d7aff5b6..1f452e8d289 100644 --- a/adapters/silvermob/silvermobtest/supplemental/invalid-silvermob-ext-object.json +++ b/adapters/silvermob/silvermobtest/supplemental/invalid-silvermob-ext-object.json @@ -21,7 +21,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "error unmarshaling imp.ext: json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "value": "error unmarshaling imp.ext: expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/silverpush/silverpush.go b/adapters/silverpush/silverpush.go index 2ed554a2594..043e94765bf 100644 --- a/adapters/silverpush/silverpush.go +++ b/adapters/silverpush/silverpush.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" "github.com/prebid/prebid-server/v2/util/ptrutil" ) @@ -118,11 +119,11 @@ func setUser(req *openrtb2.BidRequest) error { var userExtRaw map[string]json.RawMessage if req.User != nil && req.User.Ext != nil { - if err := json.Unmarshal(req.User.Ext, &userExtRaw); err != nil { + if err := jsonutil.Unmarshal(req.User.Ext, &userExtRaw); err != nil { return &errortypes.BadInput{Message: "Invalid user.ext."} } if userExtDataRaw, ok := userExtRaw["data"]; ok { - if err := json.Unmarshal(userExtDataRaw, &extUser); err != nil { + if err := jsonutil.Unmarshal(userExtDataRaw, &extUser); err != nil { return &errortypes.BadInput{Message: "Invalid user.ext.data."} } var userCopy = *req.User @@ -217,13 +218,13 @@ func setBannerDimension(banner *openrtb2.Banner) (*openrtb2.Banner, error) { func setPublisherId(req *openrtb2.BidRequest, imp *openrtb2.Imp, impExt *openrtb_ext.ImpExtSilverpush) error { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return &errortypes.BadInput{ Message: err.Error(), } } - if err := json.Unmarshal(bidderExt.Bidder, impExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, impExt); err != nil { return &errortypes.BadInput{ Message: err.Error(), } @@ -283,7 +284,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/silverpush/silverpushtest/supplemental/bad-imp-ext-bidder.json b/adapters/silverpush/silverpushtest/supplemental/bad-imp-ext-bidder.json index 5bedcfe34c6..5621dfbe2d4 100644 --- a/adapters/silverpush/silverpushtest/supplemental/bad-imp-ext-bidder.json +++ b/adapters/silverpush/silverpushtest/supplemental/bad-imp-ext-bidder.json @@ -77,7 +77,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal number into Go value of type openrtb_ext.ImpExtSilverpush", + "value": "expect { or n, but found 9", "comparison": "literal" } ] diff --git a/adapters/silverpush/silverpushtest/supplemental/bad-imp-ext.json b/adapters/silverpush/silverpushtest/supplemental/bad-imp-ext.json index 7c5b7af90e2..16d7aaf7159 100644 --- a/adapters/silverpush/silverpushtest/supplemental/bad-imp-ext.json +++ b/adapters/silverpush/silverpushtest/supplemental/bad-imp-ext.json @@ -75,7 +75,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal number into Go value of type adapters.ExtImpBidder", + "value": "expect { or n, but found 9", "comparison": "literal" } ] diff --git a/adapters/silverpush/silverpushtest/supplemental/bad-response-unmarshal.json b/adapters/silverpush/silverpushtest/supplemental/bad-response-unmarshal.json index d6cad0fc5f7..dba093b2dc3 100644 --- a/adapters/silverpush/silverpushtest/supplemental/bad-response-unmarshal.json +++ b/adapters/silverpush/silverpushtest/supplemental/bad-response-unmarshal.json @@ -178,7 +178,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/smaato/native.go b/adapters/smaato/native.go index b18a5fc4490..44611c0b14b 100644 --- a/adapters/smaato/native.go +++ b/adapters/smaato/native.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/prebid/prebid-server/v2/errortypes" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type nativeAd struct { @@ -13,7 +14,7 @@ type nativeAd struct { func extractAdmNative(adMarkup string) (string, error) { var nativeAd nativeAd - if err := json.Unmarshal([]byte(adMarkup), &nativeAd); err != nil { + if err := jsonutil.Unmarshal([]byte(adMarkup), &nativeAd); err != nil { return "", &errortypes.BadServerResponse{ Message: fmt.Sprintf("Invalid ad markup %s.", adMarkup), } diff --git a/adapters/smaato/smaato.go b/adapters/smaato/smaato.go index 2d1579c55bd..9c417f5f7f5 100644 --- a/adapters/smaato/smaato.go +++ b/adapters/smaato/smaato.go @@ -14,6 +14,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/metrics" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" "github.com/prebid/prebid-server/v2/util/timeutil" ) @@ -108,7 +109,7 @@ func (adapter *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalR } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -361,7 +362,7 @@ func setUser(request *openrtb2.BidRequest) error { if request.User != nil && request.User.Ext != nil { var userExtRaw map[string]json.RawMessage - if err := json.Unmarshal(request.User.Ext, &userExtRaw); err != nil { + if err := jsonutil.Unmarshal(request.User.Ext, &userExtRaw); err != nil { return &errortypes.BadInput{Message: "Invalid user.ext."} } @@ -369,7 +370,7 @@ func setUser(request *openrtb2.BidRequest) error { var err error var userExtData userExtData - if err = json.Unmarshal(userExtDataRaw, &userExtData); err != nil { + if err = jsonutil.Unmarshal(userExtDataRaw, &userExtData); err != nil { return &errortypes.BadInput{Message: "Invalid user.ext.data."} } @@ -415,7 +416,7 @@ func setSite(request *openrtb2.BidRequest) error { if request.Site.Ext != nil { var siteExt siteExt - if err := json.Unmarshal(request.Site.Ext, &siteExt); err != nil { + if err := jsonutil.Unmarshal(request.Site.Ext, &siteExt); err != nil { return &errortypes.BadInput{Message: "Invalid site.ext."} } @@ -520,14 +521,14 @@ func setImpForAdBreak(imps []openrtb2.Imp) error { func makeImpExt(impExtRaw *json.RawMessage) (json.RawMessage, error) { var impExt openrtb_ext.ExtImpExtraDataSmaato - if err := json.Unmarshal(*impExtRaw, &impExt); err != nil { + if err := jsonutil.Unmarshal(*impExtRaw, &impExt); err != nil { return nil, &errortypes.BadInput{Message: "Invalid imp.ext."} } if impExtSkadnRaw := impExt.Skadn; impExtSkadnRaw != nil { var impExtSkadn map[string]json.RawMessage - if err := json.Unmarshal(impExtSkadnRaw, &impExtSkadn); err != nil { + if err := jsonutil.Unmarshal(impExtSkadnRaw, &impExtSkadn); err != nil { return nil, &errortypes.BadInput{Message: "Invalid imp.ext.skadn."} } } @@ -585,7 +586,7 @@ func extractBidExt(bid *openrtb2.Bid) (bidExt, error) { if bid.Ext == nil { return bidExt, nil } - if err := json.Unmarshal(bid.Ext, &bidExt); err != nil { + if err := jsonutil.Unmarshal(bid.Ext, &bidExt); err != nil { return bidExt, &errortypes.BadServerResponse{Message: "Invalid bid.ext."} } return bidExt, nil diff --git a/adapters/smartadserver/smartadserver.go b/adapters/smartadserver/smartadserver.go index f28c0f618f7..51e4fa9f20c 100644 --- a/adapters/smartadserver/smartadserver.go +++ b/adapters/smartadserver/smartadserver.go @@ -13,6 +13,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type SmartAdserverAdapter struct { @@ -61,7 +62,7 @@ func (a *SmartAdserverAdapter) MakeRequests(request *openrtb2.BidRequest, reqInf // We send one serialized "smartRequest" per impression of the original request. for _, imp := range request.Imp { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { errs = append(errs, &errortypes.BadInput{ Message: "Error parsing bidderExt object", }) @@ -69,7 +70,7 @@ func (a *SmartAdserverAdapter) MakeRequests(request *openrtb2.BidRequest, reqInf } var smartadserverExt openrtb_ext.ExtImpSmartadserver - if err := json.Unmarshal(bidderExt.Bidder, &smartadserverExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &smartadserverExt); err != nil { errs = append(errs, &errortypes.BadInput{ Message: "Error parsing smartadserverExt parameters", }) @@ -137,7 +138,7 @@ func (a *SmartAdserverAdapter) MakeBids(internalRequest *openrtb2.BidRequest, ex } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/smartadserver/smartadservertest/supplemental/response-200-without-body.json b/adapters/smartadserver/smartadservertest/supplemental/response-200-without-body.json index 87196e8c1ad..2b925662e52 100644 --- a/adapters/smartadserver/smartadservertest/supplemental/response-200-without-body.json +++ b/adapters/smartadserver/smartadservertest/supplemental/response-200-without-body.json @@ -56,8 +56,8 @@ ], "expectedMakeBidsErrors": [ { - "value": "unexpected end of JSON input", - "comparison": "literal" + "value": "expect { or n, but found", + "comparison": "startswith" } ] } diff --git a/adapters/smarthub/smarthub.go b/adapters/smarthub/smarthub.go index c170ba5dbd1..bd58c3ca04c 100644 --- a/adapters/smarthub/smarthub.go +++ b/adapters/smarthub/smarthub.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) const ( @@ -41,14 +42,14 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co func (a *adapter) getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtSmartHub, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: "Bidder extension not provided or can't be unmarshalled", } } var smarthubExt openrtb_ext.ExtSmartHub - if err := json.Unmarshal(bidderExt.Bidder, &smarthubExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &smarthubExt); err != nil { return nil, &errortypes.BadInput{ Message: "Error while unmarshaling bidder extension", } @@ -135,7 +136,7 @@ func (a *adapter) MakeBids( responseBody := bidderRawResponse.Body var bidResp openrtb2.BidResponse - if err := json.Unmarshal(responseBody, &bidResp); err != nil { + if err := jsonutil.Unmarshal(responseBody, &bidResp); err != nil { return nil, []error{err} } @@ -160,7 +161,7 @@ func (a *adapter) MakeBids( var bidExt bidExt var bidType openrtb_ext.BidType - if err := json.Unmarshal(bid.Ext, &bidExt); err != nil { + if err := jsonutil.Unmarshal(bid.Ext, &bidExt); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Field BidExt is required", }} diff --git a/adapters/smarthub/smarthubtest/supplemental/bad-response.json b/adapters/smarthub/smarthubtest/supplemental/bad-response.json index 09e5d9ab442..5911c140a05 100644 --- a/adapters/smarthub/smarthubtest/supplemental/bad-response.json +++ b/adapters/smarthub/smarthubtest/supplemental/bad-response.json @@ -101,7 +101,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ], diff --git a/adapters/smartrtb/smartrtb.go b/adapters/smartrtb/smartrtb.go index 1c5d1abb1de..ee5b3391cd2 100644 --- a/adapters/smartrtb/smartrtb.go +++ b/adapters/smartrtb/smartrtb.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) // Base adapter structure. @@ -62,14 +63,14 @@ func (adapter *SmartRTBAdapter) buildEndpointURL(pubID string) (string, error) { func parseExtImp(dst *bidRequestExt, imp *openrtb2.Imp) error { var ext adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &ext); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &ext); err != nil { return &errortypes.BadInput{ Message: err.Error(), } } var src openrtb_ext.ExtImpSmartRTB - if err := json.Unmarshal(ext.Bidder, &src); err != nil { + if err := jsonutil.Unmarshal(ext.Bidder, &src); err != nil { return &errortypes.BadInput{ Message: err.Error(), } @@ -160,7 +161,7 @@ func (s *SmartRTBAdapter) MakeBids( } var brs openrtb2.BidResponse - if err := json.Unmarshal(rs.Body, &brs); err != nil { + if err := jsonutil.Unmarshal(rs.Body, &brs); err != nil { return nil, []error{err} } @@ -168,7 +169,7 @@ func (s *SmartRTBAdapter) MakeBids( for _, seat := range brs.SeatBid { for i := range seat.Bid { var ext bidExt - if err := json.Unmarshal(seat.Bid[i].Ext, &ext); err != nil { + if err := jsonutil.Unmarshal(seat.Bid[i].Ext, &ext); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Invalid bid extension from endpoint.", }} diff --git a/adapters/smartrtb/smartrtbtest/supplemental/bad-bidder-ext.json b/adapters/smartrtb/smartrtbtest/supplemental/bad-bidder-ext.json index b261415de4d..774cd2141d6 100644 --- a/adapters/smartrtb/smartrtbtest/supplemental/bad-bidder-ext.json +++ b/adapters/smartrtb/smartrtbtest/supplemental/bad-bidder-ext.json @@ -24,8 +24,8 @@ "expectedMakeRequestsErrors": [ { - "value": "unexpected end of JSON input", - "comparison": "literal" + "value": "expect { or n, but found", + "comparison": "startswith" } ] } diff --git a/adapters/smartrtb/smartrtbtest/supplemental/bad-imp-ext.json b/adapters/smartrtb/smartrtbtest/supplemental/bad-imp-ext.json index 1c0f57d2f34..b5b77d9e57a 100644 --- a/adapters/smartrtb/smartrtbtest/supplemental/bad-imp-ext.json +++ b/adapters/smartrtb/smartrtbtest/supplemental/bad-imp-ext.json @@ -25,8 +25,8 @@ "expectedMakeRequestsErrors": [ { - "value": "unexpected end of JSON input", - "comparison": "literal" + "value": "expect { or n, but found", + "comparison": "startswith" } ] } diff --git a/adapters/smartrtb/smartrtbtest/supplemental/bad-pub-value.json b/adapters/smartrtb/smartrtbtest/supplemental/bad-pub-value.json index 93b45c747fd..cff39cc06b1 100644 --- a/adapters/smartrtb/smartrtbtest/supplemental/bad-pub-value.json +++ b/adapters/smartrtb/smartrtbtest/supplemental/bad-pub-value.json @@ -30,7 +30,7 @@ "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal number into Go struct field ExtImpSmartRTB.pub_id of type string", + "value": "cannot unmarshal PubID: expects \" or n, but found 0", "comparison": "literal" } ] diff --git a/adapters/smartrtb/smartrtbtest/supplemental/invalid-bid-json.json b/adapters/smartrtb/smartrtbtest/supplemental/invalid-bid-json.json index a8065446443..51b2ec8b794 100644 --- a/adapters/smartrtb/smartrtbtest/supplemental/invalid-bid-json.json +++ b/adapters/smartrtb/smartrtbtest/supplemental/invalid-bid-json.json @@ -70,7 +70,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/smartrtb/smartrtbtest/supplemental/invalid-imp-ext.json b/adapters/smartrtb/smartrtbtest/supplemental/invalid-imp-ext.json index 13485f797ba..743f492bba1 100644 --- a/adapters/smartrtb/smartrtbtest/supplemental/invalid-imp-ext.json +++ b/adapters/smartrtb/smartrtbtest/supplemental/invalid-imp-ext.json @@ -25,7 +25,7 @@ "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/smartx/smartx.go b/adapters/smartx/smartx.go index 9254ec0d95c..a3245908d47 100644 --- a/adapters/smartx/smartx.go +++ b/adapters/smartx/smartx.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -63,7 +64,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, _ *adapters.RequestData } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/smartyads/smartyads.go b/adapters/smartyads/smartyads.go index d00a808d025..02e3835385d 100644 --- a/adapters/smartyads/smartyads.go +++ b/adapters/smartyads/smartyads.go @@ -13,6 +13,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type SmartyAdsAdapter struct { @@ -109,13 +110,13 @@ func (a *SmartyAdsAdapter) MakeRequests( func (a *SmartyAdsAdapter) getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtSmartyAds, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: "ext.bidder not provided", } } var smartyadsExt openrtb_ext.ExtSmartyAds - if err := json.Unmarshal(bidderExt.Bidder, &smartyadsExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &smartyadsExt); err != nil { return nil, &errortypes.BadInput{ Message: "ext.bidder not provided", } @@ -169,7 +170,7 @@ func (a *SmartyAdsAdapter) MakeBids( responseBody := bidderRawResponse.Body var bidResp openrtb2.BidResponse - if err := json.Unmarshal(responseBody, &bidResp); err != nil { + if err := jsonutil.Unmarshal(responseBody, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Bad Server Response", }} diff --git a/adapters/smilewanted/smilewanted.go b/adapters/smilewanted/smilewanted.go index b17b3825540..f883043b0d6 100644 --- a/adapters/smilewanted/smilewanted.go +++ b/adapters/smilewanted/smilewanted.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -61,14 +62,14 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Bad server response: %s.", err), }} } var bidReq openrtb2.BidRequest - if err := json.Unmarshal(externalRequest.Body, &bidReq); err != nil { + if err := jsonutil.Unmarshal(externalRequest.Body, &bidReq); err != nil { return nil, []error{err} } diff --git a/adapters/smilewanted/smilewantedtest/supplemental/bad-server-response.json b/adapters/smilewanted/smilewantedtest/supplemental/bad-server-response.json index 63826e325fa..e6f59ab83a1 100644 --- a/adapters/smilewanted/smilewantedtest/supplemental/bad-server-response.json +++ b/adapters/smilewanted/smilewantedtest/supplemental/bad-server-response.json @@ -57,7 +57,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "Bad server response: json: cannot unmarshal string into Go value of type openrtb2.BidResponse.", + "value": "Bad server response: expect { or n, but found \".", "comparison": "literal" } ] diff --git a/adapters/smrtconnect/smrtconnect.go b/adapters/smrtconnect/smrtconnect.go index bd68e267eaf..410fb3152b4 100644 --- a/adapters/smrtconnect/smrtconnect.go +++ b/adapters/smrtconnect/smrtconnect.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -64,13 +65,13 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte func getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtSmrtconnect, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: "ext.bidder not provided", } } var smrtconnectExt openrtb_ext.ExtSmrtconnect - if err := json.Unmarshal(bidderExt.Bidder, &smrtconnectExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &smrtconnectExt); err != nil { return nil, &errortypes.BadInput{ Message: "ext.bidder not provided", } @@ -94,7 +95,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Bad Server Response", }} diff --git a/adapters/sonobi/sonobi.go b/adapters/sonobi/sonobi.go index afc1e5793d9..c8f0008ba12 100644 --- a/adapters/sonobi/sonobi.go +++ b/adapters/sonobi/sonobi.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) // SonobiAdapter - Sonobi SonobiAdapter definition @@ -42,12 +43,12 @@ func (a *SonobiAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adap reqCopy.Imp = append(make([]openrtb2.Imp, 0, 1), imp) var bidderExt adapters.ExtImpBidder - if err = json.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { + if err = jsonutil.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { errs = append(errs, err) continue } - if err = json.Unmarshal(bidderExt.Bidder, &sonobiExt); err != nil { + if err = jsonutil.Unmarshal(bidderExt.Bidder, &sonobiExt); err != nil { errs = append(errs, err) continue } @@ -130,7 +131,7 @@ func (a *SonobiAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalR var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/sovrn/sovrn.go b/adapters/sovrn/sovrn.go index 83ab136c963..db13db99f74 100644 --- a/adapters/sovrn/sovrn.go +++ b/adapters/sovrn/sovrn.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" "github.com/prebid/openrtb/v20/openrtb2" ) @@ -50,7 +51,7 @@ func (s *SovrnAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapt for _, imp := range request.Imp { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { errs = append(errs, &errortypes.BadInput{ Message: err.Error(), }) @@ -58,7 +59,7 @@ func (s *SovrnAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapt } var sovrnExt openrtb_ext.ExtImpSovrn - if err := json.Unmarshal(bidderExt.Bidder, &sovrnExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &sovrnExt); err != nil { errs = append(errs, &errortypes.BadInput{ Message: err.Error(), }) @@ -154,7 +155,7 @@ func (s *SovrnAdapter) MakeBids(request *openrtb2.BidRequest, bidderRequest *ada } var bidResponse openrtb2.BidResponse - if err := json.Unmarshal(bidderResponse.Body, &bidResponse); err != nil { + if err := jsonutil.Unmarshal(bidderResponse.Body, &bidResponse); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: err.Error(), }} diff --git a/adapters/sovrnXsp/sovrnXsp.go b/adapters/sovrnXsp/sovrnXsp.go index ed97697e824..9a875ae7f79 100644 --- a/adapters/sovrnXsp/sovrnXsp.go +++ b/adapters/sovrnXsp/sovrnXsp.go @@ -9,6 +9,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" "github.com/prebid/openrtb/v20/openrtb2" ) @@ -49,7 +50,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte } var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { err = &errortypes.BadInput{ Message: fmt.Sprintf("imp #%d: ext.bidder not provided", idx), } @@ -58,7 +59,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte } var xspExt openrtb_ext.ExtImpSovrnXsp - if err := json.Unmarshal(bidderExt.Bidder, &xspExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &xspExt); err != nil { err = &errortypes.BadInput{ Message: fmt.Sprintf("imp #%d: %s", idx, err.Error()), } @@ -111,7 +112,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } @@ -122,7 +123,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R for _, bid := range seatBid.Bid { bid := bid var ext bidExt - if err := json.Unmarshal(bid.Ext, &ext); err != nil { + if err := jsonutil.Unmarshal(bid.Ext, &ext); err != nil { errors = append(errors, err) continue } diff --git a/adapters/sspBC/sspbc.go b/adapters/sspBC/sspbc.go index 59dffbdfbea..80c85e32cc5 100644 --- a/adapters/sspBC/sspbc.go +++ b/adapters/sspBC/sspbc.go @@ -15,6 +15,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) const ( @@ -147,7 +148,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest } var response openrtb2.BidResponse - if err := json.Unmarshal(externalResponse.Body, &response); err != nil { + if err := jsonutil.Unmarshal(externalResponse.Body, &response); err != nil { return nil, []error{err} } @@ -192,7 +193,7 @@ func (a *adapter) impToBid(internalRequest *openrtb2.BidRequest, seatBid openrtb // read additional data from proxy var bidDataExt responseExt - if err := json.Unmarshal(bid.Ext, &bidDataExt); err != nil { + if err := jsonutil.Unmarshal(bid.Ext, &bidDataExt); err != nil { return err } /* @@ -289,8 +290,8 @@ func getBidParameters(imp openrtb2.Imp) openrtb_ext.ExtImpSspbc { var extBidder adapters.ExtImpBidder var extSSP openrtb_ext.ExtImpSspbc - if err := json.Unmarshal(imp.Ext, &extBidder); err == nil { - _ = json.Unmarshal(extBidder.Bidder, &extSSP) + if err := jsonutil.Unmarshal(imp.Ext, &extBidder); err == nil { + _ = jsonutil.Unmarshal(extBidder.Bidder, &extSSP) } return extSSP diff --git a/adapters/sspBC/sspbctest/supplemental/bad_response.json b/adapters/sspBC/sspbctest/supplemental/bad_response.json index 7859596d2f6..14f7d4ddb11 100644 --- a/adapters/sspBC/sspbctest/supplemental/bad_response.json +++ b/adapters/sspBC/sspbctest/supplemental/bad_response.json @@ -93,7 +93,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/stroeerCore/stroeercore.go b/adapters/stroeerCore/stroeercore.go index 4975c32e3b3..bc1454dcf86 100644 --- a/adapters/stroeerCore/stroeercore.go +++ b/adapters/stroeerCore/stroeercore.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -59,7 +60,7 @@ func (a *adapter) MakeBids(bidRequest *openrtb2.BidRequest, requestData *adapter var errors []error stroeerResponse := response{} - if err := json.Unmarshal(responseData.Body, &stroeerResponse); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &stroeerResponse); err != nil { errors = append(errors, err) return nil, errors } @@ -111,13 +112,13 @@ func (a *adapter) MakeRequests(bidRequest *openrtb2.BidRequest, extraRequestInfo for idx := range bidRequest.Imp { imp := &bidRequest.Imp[idx] var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { errors = append(errors, err) continue } var stroeerExt openrtb_ext.ExtImpStroeerCore - if err := json.Unmarshal(bidderExt.Bidder, &stroeerExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &stroeerExt); err != nil { errors = append(errors, err) continue } diff --git a/adapters/taboola/taboola.go b/adapters/taboola/taboola.go index 6621c78f6eb..1a4742d9e38 100644 --- a/adapters/taboola/taboola.go +++ b/adapters/taboola/taboola.go @@ -16,6 +16,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -86,7 +87,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } @@ -174,11 +175,11 @@ func createTaboolaRequests(request *openrtb2.BidRequest) (taboolaRequests []*ope imp := modifiedRequest.Imp[i] var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { errs = append(errs, err) continue } - if err := json.Unmarshal(bidderExt.Bidder, &taboolaExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &taboolaExt); err != nil { errs = append(errs, err) continue } diff --git a/adapters/taboola/taboolatest/supplemental/noValidImpression.json b/adapters/taboola/taboolatest/supplemental/noValidImpression.json index 2ecf5594817..eb3ff2ec384 100644 --- a/adapters/taboola/taboolatest/supplemental/noValidImpression.json +++ b/adapters/taboola/taboolatest/supplemental/noValidImpression.json @@ -40,7 +40,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal number into Go struct field ImpExtTaboola.publisherId of type string", + "value": "cannot unmarshal openrtb_ext.ImpExtTaboola.PublisherId: expects \" or n, but found 1", "comparison": "literal" } ] diff --git a/adapters/tappx/tappx.go b/adapters/tappx/tappx.go index e50a5089c1d..7d841283bda 100644 --- a/adapters/tappx/tappx.go +++ b/adapters/tappx/tappx.go @@ -16,6 +16,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) const TAPPX_BIDDER_VERSION = "1.5" @@ -57,13 +58,13 @@ func (a *TappxAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapt } var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(request.Imp[0].Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(request.Imp[0].Ext, &bidderExt); err != nil { return nil, []error{&errortypes.BadInput{ Message: "Error parsing bidderExt object", }} } var tappxExt openrtb_ext.ExtImpTappx - if err := json.Unmarshal(bidderExt.Bidder, &tappxExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &tappxExt); err != nil { return nil, []error{&errortypes.BadInput{ Message: "Error parsing tappxExt parameters", }} @@ -198,7 +199,7 @@ func (a *TappxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRe } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/teads/teads.go b/adapters/teads/teads.go index fbea4fcd96f..511c7cca59b 100644 --- a/adapters/teads/teads.go +++ b/adapters/teads/teads.go @@ -14,6 +14,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) // Builder builds a new instance of the Teads adapter for the given bidder with the given config. @@ -77,7 +78,7 @@ func updateImpObject(imps []openrtb2.Imp) error { } var defaultImpExt defaultBidderImpExtension - if err := json.Unmarshal(imp.Ext, &defaultImpExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &defaultImpExt); err != nil { return &errortypes.BadInput{ Message: "Error parsing Imp.Ext object", } @@ -136,7 +137,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, _ *adapters.Req } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -172,7 +173,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, _ *adapters.Req func getTeadsRendererFromBidExt(ext json.RawMessage) (*teadsBidExt, []error) { var bidExtTeads teadsBidExt - if err := json.Unmarshal(ext, &bidExtTeads); err != nil { + if err := jsonutil.Unmarshal(ext, &bidExtTeads); err != nil { return nil, []error{err} } if bidExtTeads.Prebid.Meta.RendererName == "" { diff --git a/adapters/telaria/telaria.go b/adapters/telaria/telaria.go index 3658bfdf0b7..676dc1f99eb 100644 --- a/adapters/telaria/telaria.go +++ b/adapters/telaria/telaria.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) const Endpoint = "https://ads.tremorhub.com/ad/rtb/prebid" @@ -99,7 +100,7 @@ func GetHeaders(request *openrtb2.BidRequest) *http.Header { // Checks the imp[i].ext object and returns a imp.ext object as per ExtImpTelaria format func (a *TelariaAdapter) FetchTelariaExtImpParams(imp *openrtb2.Imp) (*openrtb_ext.ExtImpTelaria, error) { var bidderExt adapters.ExtImpBidder - err := json.Unmarshal(imp.Ext, &bidderExt) + err := jsonutil.Unmarshal(imp.Ext, &bidderExt) if err != nil { err = &errortypes.BadInput{ @@ -110,7 +111,7 @@ func (a *TelariaAdapter) FetchTelariaExtImpParams(imp *openrtb2.Imp) (*openrtb_e } var telariaExt openrtb_ext.ExtImpTelaria - err = json.Unmarshal(bidderExt.Bidder, &telariaExt) + err = jsonutil.Unmarshal(bidderExt.Bidder, &telariaExt) if err != nil { return nil, err @@ -271,7 +272,7 @@ func (a *TelariaAdapter) MakeBids(internalRequest *openrtb2.BidRequest, external responseBody := response.Body var bidResp openrtb2.BidResponse - if err := json.Unmarshal(responseBody, &bidResp); err != nil { + if err := jsonutil.Unmarshal(responseBody, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Telaria: Bad Server Response", }} diff --git a/adapters/theadx/theadx.go b/adapters/theadx/theadx.go index 48af365f105..329f556b62a 100644 --- a/adapters/theadx/theadx.go +++ b/adapters/theadx/theadx.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -52,7 +53,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte for _, imp := range request.Imp { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { errors = append(errors, &errortypes.BadInput{ Message: err.Error(), }) @@ -60,7 +61,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte } var theadxImpExt openrtb_ext.ExtImpTheadx - if err := json.Unmarshal(bidderExt.Bidder, &theadxImpExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &theadxImpExt); err != nil { errors = append(errors, &errortypes.BadInput{ Message: err.Error(), }) @@ -110,7 +111,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } @@ -137,7 +138,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) { if bid.Ext != nil { var bidExt openrtb_ext.ExtBid - err := json.Unmarshal(bid.Ext, &bidExt) + err := jsonutil.Unmarshal(bid.Ext, &bidExt) if err == nil && bidExt.Prebid != nil { return openrtb_ext.ParseBidType(string(bidExt.Prebid.Type)) } diff --git a/adapters/theadx/theadxtest/supplemental/unparsable-response.json b/adapters/theadx/theadxtest/supplemental/unparsable-response.json index db9c246e15a..fa74cfdc989 100644 --- a/adapters/theadx/theadxtest/supplemental/unparsable-response.json +++ b/adapters/theadx/theadxtest/supplemental/unparsable-response.json @@ -43,7 +43,7 @@ "expectedBidResponses": [], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/thetradedesk/thetradedesk.go b/adapters/thetradedesk/thetradedesk.go index 1ef48a70d4f..fa969d223d3 100644 --- a/adapters/thetradedesk/thetradedesk.go +++ b/adapters/thetradedesk/thetradedesk.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" "github.com/prebid/openrtb/v20/openrtb2" ) @@ -103,12 +104,12 @@ func getPublisherId(impressions []openrtb2.Imp) (string, error) { for _, imp := range impressions { var bidderExt ExtImpBidderTheTradeDesk - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return "", err } var ttdExt openrtb_ext.ExtImpTheTradeDesk - if err := json.Unmarshal(bidderExt.Bidder, &ttdExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &ttdExt); err != nil { return "", err } @@ -129,7 +130,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest } var bidResponse openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResponse); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResponse); err != nil { return nil, []error{err} } diff --git a/adapters/thetradedesk/thetradedesktest/supplemental/200-response-from-target.json b/adapters/thetradedesk/thetradedesktest/supplemental/200-response-from-target.json index 9769f0499c3..fdbe15ac48e 100644 --- a/adapters/thetradedesk/thetradedesktest/supplemental/200-response-from-target.json +++ b/adapters/thetradedesk/thetradedesktest/supplemental/200-response-from-target.json @@ -98,8 +98,8 @@ ], "expectedMakeBidsErrors": [ { - "value": "unexpected end of JSON input", - "comparison": "literal" + "value": "expect { or n, but found", + "comparison": "startswith" } ] } diff --git a/adapters/thetradedesk/thetradedesktest/supplemental/invalid-publisher.json b/adapters/thetradedesk/thetradedesktest/supplemental/invalid-publisher.json index 9e936f38f20..9e2426d79b2 100644 --- a/adapters/thetradedesk/thetradedesktest/supplemental/invalid-publisher.json +++ b/adapters/thetradedesk/thetradedesktest/supplemental/invalid-publisher.json @@ -37,7 +37,7 @@ "httpCalls": [], "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal number into Go struct field ExtImpTheTradeDesk.publisherId of type string", + "value": "cannot unmarshal openrtb_ext.ExtImpTheTradeDesk.PublisherId: expects \" or n, but found 1", "comparison": "literal" } ] diff --git a/adapters/tpmn/tpmn.go b/adapters/tpmn/tpmn.go index 77357866a6a..e91e8e9ed89 100644 --- a/adapters/tpmn/tpmn.go +++ b/adapters/tpmn/tpmn.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) // TpmnAdapter struct @@ -83,7 +84,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, _ *adapters.RequestData } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{fmt.Errorf("bid response unmarshal: %v", err)} } diff --git a/adapters/tpmn/tpmntest/supplemental/bad_response.json b/adapters/tpmn/tpmntest/supplemental/bad_response.json index 21ebfb968c7..c8096e9df2a 100644 --- a/adapters/tpmn/tpmntest/supplemental/bad_response.json +++ b/adapters/tpmn/tpmntest/supplemental/bad_response.json @@ -81,7 +81,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "bid response unmarshal: json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "bid response unmarshal: expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/tpmn/tpmntest/supplemental/no-imp-ext.json b/adapters/tpmn/tpmntest/supplemental/no-imp-ext.json index a22f0a16d12..9bb91e4c167 100644 --- a/adapters/tpmn/tpmntest/supplemental/no-imp-ext.json +++ b/adapters/tpmn/tpmntest/supplemental/no-imp-ext.json @@ -74,7 +74,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "bid response unmarshal: json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "bid response unmarshal: expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/trafficgate/trafficgate.go b/adapters/trafficgate/trafficgate.go index 24e8be20c6c..5f313c90fc6 100644 --- a/adapters/trafficgate/trafficgate.go +++ b/adapters/trafficgate/trafficgate.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -91,7 +92,7 @@ func (a *adapter) MakeBids( var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: err.Error(), }} @@ -103,7 +104,7 @@ func (a *adapter) MakeBids( for _, seatBid := range bidResp.SeatBid { for i := range seatBid.Bid { var bidExt BidResponseExt - if err := json.Unmarshal(seatBid.Bid[i].Ext, &bidExt); err != nil { + if err := jsonutil.Unmarshal(seatBid.Bid[i].Ext, &bidExt); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Missing response ext", }} @@ -141,13 +142,13 @@ func splitImpressions(imps []openrtb2.Imp) (map[openrtb_ext.ExtImpTrafficGate][] func getBidderParams(imp *openrtb2.Imp) (*openrtb_ext.ExtImpTrafficGate, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: "Missing bidder ext", } } var TrafficGateExt openrtb_ext.ExtImpTrafficGate - if err := json.Unmarshal(bidderExt.Bidder, &TrafficGateExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &TrafficGateExt); err != nil { return nil, &errortypes.BadInput{ Message: "Bidder parameters required", } diff --git a/adapters/trafficgate/trafficgatetest/supplemental/bad_response.json b/adapters/trafficgate/trafficgatetest/supplemental/bad_response.json index e4177fd79ea..64cccbf6905 100644 --- a/adapters/trafficgate/trafficgatetest/supplemental/bad_response.json +++ b/adapters/trafficgate/trafficgatetest/supplemental/bad_response.json @@ -81,7 +81,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/triplelift/triplelift.go b/adapters/triplelift/triplelift.go index 773048fc32e..d2a80ff7c5c 100644 --- a/adapters/triplelift/triplelift.go +++ b/adapters/triplelift/triplelift.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type TripleliftAdapter struct { @@ -36,10 +37,10 @@ func processImp(imp *openrtb2.Imp) error { // get the triplelift extension var ext adapters.ExtImpBidder var tlext openrtb_ext.ExtImpTriplelift - if err := json.Unmarshal(imp.Ext, &ext); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &ext); err != nil { return err } - if err := json.Unmarshal(ext.Bidder, &tlext); err != nil { + if err := jsonutil.Unmarshal(ext.Bidder, &tlext); err != nil { return err } if imp.Banner == nil && imp.Video == nil { @@ -118,7 +119,7 @@ func (a *TripleliftAdapter) MakeBids(internalRequest *openrtb2.BidRequest, exter return nil, []error{fmt.Errorf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode)} } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } var errs []error @@ -129,7 +130,7 @@ func (a *TripleliftAdapter) MakeBids(internalRequest *openrtb2.BidRequest, exter for i := 0; i < len(sb.Bid); i++ { bid := sb.Bid[i] var bidExt TripleliftRespExt - if err := json.Unmarshal(bid.Ext, &bidExt); err != nil { + if err := jsonutil.Unmarshal(bid.Ext, &bidExt); err != nil { errs = append(errs, err) } else { bidType := getBidType(bidExt) diff --git a/adapters/triplelift/triplelifttest/supplemental/badext.json b/adapters/triplelift/triplelifttest/supplemental/badext.json index a36454c86d8..7c4b8190faf 100644 --- a/adapters/triplelift/triplelifttest/supplemental/badext.json +++ b/adapters/triplelift/triplelifttest/supplemental/badext.json @@ -1,7 +1,7 @@ { "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "value": "expect { or n, but found \"", "comparison": "literal" }, { diff --git a/adapters/triplelift/triplelifttest/supplemental/badextbidder.json b/adapters/triplelift/triplelifttest/supplemental/badextbidder.json index 744de84d45d..c5b0c1fcbed 100644 --- a/adapters/triplelift/triplelifttest/supplemental/badextbidder.json +++ b/adapters/triplelift/triplelifttest/supplemental/badextbidder.json @@ -1,7 +1,7 @@ { "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb_ext.ExtImpTriplelift", + "value": "expect { or n, but found \"", "comparison": "literal" }, { diff --git a/adapters/triplelift/triplelifttest/supplemental/badresponseext.json b/adapters/triplelift/triplelifttest/supplemental/badresponseext.json index 881ead4da6f..3c217f64f4e 100644 --- a/adapters/triplelift/triplelifttest/supplemental/badresponseext.json +++ b/adapters/triplelift/triplelifttest/supplemental/badresponseext.json @@ -97,7 +97,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type triplelift.TripleliftRespExt", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/triplelift_native/triplelift_native.go b/adapters/triplelift_native/triplelift_native.go index 57d5f2d7c2f..ddd4183848b 100644 --- a/adapters/triplelift_native/triplelift_native.go +++ b/adapters/triplelift_native/triplelift_native.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type TripleliftNativeAdapter struct { @@ -51,10 +52,10 @@ func processImp(imp *openrtb2.Imp, request *openrtb2.BidRequest) error { var ext ExtImp var tlext openrtb_ext.ExtImpTriplelift - if err := json.Unmarshal(imp.Ext, &ext); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &ext); err != nil { return err } - if err := json.Unmarshal(ext.Bidder, &tlext); err != nil { + if err := jsonutil.Unmarshal(ext.Bidder, &tlext); err != nil { return err } if imp.Native == nil { @@ -91,7 +92,7 @@ func effectivePubID(pub *openrtb2.Publisher) string { if pub != nil { if pub.Ext != nil { var pubExt openrtb_ext.ExtPublisher - err := json.Unmarshal(pub.Ext, &pubExt) + err := jsonutil.Unmarshal(pub.Ext, &pubExt) if err == nil && pubExt.Prebid != nil && pubExt.Prebid.ParentAccount != nil && *pubExt.Prebid.ParentAccount != "" { return *pubExt.Prebid.ParentAccount } @@ -178,7 +179,7 @@ func (a *TripleliftNativeAdapter) MakeBids(internalRequest *openrtb2.BidRequest, return nil, []error{&errortypes.BadServerResponse{Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode)}} } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } var errs []error @@ -225,7 +226,7 @@ func getExtraInfo(v string) (TripleliftNativeExtInfo, error) { } var extraInfo TripleliftNativeExtInfo - if err := json.Unmarshal([]byte(v), &extraInfo); err != nil { + if err := jsonutil.Unmarshal([]byte(v), &extraInfo); err != nil { return extraInfo, fmt.Errorf("invalid extra info: %v", err) } diff --git a/adapters/triplelift_native/triplelift_nativetest/supplemental/badext.json b/adapters/triplelift_native/triplelift_nativetest/supplemental/badext.json index f43deb8b7c5..eb2d6a1e19d 100644 --- a/adapters/triplelift_native/triplelift_nativetest/supplemental/badext.json +++ b/adapters/triplelift_native/triplelift_nativetest/supplemental/badext.json @@ -1,7 +1,7 @@ { "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type triplelift_native.ExtImp", + "value": "expect { or n, but found \"", "comparison": "literal" }, { diff --git a/adapters/triplelift_native/triplelift_nativetest/supplemental/badextbidder.json b/adapters/triplelift_native/triplelift_nativetest/supplemental/badextbidder.json index 59ebe048b19..deb9dfce308 100644 --- a/adapters/triplelift_native/triplelift_nativetest/supplemental/badextbidder.json +++ b/adapters/triplelift_native/triplelift_nativetest/supplemental/badextbidder.json @@ -1,7 +1,7 @@ { "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb_ext.ExtImpTriplelift", + "value": "expect { or n, but found \"", "comparison": "literal" }, { diff --git a/adapters/trustedstack/trustedstack.go b/adapters/trustedstack/trustedstack.go index f79f43ffe35..3c32f043d3b 100644 --- a/adapters/trustedstack/trustedstack.go +++ b/adapters/trustedstack/trustedstack.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -48,7 +49,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/trustedstack/trustedstacktest/supplemental/valid-req-200-incorrect-response-format.json b/adapters/trustedstack/trustedstacktest/supplemental/valid-req-200-incorrect-response-format.json index c2cf9a06110..2852d8a2443 100644 --- a/adapters/trustedstack/trustedstacktest/supplemental/valid-req-200-incorrect-response-format.json +++ b/adapters/trustedstack/trustedstacktest/supplemental/valid-req-200-incorrect-response-format.json @@ -114,7 +114,7 @@ "expectedBidResponses": [], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go struct field Bid.seatbid.bid.price of type float64", + "value": "cannot unmarshal openrtb2.Bid.Price: invalid number", "comparison": "literal" } ] diff --git a/adapters/ucfunnel/ucfunnel.go b/adapters/ucfunnel/ucfunnel.go index f74e79bddcf..c3f5445a73a 100644 --- a/adapters/ucfunnel/ucfunnel.go +++ b/adapters/ucfunnel/ucfunnel.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type UcfunnelAdapter struct { @@ -44,12 +45,12 @@ func (a *UcfunnelAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externa var errs []error var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } var bidReq openrtb2.BidRequest - if err := json.Unmarshal(externalRequest.Body, &bidReq); err != nil { + if err := jsonutil.Unmarshal(externalRequest.Body, &bidReq); err != nil { return nil, []error{err} } @@ -105,7 +106,7 @@ func (a *UcfunnelAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ad func getPartnerId(request *openrtb2.BidRequest) (string, []error) { var ext ExtBidderUcfunnel var errs = []error{} - err := json.Unmarshal(request.Imp[0].Ext, &ext) + err := jsonutil.Unmarshal(request.Imp[0].Ext, &ext) if err != nil { errs = append(errs, err) return "", errs diff --git a/adapters/undertone/undertone.go b/adapters/undertone/undertone.go index f3b48e33eab..82928b40d7e 100644 --- a/adapters/undertone/undertone.go +++ b/adapters/undertone/undertone.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) const adapterId = 4 @@ -88,7 +89,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } @@ -165,7 +166,7 @@ func getImpsAndPublisherId(bidRequest *openrtb2.BidRequest) ([]openrtb2.Imp, int for _, imp := range bidRequest.Imp { var ext impExt - if err := json.Unmarshal(imp.Ext, &ext); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &ext); err != nil { errs = append(errs, getInvalidImpErr(imp.ID, err)) continue } diff --git a/adapters/unicorn/unicorn.go b/adapters/unicorn/unicorn.go index 21864d3d492..1bddf252c21 100644 --- a/adapters/unicorn/unicorn.go +++ b/adapters/unicorn/unicorn.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -51,7 +52,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte Message: "COPPA is not supported", }} } - if err := json.Unmarshal(request.Regs.Ext, &extRegs); err == nil { + if err := jsonutil.Unmarshal(request.Regs.Ext, &extRegs); err == nil { if extRegs.GDPR != nil && (*extRegs.GDPR == 1) { return nil, []error{&errortypes.BadInput{ Message: "GDPR is not supported", @@ -132,7 +133,7 @@ func modifyImps(request *openrtb2.BidRequest) error { imp := &request.Imp[i] var ext unicornImpExt - err := json.Unmarshal(imp.Ext, &ext) + err := jsonutil.Unmarshal(imp.Ext, &ext) if err != nil { return &errortypes.BadInput{ @@ -214,7 +215,7 @@ func setExt(request *openrtb2.BidRequest) (json.RawMessage, error) { } var decodedExt *unicornExt - err = json.Unmarshal(request.Ext, &decodedExt) + err = jsonutil.Unmarshal(request.Ext, &decodedExt) if err != nil { decodedExt = &unicornExt{ Prebid: nil, @@ -253,7 +254,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/unicorn/unicorntest/supplemental/cannot-parse-accountid.json b/adapters/unicorn/unicorntest/supplemental/cannot-parse-accountid.json index 9ece314b485..93f038e2a0e 100644 --- a/adapters/unicorn/unicorntest/supplemental/cannot-parse-accountid.json +++ b/adapters/unicorn/unicorntest/supplemental/cannot-parse-accountid.json @@ -68,8 +68,8 @@ }, "expectedMakeRequestsErrors": [ { - "value": "Error while decoding imp[0].ext: json: cannot unmarshal string into Go struct field ExtImpUnicorn.bidder.accountId of type int", - "comparison": "literal" + "value": "Error while decoding imp[0].ext: cannot unmarshal openrtb_ext.ExtImpUnicorn.AccountID: unexpected character", + "comparison": "startswith" } ] } diff --git a/adapters/unicorn/unicorntest/supplemental/no-imp-ext.json b/adapters/unicorn/unicorntest/supplemental/no-imp-ext.json index bab6e8d9603..4acfc734f97 100644 --- a/adapters/unicorn/unicorntest/supplemental/no-imp-ext.json +++ b/adapters/unicorn/unicorntest/supplemental/no-imp-ext.json @@ -55,8 +55,8 @@ }, "expectedMakeRequestsErrors": [ { - "value": "Error while decoding imp[0].ext: unexpected end of JSON input", - "comparison": "literal" + "value": "Error while decoding imp[0].ext: expect { or n, but found", + "comparison": "startswith" } ] } diff --git a/adapters/unruly/unruly.go b/adapters/unruly/unruly.go index 97fc2b64a94..3c557c719f5 100644 --- a/adapters/unruly/unruly.go +++ b/adapters/unruly/unruly.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -55,7 +56,7 @@ func (a *adapter) preProcess(req *openrtb2.BidRequest, errors []error) (*openrtb for i := 0; i < numRequests; i++ { imp := req.Imp[i] var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { err = &errortypes.BadInput{ Message: fmt.Sprintf("ext data not provided in imp id=%s. Abort all Request", imp.ID), } @@ -63,7 +64,7 @@ func (a *adapter) preProcess(req *openrtb2.BidRequest, errors []error) (*openrtb return nil, errors } var unrulyExt openrtb_ext.ExtImpUnruly - if err := json.Unmarshal(bidderExt.Bidder, &unrulyExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &unrulyExt); err != nil { err = &errortypes.BadInput{ Message: fmt.Sprintf("siteid not provided in imp id=%s. Abort all Request", imp.ID), } @@ -107,7 +108,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest }} } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("bad server response: %d. ", err), }} diff --git a/adapters/vidazoo/vidazoo.go b/adapters/vidazoo/vidazoo.go index e2fc9959486..cae49724f80 100644 --- a/adapters/vidazoo/vidazoo.go +++ b/adapters/vidazoo/vidazoo.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -90,7 +91,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("bad server response: %d. ", err), }} @@ -121,12 +122,12 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R func extractCid(imp *openrtb2.Imp) (string, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return "", fmt.Errorf("unmarshal bidderExt: %w", err) } var impExt openrtb_ext.ImpExtVidazoo - if err := json.Unmarshal(bidderExt.Bidder, &impExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &impExt); err != nil { return "", fmt.Errorf("unmarshal ImpExtVidazoo: %w", err) } return strings.TrimSpace(impExt.ConnectionId), nil diff --git a/adapters/videobyte/videobyte.go b/adapters/videobyte/videobyte.go index d9e2d4e4be2..b9b943b0a0e 100644 --- a/adapters/videobyte/videobyte.go +++ b/adapters/videobyte/videobyte.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" "github.com/prebid/openrtb/v20/openrtb2" ) @@ -75,7 +76,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest } var ortbResponse openrtb2.BidResponse - err := json.Unmarshal(response.Body, &ortbResponse) + err := jsonutil.Unmarshal(response.Body, &ortbResponse) if err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Bad Server Response", @@ -141,14 +142,14 @@ func getHeaders(request *openrtb2.BidRequest) http.Header { func parseExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpVideoByte, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("Ignoring imp id=%s, error while decoding extImpBidder, err: %s", imp.ID, err), } } impExt := openrtb_ext.ExtImpVideoByte{} - err := json.Unmarshal(bidderExt.Bidder, &impExt) + err := jsonutil.Unmarshal(bidderExt.Bidder, &impExt) if err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("Ignoring imp id=%s, error while decoding impExt, err: %s", imp.ID, err), diff --git a/adapters/videobyte/videobytetest/supplemental/invalid-imp-ext-bidder.json b/adapters/videobyte/videobytetest/supplemental/invalid-imp-ext-bidder.json index 1b806ed57ab..d7d8460bb1b 100644 --- a/adapters/videobyte/videobytetest/supplemental/invalid-imp-ext-bidder.json +++ b/adapters/videobyte/videobytetest/supplemental/invalid-imp-ext-bidder.json @@ -38,7 +38,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "Ignoring imp id=test-imp-id, error while decoding impExt, err: json: cannot unmarshal string into Go value of type openrtb_ext.ExtImpVideoByte", + "value": "Ignoring imp id=test-imp-id, error while decoding impExt, err: expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/videobyte/videobytetest/supplemental/invalid-imp-ext.json b/adapters/videobyte/videobytetest/supplemental/invalid-imp-ext.json index 199f4c5570c..a24ea9b924f 100644 --- a/adapters/videobyte/videobytetest/supplemental/invalid-imp-ext.json +++ b/adapters/videobyte/videobytetest/supplemental/invalid-imp-ext.json @@ -36,7 +36,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "Ignoring imp id=test-imp-id, error while decoding extImpBidder, err: json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "value": "Ignoring imp id=test-imp-id, error while decoding extImpBidder, err: expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/videoheroes/videoheroes.go b/adapters/videoheroes/videoheroes.go index 89bbb9c8162..f20b3878d05 100755 --- a/adapters/videoheroes/videoheroes.go +++ b/adapters/videoheroes/videoheroes.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -67,13 +68,13 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte func (a *adapter) getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpVideoHeroes, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: "ext.bidder not provided", } } var videoHeroesExt openrtb_ext.ExtImpVideoHeroes - if err := json.Unmarshal(bidderExt.Bidder, &videoHeroesExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &videoHeroesExt); err != nil { return nil, &errortypes.BadInput{ Message: "ext.bidder not provided", } @@ -118,7 +119,7 @@ func (a *adapter) MakeBids( } var bidResponse openrtb2.BidResponse - if err := json.Unmarshal(bidderResponse.Body, &bidResponse); err != nil { + if err := jsonutil.Unmarshal(bidderResponse.Body, &bidResponse); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Bad Server Response", }} diff --git a/adapters/vidoomy/vidoomy.go b/adapters/vidoomy/vidoomy.go index d5538019a3e..c4748773e1a 100644 --- a/adapters/vidoomy/vidoomy.go +++ b/adapters/vidoomy/vidoomy.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" "github.com/prebid/prebid-server/v2/util/ptrutil" ) @@ -117,7 +118,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Bad server response: %d.", err), }} diff --git a/adapters/visiblemeasures/visiblemeasures.go b/adapters/visiblemeasures/visiblemeasures.go index 4a461d2d8f7..980ae7b86b4 100644 --- a/adapters/visiblemeasures/visiblemeasures.go +++ b/adapters/visiblemeasures/visiblemeasures.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -44,10 +45,10 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E var bidderExt adapters.ExtImpBidder var visiblemeasuresExt openrtb_ext.ImpExtVisibleMeasures - if err = json.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { + if err = jsonutil.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { return nil, []error{err} } - if err = json.Unmarshal(bidderExt.Bidder, &visiblemeasuresExt); err != nil { + if err = jsonutil.Unmarshal(bidderExt.Bidder, &visiblemeasuresExt); err != nil { return nil, []error{err} } @@ -111,7 +112,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/visiblemeasures/visiblemeasurestest/supplemental/bad_response.json b/adapters/visiblemeasures/visiblemeasurestest/supplemental/bad_response.json index c732ba92c67..5cc4a338ac3 100644 --- a/adapters/visiblemeasures/visiblemeasurestest/supplemental/bad_response.json +++ b/adapters/visiblemeasures/visiblemeasurestest/supplemental/bad_response.json @@ -78,7 +78,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/visx/visx.go b/adapters/visx/visx.go index 2cd3dfc5370..c486c66b819 100644 --- a/adapters/visx/visx.go +++ b/adapters/visx/visx.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type VisxAdapter struct { @@ -107,7 +108,7 @@ func (a *VisxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalReq } var bidResp visxResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -146,7 +147,7 @@ func getMediaTypeForImp(impID string, imps []openrtb2.Imp, bid visxBid) (openrtb for _, imp := range imps { if imp.ID == impID { var ext visxBidExt - if err := json.Unmarshal(bid.Ext, &ext); err == nil { + if err := jsonutil.Unmarshal(bid.Ext, &ext); err == nil { if ext.Prebid.Meta.MediaType == openrtb_ext.BidTypeBanner { return openrtb_ext.BidTypeBanner, nil } diff --git a/adapters/visx/visxtest/supplemental/bad_response.json b/adapters/visx/visxtest/supplemental/bad_response.json index e905068b7ea..21da96d8783 100644 --- a/adapters/visx/visxtest/supplemental/bad_response.json +++ b/adapters/visx/visxtest/supplemental/bad_response.json @@ -56,7 +56,7 @@ "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type visx.visxResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/vox/vox.go b/adapters/vox/vox.go index 1a04d1fbf72..c64cbd3485e 100644 --- a/adapters/vox/vox.go +++ b/adapters/vox/vox.go @@ -8,6 +8,7 @@ import ( "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -47,7 +48,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/vrtcal/vrtcal.go b/adapters/vrtcal/vrtcal.go index 0f6f27eb23b..8c28f5c146b 100644 --- a/adapters/vrtcal/vrtcal.go +++ b/adapters/vrtcal/vrtcal.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type VrtcalAdapter struct { @@ -63,7 +64,7 @@ func (a *VrtcalAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalR var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/vungle/vungle.go b/adapters/vungle/vungle.go index 9d479b81e31..f3473719ecd 100644 --- a/adapters/vungle/vungle.go +++ b/adapters/vungle/vungle.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) const SupportedCurrency = "USD" @@ -52,14 +53,14 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte } var impExt vungleImpressionExt - if err := json.Unmarshal(imp.Ext, &impExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &impExt); err != nil { errs = append(errs, fmt.Errorf("failed unmarshalling imp ext (err)%s", err.Error())) continue } // get placement_reference_id & pub_app_store_id var bidderImpExt openrtb_ext.ImpExtVungle - if err := json.Unmarshal(impExt.Bidder, &bidderImpExt); err != nil { + if err := jsonutil.Unmarshal(impExt.Bidder, &bidderImpExt); err != nil { errs = append(errs, fmt.Errorf("failed unmarshalling bidder imp ext (err)%s", err.Error())) continue } @@ -127,7 +128,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/xeworks/xeworks.go b/adapters/xeworks/xeworks.go index 458087ece23..832e1ca7af0 100644 --- a/adapters/xeworks/xeworks.go +++ b/adapters/xeworks/xeworks.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type bidType struct { @@ -41,14 +42,14 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co func (a *adapter) buildEndpointFromRequest(imp *openrtb2.Imp) (string, error) { var impExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &impExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &impExt); err != nil { return "", &errortypes.BadInput{ Message: fmt.Sprintf("Failed to deserialize bidder impression extension: %v", err), } } var xeworksExt openrtb_ext.ExtXeworks - if err := json.Unmarshal(impExt.Bidder, &xeworksExt); err != nil { + if err := jsonutil.Unmarshal(impExt.Bidder, &xeworksExt); err != nil { return "", &errortypes.BadInput{ Message: fmt.Sprintf("Failed to deserialize Xeworks extension: %v", err), } @@ -116,7 +117,7 @@ func (a *adapter) MakeBids(openRTBRequest *openrtb2.BidRequest, requestToBidder } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(bidderRawResponse.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(bidderRawResponse.Body, &bidResp); err != nil { return nil, []error{err} } @@ -136,7 +137,7 @@ func prepareBidResponse(seats []openrtb2.SeatBid) (*adapters.BidderResponse, []e for _, seatBid := range seats { for bidId, bid := range seatBid.Bid { var bidExt bidExt - if err := json.Unmarshal(bid.Ext, &bidExt); err != nil { + if err := jsonutil.Unmarshal(bid.Ext, &bidExt); err != nil { errs = append(errs, &errortypes.BadServerResponse{ Message: fmt.Sprintf("Failed to parse Bid[%d].Ext: %s", bidId, err.Error()), }) diff --git a/adapters/xeworks/xeworkstest/supplemental/bad-response.json b/adapters/xeworks/xeworkstest/supplemental/bad-response.json index e91040e9799..ecfa343be36 100644 --- a/adapters/xeworks/xeworkstest/supplemental/bad-response.json +++ b/adapters/xeworks/xeworkstest/supplemental/bad-response.json @@ -99,7 +99,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ], diff --git a/adapters/xeworks/xeworkstest/supplemental/invalid-ext-bidder-object.json b/adapters/xeworks/xeworkstest/supplemental/invalid-ext-bidder-object.json index fe7fd9c8b19..77347bfd3d7 100644 --- a/adapters/xeworks/xeworkstest/supplemental/invalid-ext-bidder-object.json +++ b/adapters/xeworks/xeworkstest/supplemental/invalid-ext-bidder-object.json @@ -42,7 +42,7 @@ "httpCalls": [], "expectedMakeRequestsErrors": [ { - "value": "Failed to deserialize Xeworks extension: json: cannot unmarshal array into Go value of type openrtb_ext.ExtXeworks", + "value": "Failed to deserialize Xeworks extension: expect { or n, but found [", "comparison": "literal" } ] diff --git a/adapters/xeworks/xeworkstest/supplemental/invalid-ext-object.json b/adapters/xeworks/xeworkstest/supplemental/invalid-ext-object.json index aa215eb3e34..16cf58bbe54 100644 --- a/adapters/xeworks/xeworkstest/supplemental/invalid-ext-object.json +++ b/adapters/xeworks/xeworkstest/supplemental/invalid-ext-object.json @@ -40,7 +40,7 @@ "httpCalls": [], "expectedMakeRequestsErrors": [ { - "value": "Failed to deserialize bidder impression extension: json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "value": "Failed to deserialize bidder impression extension: expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/yahooAds/yahooAds.go b/adapters/yahooAds/yahooAds.go index dddeddcce21..3ebf061b297 100644 --- a/adapters/yahooAds/yahooAds.go +++ b/adapters/yahooAds/yahooAds.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" "github.com/prebid/prebid-server/v2/util/ptrutil" ) @@ -33,7 +34,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E for idx, imp := range request.Imp { var bidderExt adapters.ExtImpBidder - err := json.Unmarshal(imp.Ext, &bidderExt) + err := jsonutil.Unmarshal(imp.Ext, &bidderExt) if err != nil { err = &errortypes.BadInput{ Message: fmt.Sprintf("imp #%d: ext.bidder not provided", idx), @@ -43,7 +44,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E } var yahooAdsExt openrtb_ext.ExtImpYahooAds - err = json.Unmarshal(bidderExt.Bidder, &yahooAdsExt) + err = jsonutil.Unmarshal(bidderExt.Bidder, &yahooAdsExt) if err != nil { err = &errortypes.BadInput{ Message: fmt.Sprintf("imp #%d: %s", idx, err.Error()), @@ -101,7 +102,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Bad server response: %d.", err), }} @@ -177,7 +178,7 @@ func changeRequestForBidService(request *openrtb2.BidRequest, extension *openrtb requestRegs.Ext = json.RawMessage("{}") } var regsExt map[string]json.RawMessage - err := json.Unmarshal(requestRegs.Ext, ®sExt) + err := jsonutil.Unmarshal(requestRegs.Ext, ®sExt) if err != nil { return err } diff --git a/adapters/yandex/yandex.go b/adapters/yandex/yandex.go index 7d40dc85a7a..ae8dd8b5bd5 100644 --- a/adapters/yandex/yandex.go +++ b/adapters/yandex/yandex.go @@ -15,6 +15,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) const ( @@ -131,14 +132,14 @@ func splitRequestDataByImp(request *openrtb2.BidRequest, imp openrtb2.Imp) openr func getYandexPlacementId(imp openrtb2.Imp) (*yandexPlacementID, error) { var ext adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &ext); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &ext); err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("imp %s: unable to unmarshal ext", imp.ID), } } var yandexExt openrtb_ext.ExtImpYandex - if err := json.Unmarshal(ext.Bidder, &yandexExt); err != nil { + if err := jsonutil.Unmarshal(ext.Bidder, &yandexExt); err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("imp %s: unable to unmarshal ext.bidder: %v", imp.ID, err), } @@ -280,7 +281,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, _ *adapters.RequestData } var bidResponse openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &bidResponse); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &bidResponse); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Bad server response: %d", err), }} diff --git a/adapters/yeahmobi/yeahmobi.go b/adapters/yeahmobi/yeahmobi.go index b533e76b19a..09fc2ba27ab 100644 --- a/adapters/yeahmobi/yeahmobi.go +++ b/adapters/yeahmobi/yeahmobi.go @@ -13,6 +13,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -85,7 +86,7 @@ func transform(request *openrtb2.BidRequest) { if imp.Native != nil { var nativeRequest map[string]interface{} nativeCopyRequest := make(map[string]interface{}) - err := json.Unmarshal([]byte(request.Imp[i].Native.Request), &nativeRequest) + err := jsonutil.Unmarshal([]byte(request.Imp[i].Native.Request), &nativeRequest) //just ignore the bad native request if err == nil { _, exists := nativeRequest["native"] @@ -114,12 +115,12 @@ func getYeahmobiExt(request *openrtb2.BidRequest) (*openrtb_ext.ExtImpYeahmobi, for _, imp := range request.Imp { var extBidder adapters.ExtImpBidder - err := json.Unmarshal(imp.Ext, &extBidder) + err := jsonutil.Unmarshal(imp.Ext, &extBidder) if err != nil { errs = append(errs, err) continue } - err = json.Unmarshal(extBidder.Bidder, &extImpYeahmobi) + err = jsonutil.Unmarshal(extBidder.Bidder, &extImpYeahmobi) if err != nil { errs = append(errs, err) continue @@ -151,7 +152,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest }} } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } bidResponse := adapters.NewBidderResponseWithBidsCapacity(1) @@ -166,7 +167,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest } if bid.Ext != nil { var bidExt *yeahmobiBidExt - err := json.Unmarshal(bid.Ext, &bidExt) + err := jsonutil.Unmarshal(bid.Ext, &bidExt) if err != nil { return nil, []error{fmt.Errorf("bid.ext json unmarshal error")} } else if bidExt != nil { diff --git a/adapters/yeahmobi/yeahmobitest/supplemental/bad_imp_ext.json b/adapters/yeahmobi/yeahmobitest/supplemental/bad_imp_ext.json index 444e1e7a8d8..782f7a0c3b4 100644 --- a/adapters/yeahmobi/yeahmobitest/supplemental/bad_imp_ext.json +++ b/adapters/yeahmobi/yeahmobitest/supplemental/bad_imp_ext.json @@ -14,7 +14,7 @@ "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/yeahmobi/yeahmobitest/supplemental/bad_imp_ext_bidder.json b/adapters/yeahmobi/yeahmobitest/supplemental/bad_imp_ext_bidder.json index 89697d37141..da9dce00905 100644 --- a/adapters/yeahmobi/yeahmobitest/supplemental/bad_imp_ext_bidder.json +++ b/adapters/yeahmobi/yeahmobitest/supplemental/bad_imp_ext_bidder.json @@ -16,7 +16,7 @@ "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb_ext.ExtImpYeahmobi", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/yeahmobi/yeahmobitest/supplemental/bad_response.json b/adapters/yeahmobi/yeahmobitest/supplemental/bad_response.json index 2fc375532de..43e16117887 100644 --- a/adapters/yeahmobi/yeahmobitest/supplemental/bad_response.json +++ b/adapters/yeahmobi/yeahmobitest/supplemental/bad_response.json @@ -50,7 +50,7 @@ "expectedMakeBidsErrors": [ { "comparison": "literal", - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse" + "value": "expect { or n, but found \"" } ] } diff --git a/adapters/yieldlab/yieldlab.go b/adapters/yieldlab/yieldlab.go index c92abe7597d..ea5f64aff27 100644 --- a/adapters/yieldlab/yieldlab.go +++ b/adapters/yieldlab/yieldlab.go @@ -16,6 +16,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" "github.com/prebid/prebid-server/v2/util/ptrutil" ) @@ -130,7 +131,7 @@ func getDSA(req *openrtb2.BidRequest) (*dsaRequest, error) { } var extRegs openRTBExtRegsWithDSA - err := json.Unmarshal(req.Regs.Ext, &extRegs) + err := jsonutil.Unmarshal(req.Regs.Ext, &extRegs) if err != nil { return nil, fmt.Errorf("failed to parse Regs.Ext object from Yieldlab response: %v", err) } @@ -207,7 +208,7 @@ func (a *YieldlabAdapter) getGDPR(request *openrtb2.BidRequest) (string, string, consent := "" if request.User != nil && request.User.Ext != nil { var extUser openrtb_ext.ExtUser - if err := json.Unmarshal(request.User.Ext, &extUser); err != nil { + if err := jsonutil.Unmarshal(request.User.Ext, &extUser); err != nil { return "", "", fmt.Errorf("failed to parse ExtUser in Yieldlab GDPR check: %v", err) } consent = extUser.Consent @@ -216,7 +217,7 @@ func (a *YieldlabAdapter) getGDPR(request *openrtb2.BidRequest) (string, string, gdpr := "" var extRegs openrtb_ext.ExtRegs if request.Regs != nil { - if err := json.Unmarshal(request.Regs.Ext, &extRegs); err == nil { + if err := jsonutil.Unmarshal(request.Regs.Ext, &extRegs); err == nil { if extRegs.GDPR != nil && (*extRegs.GDPR == 0 || *extRegs.GDPR == 1) { gdpr = strconv.Itoa(int(*extRegs.GDPR)) } @@ -271,12 +272,12 @@ func (a *YieldlabAdapter) parseRequest(request *openrtb2.BidRequest) []*openrtb_ for i := 0; i < len(request.Imp); i++ { bidderExt := new(adapters.ExtImpBidder) - if err := json.Unmarshal(request.Imp[i].Ext, bidderExt); err != nil { + if err := jsonutil.Unmarshal(request.Imp[i].Ext, bidderExt); err != nil { continue } yieldlabExt := new(openrtb_ext.ExtImpYieldlab) - if err := json.Unmarshal(bidderExt.Bidder, yieldlabExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, yieldlabExt); err != nil { continue } @@ -314,7 +315,7 @@ func (a *YieldlabAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externa } bids := make([]*bidResponse, 0) - if err := json.Unmarshal(response.Body, &bids); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bids); err != nil { return nil, []error{ &errortypes.BadServerResponse{ Message: fmt.Sprintf("failed to parse bids response from yieldlab: %v", err), @@ -420,9 +421,9 @@ func (a *YieldlabAdapter) findBidReq(adslotID uint64, params []*openrtb_ext.ExtI func (a *YieldlabAdapter) extractAdslotID(internalRequestImp openrtb2.Imp) string { bidderExt := new(adapters.ExtImpBidder) - json.Unmarshal(internalRequestImp.Ext, bidderExt) + jsonutil.Unmarshal(internalRequestImp.Ext, bidderExt) yieldlabExt := new(openrtb_ext.ExtImpYieldlab) - json.Unmarshal(bidderExt.Bidder, yieldlabExt) + jsonutil.Unmarshal(bidderExt.Bidder, yieldlabExt) return yieldlabExt.AdslotID } @@ -460,7 +461,7 @@ func (a *YieldlabAdapter) makeCreativeID(req *openrtb_ext.ExtImpYieldlab, bid *b // unmarshalSupplyChain makes the value for the schain URL parameter from the openRTB schain object. func unmarshalSupplyChain(req *openrtb2.BidRequest) *openrtb2.SupplyChain { var extSChain openrtb_ext.ExtRequestPrebidSChain - err := json.Unmarshal(req.Source.Ext, &extSChain) + err := jsonutil.Unmarshal(req.Source.Ext, &extSChain) if err != nil { // req.Source.Ext could be anything so don't handle any errors return nil diff --git a/adapters/yieldlab/yieldlabtest/supplemental/invalid_reg_ext.json b/adapters/yieldlab/yieldlabtest/supplemental/invalid_reg_ext.json index 1723b8fbe80..51e8e87d540 100644 --- a/adapters/yieldlab/yieldlabtest/supplemental/invalid_reg_ext.json +++ b/adapters/yieldlab/yieldlabtest/supplemental/invalid_reg_ext.json @@ -60,7 +60,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "failed to parse Regs.Ext object from Yieldlab response: json: cannot unmarshal string into Go struct field openRTBExtRegsWithDSA.dsa of type yieldlab.dsaRequest", + "value": "failed to parse Regs.Ext object from Yieldlab response: cannot unmarshal yieldlab.openRTBExtRegsWithDSA.DSA: expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/yieldmo/yieldmo.go b/adapters/yieldmo/yieldmo.go index 107622e9304..baa09498383 100644 --- a/adapters/yieldmo/yieldmo.go +++ b/adapters/yieldmo/yieldmo.go @@ -11,6 +11,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type YieldmoAdapter struct { @@ -81,7 +82,7 @@ func preprocess(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo } } - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { errs = append(errs, &errortypes.BadInput{ Message: err.Error(), }) @@ -89,7 +90,7 @@ func preprocess(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo var yieldmoExt openrtb_ext.ExtImpYieldmo - if err := json.Unmarshal(bidderExt.Bidder, &yieldmoExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &yieldmoExt); err != nil { errs = append(errs, &errortypes.BadInput{ Message: err.Error(), }) @@ -137,7 +138,7 @@ func (a *YieldmoAdapter) MakeBids(internalRequest *openrtb2.BidRequest, external var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -170,7 +171,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co // Retrieve the media type corresponding to the bid from the bid.ext object func getMediaTypeForImp(bid openrtb2.Bid) (openrtb_ext.BidType, error) { var bidExt ExtBid - if err := json.Unmarshal(bid.Ext, &bidExt); err != nil { + if err := jsonutil.Unmarshal(bid.Ext, &bidExt); err != nil { return "", &errortypes.BadInput{Message: err.Error()} } diff --git a/adapters/yieldone/yieldone.go b/adapters/yieldone/yieldone.go index 8cd7dbd6021..102665ec90b 100644 --- a/adapters/yieldone/yieldone.go +++ b/adapters/yieldone/yieldone.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type YieldoneAdapter struct { @@ -68,7 +69,7 @@ func (a *YieldoneAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externa } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -105,11 +106,11 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co func preprocess(imp *openrtb2.Imp) error { var ext adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &ext); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &ext); err != nil { return err } var impressionExt openrtb_ext.ExtImpYieldone - if err := json.Unmarshal(ext.Bidder, &impressionExt); err != nil { + if err := jsonutil.Unmarshal(ext.Bidder, &impressionExt); err != nil { return err } diff --git a/adapters/yieldone/yieldonetest/supplemental/bad_response.json b/adapters/yieldone/yieldonetest/supplemental/bad_response.json index ac4bfd7da23..c3ce0ed0c65 100644 --- a/adapters/yieldone/yieldonetest/supplemental/bad_response.json +++ b/adapters/yieldone/yieldonetest/supplemental/bad_response.json @@ -59,7 +59,7 @@ "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/zeroclickfraud/zeroclickfraud.go b/adapters/zeroclickfraud/zeroclickfraud.go index 0b5c74771ba..a035cddb568 100644 --- a/adapters/zeroclickfraud/zeroclickfraud.go +++ b/adapters/zeroclickfraud/zeroclickfraud.go @@ -13,6 +13,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/macros" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type ZeroClickFraudAdapter struct { @@ -92,7 +93,7 @@ func (a *ZeroClickFraudAdapter) MakeBids( var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -130,13 +131,13 @@ func splitImpressions(imps []openrtb2.Imp) (map[openrtb_ext.ExtImpZeroClickFraud func getBidderParams(imp *openrtb2.Imp) (*openrtb_ext.ExtImpZeroClickFraud, error) { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("Missing bidder ext: %s", err.Error()), } } var zeroclickfraudExt openrtb_ext.ExtImpZeroClickFraud - if err := json.Unmarshal(bidderExt.Bidder, &zeroclickfraudExt); err != nil { + if err := jsonutil.Unmarshal(bidderExt.Bidder, &zeroclickfraudExt); err != nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("Cannot Resolve host or sourceId: %s", err.Error()), } diff --git a/adapters/zeroclickfraud/zeroclickfraudtest/supplemental/bad-response-body.json b/adapters/zeroclickfraud/zeroclickfraudtest/supplemental/bad-response-body.json index 8dc9ffd6469..9e1483c79ec 100644 --- a/adapters/zeroclickfraud/zeroclickfraudtest/supplemental/bad-response-body.json +++ b/adapters/zeroclickfraud/zeroclickfraudtest/supplemental/bad-response-body.json @@ -82,7 +82,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/zeroclickfraud/zeroclickfraudtest/supplemental/missing-ext.json b/adapters/zeroclickfraud/zeroclickfraudtest/supplemental/missing-ext.json index 68d29e880b9..9e72e3cb6e5 100644 --- a/adapters/zeroclickfraud/zeroclickfraudtest/supplemental/missing-ext.json +++ b/adapters/zeroclickfraud/zeroclickfraudtest/supplemental/missing-ext.json @@ -18,8 +18,8 @@ "expectedMakeRequestsErrors": [ { - "value": "Missing bidder ext: unexpected end of JSON input", - "comparison": "literal" + "value": "Missing bidder ext: expect { or n, but found", + "comparison": "startswith" } ] diff --git a/adapters/zeroclickfraud/zeroclickfraudtest/supplemental/missing-extparam.json b/adapters/zeroclickfraud/zeroclickfraudtest/supplemental/missing-extparam.json index d272cd5347c..7755ef80ec2 100644 --- a/adapters/zeroclickfraud/zeroclickfraudtest/supplemental/missing-extparam.json +++ b/adapters/zeroclickfraud/zeroclickfraudtest/supplemental/missing-extparam.json @@ -21,8 +21,8 @@ "expectedMakeRequestsErrors": [ { - "value": "Cannot Resolve host or sourceId: unexpected end of JSON input", - "comparison": "literal" + "value": "Cannot Resolve host or sourceId: expect { or n, but found", + "comparison": "startswith" } ] diff --git a/adapters/zeta_global_ssp/zeta_global_ssp.go b/adapters/zeta_global_ssp/zeta_global_ssp.go index cf78b91ac8a..176dfbbda44 100644 --- a/adapters/zeta_global_ssp/zeta_global_ssp.go +++ b/adapters/zeta_global_ssp/zeta_global_ssp.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -54,7 +55,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } var response openrtb2.BidResponse - if err := json.Unmarshal(responseData.Body, &response); err != nil { + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } @@ -81,7 +82,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) { if bid.Ext != nil { var bidExt openrtb_ext.ExtBid - err := json.Unmarshal(bid.Ext, &bidExt) + err := jsonutil.Unmarshal(bid.Ext, &bidExt) if err == nil && bidExt.Prebid != nil { return openrtb_ext.ParseBidType(string(bidExt.Prebid.Type)) } diff --git a/adapters/zmaticoo/zmaticoo.go b/adapters/zmaticoo/zmaticoo.go index 61860df5b22..ac00bed3201 100644 --- a/adapters/zmaticoo/zmaticoo.go +++ b/adapters/zmaticoo/zmaticoo.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v2/util/jsonutil" ) type adapter struct { @@ -61,7 +62,7 @@ func transform(request *openrtb2.BidRequest) error { if imp.Native != nil { var nativeRequest map[string]interface{} nativeCopyRequest := make(map[string]interface{}) - if err := json.Unmarshal([]byte(request.Imp[i].Native.Request), &nativeRequest); err != nil { + if err := jsonutil.Unmarshal([]byte(request.Imp[i].Native.Request), &nativeRequest); err != nil { return err } _, exists := nativeRequest["native"] @@ -86,12 +87,12 @@ func validateZmaticooExt(request *openrtb2.BidRequest) []error { var errs []error for _, imp := range request.Imp { var extBidder adapters.ExtImpBidder - err := json.Unmarshal(imp.Ext, &extBidder) + err := jsonutil.Unmarshal(imp.Ext, &extBidder) if err != nil { errs = append(errs, err) continue } - err = json.Unmarshal(extBidder.Bidder, &extImpZmaticoo) + err = jsonutil.Unmarshal(extBidder.Bidder, &extImpZmaticoo) if err != nil { errs = append(errs, err) continue @@ -116,7 +117,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest }} } var bidResp openrtb2.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := jsonutil.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } var errs []error diff --git a/adapters/zmaticoo/zmaticootest/supplemental/bad_imp_ext.json b/adapters/zmaticoo/zmaticootest/supplemental/bad_imp_ext.json index 444e1e7a8d8..782f7a0c3b4 100644 --- a/adapters/zmaticoo/zmaticootest/supplemental/bad_imp_ext.json +++ b/adapters/zmaticoo/zmaticootest/supplemental/bad_imp_ext.json @@ -14,7 +14,7 @@ "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/zmaticoo/zmaticootest/supplemental/bad_imp_ext_bidder.json b/adapters/zmaticoo/zmaticootest/supplemental/bad_imp_ext_bidder.json index 433bac5e564..b9a32be2ce6 100644 --- a/adapters/zmaticoo/zmaticootest/supplemental/bad_imp_ext_bidder.json +++ b/adapters/zmaticoo/zmaticootest/supplemental/bad_imp_ext_bidder.json @@ -20,7 +20,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb_ext.ExtImpZmaticoo", + "value": "expect { or n, but found \"", "comparison": "literal" } ] diff --git a/adapters/zmaticoo/zmaticootest/supplemental/bad_response.json b/adapters/zmaticoo/zmaticootest/supplemental/bad_response.json index e129e3ce4a7..3d053597a20 100644 --- a/adapters/zmaticoo/zmaticootest/supplemental/bad_response.json +++ b/adapters/zmaticoo/zmaticootest/supplemental/bad_response.json @@ -58,7 +58,7 @@ "expectedMakeBidsErrors": [ { "comparison": "literal", - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse" + "value": "expect { or n, but found \"" } ] }