-
Notifications
You must be signed in to change notification settings - Fork 749
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
Request validation upgrade to 2.6 locations #3906
Conversation
endpoints/openrtb2/auction.go
Outdated
@@ -823,7 +827,7 @@ func (deps *endpointDeps) validateRequest(account *config.Account, httpReq *http | |||
} | |||
} | |||
|
|||
if err := mapSChains(req); err != nil { | |||
if err := mapSChains(req); err != nil { // do we need this? |
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.
You can get rid of this. It should now be handled in moveSupplyChainFrom24To25
from convert_up.go
.
endpoints/openrtb2/auction.go
Outdated
func validateSChains(sChains []*openrtb_ext.ExtRequestPrebidSChain) error { | ||
_, err := schain.BidderToPrebidSChains(sChains) | ||
return err | ||
} |
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.
Not sure if this needs to be deleted
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.
We need to keep this. I believe the source.ext.schain
2.5 field is what is being migrated to source.schain
in 2.6. This logic refers to a different schain feature that has no 2.6 equivalent where bidder-specific schain nodes may be specified at source.ext.prebid.schains
.
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.
Restored
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.
LGTM
endpoints/openrtb2/auction.go
Outdated
func validateSChains(sChains []*openrtb_ext.ExtRequestPrebidSChain) error { | ||
_, err := schain.BidderToPrebidSChains(sChains) | ||
return err | ||
} |
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.
We need to keep this. I believe the source.ext.schain
2.5 field is what is being migrated to source.schain
in 2.6. This logic refers to a different schain feature that has no 2.6 equivalent where bidder-specific schain nodes may be specified at source.ext.prebid.schains
.
// mapSChains maps an schain defined in an ORTB 2.4 location (req.ext.schain) to the ORTB 2.5 location | ||
// (req.source.ext.schain) if no ORTB 2.5 schain (req.source.ext.schain, req.ext.prebid.schains) exists. |
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.
I'm wondering if we need to update the upconvert logic for schain to only perform an upgrade from 2.4 to 2.5 if req.ext.prebid.schains
does not exist. req.ext.prebid.schains
is a 2.5 location so it should take precedence.
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.
Discussed offline. I'll take a look to see if this is a problem.
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 order of precedence from highest to lowest is as follows:
req.ext.prebid.schains
req.source.schain
(2.6)
req.source.ext.schain
(2.5)
req.ext.schain
(2.4)
We're upconverting right after we parse the request which will handle the ORTB standard locations resulting in a value in the 2.6 location if an schain exists in the 2.4, 2.5 or 2.6 location. Downstream we will use the schain writer to potentially overwrite the 2.6 location with a value from the req.ext.prebid.schains
.
No additional change is needed to the upconvert logic.
endpoints/openrtb2/auction.go
Outdated
if len(sChain.Ver) == 0 { | ||
return errors.New("request.source.schain.ver cannot be empty") | ||
} | ||
if len(sChain.Nodes) == 0 { | ||
return errors.New("request.source.schain.nodes cannot be empty") | ||
} | ||
for i, node := range sChain.Nodes { | ||
if len(node.ASI) == 0 { | ||
return fmt.Errorf("request.source.schain.nodes[%d].asi cannot be empty", i) | ||
} | ||
if len(node.SID) == 0 { | ||
return fmt.Errorf("request.source.schain.nodes[%d].sid cannot be empty", i) | ||
} | ||
} |
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.
Did these validation rules come from https://github.com/InteractiveAdvertisingBureau/openrtb/blob/main/supplychainobject.md? There are a couple of other fields marked as required in this spec.
I don't think we had these validation rules before so I'm wondering if there is a reason for that. I'll look through the closed issues to see if I can figure it out.
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.
I found this in OpenRTB 2.6 spec, paragraph 3.2.25 and 3.2.26.
You are probably referring to this required field: Complete int8
. This field bus not a pointer and will always present in this struct. Specification also says it can 0 = no, 1 = yes
. Do we want to validate this value is 0 or 1 only? I missed this part.
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.
Let's remove this validation. PBS's approach is to just validate the schema (attributes & datatypes) for fields we do not use.
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.
Reverted
endpoints/openrtb2/auction.go
Outdated
eidsValue := req.User.EIDs | ||
for eidIndex, eid := range eidsValue { |
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.
Nitpick: I think you can iterate over req.User.EIDs
directly and get rid of eidsValue
since we are just reading the eids from the slice.
endpoints/openrtb2/auction.go
Outdated
if device.SUA != nil { | ||
if len(device.SUA.Browsers) > 0 { | ||
for i, browser := range device.SUA.Browsers { | ||
if len(browser.Brand) == 0 { | ||
return fmt.Errorf("request.device.sua.browsers[%d].brand cannot be empty", i) | ||
} | ||
} | ||
} | ||
if device.SUA.Platform != nil { | ||
if len(device.SUA.Platform.Brand) == 0 { | ||
return errors.New("request.device.sua.platform.brand cannot be empty") | ||
} | ||
} | ||
} |
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.
Where did this validation logic come from? Is this new 2.6 behavior?
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 is from the OpenRTB 2.6 specification, paragraph 3.2.30.
device.SUA.Browser[].Brand
is required if device.SUA.Browser[]
is present.
device.SUA.Platform.Brand
is required if device.SUA.Platform
is present.
We discussed offline that we can omit validation for the fields we don't use in PBS core, so I'm open to delete this.
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.
Let's remove this validation. PBS's approach is to just validate the schema (attributes & datatypes) for fields we do not use.
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.
Reverted
@@ -1,5 +1,5 @@ | |||
{ | |||
"description": "Bid request where a request.user.ext.eids.uids array element is missing its id field", | |||
"description": "Bid request with user.eids array element array element that does not contain source field", |
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.
typo: array element array element
endpoints/openrtb2/auction_test.go
Outdated
@@ -2889,183 +2889,6 @@ func TestValidateSourceTID(t *testing.T) { | |||
assert.NotEmpty(t, req.Source.TID, "Expected req.Source.TID to be filled with a randomly generated UID") | |||
} | |||
|
|||
func TestSChainInvalid(t *testing.T) { |
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.
We should restore the prebid specific per-bidder schain logic as mentioned in another comment so this test should be restored as well.
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.
Restored
No description provided.