-
Notifications
You must be signed in to change notification settings - Fork 760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass through unknown imp.ext values to adapters #3878
Changes from 4 commits
834818f
fa8fdf7
18b6b7f
427eff2
ce51fda
73e7319
ef994ed
9bad784
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,9 +31,6 @@ | |
"wrapper": { | ||
"profile": 1234 | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this test affected? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test was affected because it had an empty
also promote in case it is empty: So we took option 2. I think route 1 is less invasive, so I am adding a lighter modification to this test fixture - where it will only remove an empty |
||
}, | ||
"prebid": { | ||
"bidder": {} | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -607,93 +607,97 @@ func TestCreateSanitizedImpExt(t *testing.T) { | |
{ | ||
description: "imp.ext", | ||
givenImpExt: map[string]json.RawMessage{ | ||
"anyBidder": json.RawMessage(`"anyBidderValues"`), | ||
"data": json.RawMessage(`"anyData"`), | ||
"context": json.RawMessage(`"anyContext"`), | ||
"skadn": json.RawMessage(`"anySKAdNetwork"`), | ||
"gpid": json.RawMessage(`"anyGPID"`), | ||
"tid": json.RawMessage(`"anyTID"`), | ||
"arbitraryField": json.RawMessage(`"arbitraryValue"`), | ||
"data": json.RawMessage(`"anyData"`), | ||
"context": json.RawMessage(`"anyContext"`), | ||
"skadn": json.RawMessage(`"anySKAdNetwork"`), | ||
"gpid": json.RawMessage(`"anyGPID"`), | ||
"tid": json.RawMessage(`"anyTID"`), | ||
}, | ||
givenImpExtPrebid: map[string]json.RawMessage{}, | ||
expected: map[string]json.RawMessage{ | ||
"data": json.RawMessage(`"anyData"`), | ||
"context": json.RawMessage(`"anyContext"`), | ||
"skadn": json.RawMessage(`"anySKAdNetwork"`), | ||
"gpid": json.RawMessage(`"anyGPID"`), | ||
"tid": json.RawMessage(`"anyTID"`), | ||
"arbitraryField": json.RawMessage(`"arbitraryValue"`), | ||
"data": json.RawMessage(`"anyData"`), | ||
"context": json.RawMessage(`"anyContext"`), | ||
"skadn": json.RawMessage(`"anySKAdNetwork"`), | ||
"gpid": json.RawMessage(`"anyGPID"`), | ||
"tid": json.RawMessage(`"anyTID"`), | ||
}, | ||
expectedError: "", | ||
}, | ||
{ | ||
description: "imp.ext + imp.ext.prebid - Prebid Bidder Only", | ||
givenImpExt: map[string]json.RawMessage{ | ||
"anyBidder": json.RawMessage(`"anyBidderValues"`), | ||
"prebid": json.RawMessage(`"ignoredInFavorOfSeparatelyUnmarshalledImpExtPrebid"`), | ||
"data": json.RawMessage(`"anyData"`), | ||
"context": json.RawMessage(`"anyContext"`), | ||
"skadn": json.RawMessage(`"anySKAdNetwork"`), | ||
"gpid": json.RawMessage(`"anyGPID"`), | ||
"tid": json.RawMessage(`"anyTID"`), | ||
"unknownBidder": json.RawMessage(`"anyUnknownBidderValues"`), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As mentioned in an earlier comment I think it makes more sense if all of these test cases in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be addressed now in |
||
"prebid": json.RawMessage(`"ignoredInFavorOfSeparatelyUnmarshalledImpExtPrebid"`), | ||
"data": json.RawMessage(`"anyData"`), | ||
"context": json.RawMessage(`"anyContext"`), | ||
"skadn": json.RawMessage(`"anySKAdNetwork"`), | ||
"gpid": json.RawMessage(`"anyGPID"`), | ||
"tid": json.RawMessage(`"anyTID"`), | ||
}, | ||
givenImpExtPrebid: map[string]json.RawMessage{ | ||
"bidder": json.RawMessage(`"anyBidder"`), | ||
}, | ||
expected: map[string]json.RawMessage{ | ||
"data": json.RawMessage(`"anyData"`), | ||
"context": json.RawMessage(`"anyContext"`), | ||
"skadn": json.RawMessage(`"anySKAdNetwork"`), | ||
"gpid": json.RawMessage(`"anyGPID"`), | ||
"tid": json.RawMessage(`"anyTID"`), | ||
"unknownBidder": json.RawMessage(`"anyUnknownBidderValues"`), | ||
"data": json.RawMessage(`"anyData"`), | ||
"context": json.RawMessage(`"anyContext"`), | ||
"skadn": json.RawMessage(`"anySKAdNetwork"`), | ||
"gpid": json.RawMessage(`"anyGPID"`), | ||
"tid": json.RawMessage(`"anyTID"`), | ||
}, | ||
expectedError: "", | ||
}, | ||
{ | ||
description: "imp.ext + imp.ext.prebid - Prebid Bidder + Other Forbidden Value", | ||
givenImpExt: map[string]json.RawMessage{ | ||
"anyBidder": json.RawMessage(`"anyBidderValues"`), | ||
"prebid": json.RawMessage(`"ignoredInFavorOfSeparatelyUnmarshalledImpExtPrebid"`), | ||
"data": json.RawMessage(`"anyData"`), | ||
"context": json.RawMessage(`"anyContext"`), | ||
"skadn": json.RawMessage(`"anySKAdNetwork"`), | ||
"gpid": json.RawMessage(`"anyGPID"`), | ||
"tid": json.RawMessage(`"anyTID"`), | ||
"unknownBidder": json.RawMessage(`"anyUnknownBidderValues"`), | ||
"prebid": json.RawMessage(`"ignoredInFavorOfSeparatelyUnmarshalledImpExtPrebid"`), | ||
"data": json.RawMessage(`"anyData"`), | ||
"context": json.RawMessage(`"anyContext"`), | ||
"skadn": json.RawMessage(`"anySKAdNetwork"`), | ||
"gpid": json.RawMessage(`"anyGPID"`), | ||
"tid": json.RawMessage(`"anyTID"`), | ||
}, | ||
givenImpExtPrebid: map[string]json.RawMessage{ | ||
"bidder": json.RawMessage(`"anyBidder"`), | ||
"forbidden": json.RawMessage(`"anyValue"`), | ||
}, | ||
expected: map[string]json.RawMessage{ | ||
"data": json.RawMessage(`"anyData"`), | ||
"context": json.RawMessage(`"anyContext"`), | ||
"skadn": json.RawMessage(`"anySKAdNetwork"`), | ||
"gpid": json.RawMessage(`"anyGPID"`), | ||
"tid": json.RawMessage(`"anyTID"`), | ||
"unknownBidder": json.RawMessage(`"anyUnknownBidderValues"`), | ||
"data": json.RawMessage(`"anyData"`), | ||
"context": json.RawMessage(`"anyContext"`), | ||
"skadn": json.RawMessage(`"anySKAdNetwork"`), | ||
"gpid": json.RawMessage(`"anyGPID"`), | ||
"tid": json.RawMessage(`"anyTID"`), | ||
}, | ||
expectedError: "", | ||
}, | ||
{ | ||
description: "imp.ext + imp.ext.prebid - Prebid Bidder + Other Allowed Values", | ||
givenImpExt: map[string]json.RawMessage{ | ||
"anyBidder": json.RawMessage(`"anyBidderValues"`), | ||
"prebid": json.RawMessage(`"ignoredInFavorOfSeparatelyUnmarshalledImpExtPrebid"`), | ||
"data": json.RawMessage(`"anyData"`), | ||
"context": json.RawMessage(`"anyContext"`), | ||
"skadn": json.RawMessage(`"anySKAdNetwork"`), | ||
"gpid": json.RawMessage(`"anyGPID"`), | ||
"tid": json.RawMessage(`"anyTID"`), | ||
"unknownBidder": json.RawMessage(`"anyUnknownBidderValues"`), | ||
"prebid": json.RawMessage(`"ignoredInFavorOfSeparatelyUnmarshalledImpExtPrebid"`), | ||
"data": json.RawMessage(`"anyData"`), | ||
"context": json.RawMessage(`"anyContext"`), | ||
"skadn": json.RawMessage(`"anySKAdNetwork"`), | ||
"gpid": json.RawMessage(`"anyGPID"`), | ||
"tid": json.RawMessage(`"anyTID"`), | ||
}, | ||
givenImpExtPrebid: map[string]json.RawMessage{ | ||
"bidder": json.RawMessage(`"anyBidder"`), | ||
"is_rewarded_inventory": json.RawMessage(`"anyIsRewardedInventory"`), | ||
"options": json.RawMessage(`"anyOptions"`), | ||
}, | ||
expected: map[string]json.RawMessage{ | ||
"prebid": json.RawMessage(`{"is_rewarded_inventory":"anyIsRewardedInventory","options":"anyOptions"}`), | ||
"data": json.RawMessage(`"anyData"`), | ||
"context": json.RawMessage(`"anyContext"`), | ||
"skadn": json.RawMessage(`"anySKAdNetwork"`), | ||
"gpid": json.RawMessage(`"anyGPID"`), | ||
"tid": json.RawMessage(`"anyTID"`), | ||
"unknownBidder": json.RawMessage(`"anyUnknownBidderValues"`), | ||
"prebid": json.RawMessage(`{"is_rewarded_inventory":"anyIsRewardedInventory","options":"anyOptions"}`), | ||
"data": json.RawMessage(`"anyData"`), | ||
"context": json.RawMessage(`"anyContext"`), | ||
"skadn": json.RawMessage(`"anySKAdNetwork"`), | ||
"gpid": json.RawMessage(`"anyGPID"`), | ||
"tid": json.RawMessage(`"anyTID"`), | ||
}, | ||
expectedError: "", | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,22 +88,27 @@ func (srv *standardRequestValidator) validateImpExt(imp *openrtb_ext.ImpWrapper, | |
prebid := impExt.GetOrCreatePrebid() | ||
prebidModified := false | ||
|
||
bidderPromote := false | ||
|
||
if prebid.Bidder == nil { | ||
prebid.Bidder = make(map[string]json.RawMessage) | ||
bidderPromote = true | ||
} | ||
|
||
ext := impExt.GetExt() | ||
extModified := false | ||
|
||
// promote imp[].ext.BIDDER to newer imp[].ext.prebid.bidder.BIDDER location, with the later taking precedence | ||
for k, v := range ext { | ||
if openrtb_ext.IsPotentialBidder(k) { | ||
if _, exists := prebid.Bidder[k]; !exists { | ||
prebid.Bidder[k] = v | ||
prebidModified = true | ||
if bidderPromote { | ||
for k, v := range ext { | ||
if openrtb_ext.IsPotentialBidder(k) { | ||
if _, exists := prebid.Bidder[k]; !exists { | ||
prebid.Bidder[k] = v | ||
prebidModified = true | ||
} | ||
delete(ext, k) | ||
extModified = true | ||
} | ||
delete(ext, k) | ||
extModified = true | ||
} | ||
} | ||
Comment on lines
101
to
113
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @SyntaxNode with this change we will now only attempt to promote from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One more option would be to allow for an empty There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I vote to keep this as-is.
Yes. This is the design of the feature and the next phase of deprecating
Right. Let's not code for unknown use cases. |
||
|
||
|
@@ -117,15 +122,15 @@ func (srv *standardRequestValidator) validateImpExt(imp *openrtb_ext.ImpWrapper, | |
|
||
errL := []error{} | ||
|
||
for bidder, ext := range prebid.Bidder { | ||
for bidder, val := range prebid.Bidder { | ||
coreBidder, _ := openrtb_ext.NormalizeBidderName(bidder) | ||
if tmp, isAlias := aliases[bidder]; isAlias { | ||
coreBidder = openrtb_ext.BidderName(tmp) | ||
} | ||
|
||
if coreBidderNormalized, isValid := srv.bidderMap[coreBidder.String()]; isValid { | ||
if !cfg.SkipBidderParams { | ||
if err := srv.paramsValidator.Validate(coreBidderNormalized, ext); err != nil { | ||
if err := srv.paramsValidator.Validate(coreBidderNormalized, val); err != nil { | ||
return []error{fmt.Errorf("request.imp[%d].ext.prebid.bidder.%s failed validation.\n%v", impIndex, bidder, err)} | ||
} | ||
} | ||
|
@@ -134,6 +139,11 @@ func (srv *standardRequestValidator) validateImpExt(imp *openrtb_ext.ImpWrapper, | |
errL = append(errL, &errortypes.BidderTemporarilyDisabled{Message: msg}) | ||
delete(prebid.Bidder, bidder) | ||
prebidModified = true | ||
} else if bidderPromote { | ||
errL = append(errL, &errortypes.Warning{Message: fmt.Sprintf("request.imp[%d].ext contains unknown bidder: '%s', ignoring", impIndex, bidder)}) | ||
ext[bidder] = val | ||
delete(prebid.Bidder, bidder) | ||
prebidModified = true | ||
} else { | ||
return []error{fmt.Errorf("request.imp[%d].ext.prebid.bidder contains unknown bidder: %s. Did you forget an alias in request.ext.prebid.aliases?", impIndex, bidder)} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way you've modified this test it is now a valid test case instead of an invalid test case and is in the wrong directory. How about doing the following instead:
imp-ext-prebid-bidder-empty.json
and modify this test case to result in a 400 status code withimp.ext.bidder
being emptyendpoints/openrtb2/sample-requests/valid-whole/supplementary/req-ext-bidder-params-backward-compatible-merge.json
toendpoints/openrtb2/sample-requests/valid-whole/supplementary/req-ext-bidder-params-promotion.json
and include a field that is not a bidder ensuring the warning is reported in addition to the known bidders being promoted.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense, sorry did not pay attention to the semantics expressed by directory names.
unknownWarningCode
or some new warning code for this specific warning?