Skip to content
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

CCPA Video Bug #1333

Merged
merged 4 commits into from
Jun 8, 2020
Merged

CCPA Video Bug #1333

merged 4 commits into from
Jun 8, 2020

Conversation

SyntaxNode
Copy link
Contributor

CCPA validation errors should result in warnings, not fatal errors. The video endpoint is missing the filter to ignore warnings. This PR also removes the invalid CCPA consent string from the request in further processing.

@@ -122,9 +122,8 @@ func TestAMPPageInfo(t *testing.T) {
}

func TestGDPRConsent(t *testing.T) {
consent := "BONV8oqONXwgmADACHENAO7pqzAAppY"
consent := "BOu5On0Ou5On0ADACHENAO7pqzAAppY"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated. Noticed the poor test setup in looking at the adjacent CCPA tests.

ccpaPolicy.Value = ""
if err := ccpaPolicy.Write(req); err != nil {
errL = append(errL, fmt.Errorf("Unable to remove invalid CCPA consent from the request. (%v)", err))
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now remove the invalid value from the request. This prevents invalid CCPA values from being passed downstream to bidders.

expectedWarning := errortypes.InvalidPrivacyConsent{Message: "CCPA consent is invalid and will be ignored. (request.regs.ext.us_privacy must contain 4 characters)"}
assert.ElementsMatch(t, errL, []error{&expectedWarning})

assert.Empty(t, req.Regs.Ext, "Invalid Consent Removed From Request")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New assertion to verify the invalid consent string is removed.

@@ -1,68 +1,69 @@
{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I normalized the format of the sample json files. I removed the no longer existing accountid field, moved the no longer valid gdpr section (it's uses the standard IAB locations now), and reformatted the user section to match IAB spec from an earlier customized user object. .. oh, and ran it through a json "prettifier".

"gender": "F",
"keywords": "Hotels, Travelling"
},
"device11": {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this a typo or an intention way to effectively remove the device info? I erred on the side of a typo and fixed it.

errL = deps.validateRequest(bidReq)
if len(errL) > 0 {
if errortypes.ContainsFatalError(errL) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main fix. I added similar filters to AMP and Auction, but forgot about Video.

headers := http.Header{}
headers.Add("User-Agent", "TestHeader")

deps := mockDeps(t, ex)
req, valErr, podErr := deps.parseVideoRequest(reqData, headers)
reqBody := string(getRequestPayload(t, reqData))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of normalizing the json file formats.

@@ -32,6 +32,10 @@ func ReadPolicy(req *openrtb.BidRequest) (Policy, error) {
// Write mutates an OpenRTB bid request with the context of the CCPA policy.
func (p Policy) Write(req *openrtb.BidRequest) error {
if p.Value == "" {
return clearPolicy(req)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It used to do nothing, but now there's a use case to remove the value.

jmaynardxandr
jmaynardxandr previously approved these changes Jun 4, 2020
}
}

func TestCCPAInvalidConsent(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove? The invalid CCPA string is covered by the 3rd case in above function I believe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooops! You're absolutely right. This is a useless empty test I forgot to remove when I turned the above one into a "table driven" format. Removed.

@@ -232,7 +232,7 @@ func (deps *endpointDeps) VideoAuctionEndpoint(w http.ResponseWriter, r *http.Re
}

if acctIdErr := validateAccount(deps.cfg, labels.PubID); acctIdErr != nil {
errL = append(errL, acctIdErr)
errL := []error{err}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is intentional that we want to drop any previous errors if we encounter this error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added that bit just now. Yes, it's intentional. The previous expectation from the code is for errL to be empty here. If it had an error before my changes, that should've triggered an early exit. The video endpoint doesn't have a structured response for errors (yet? hopefully?) so there's currently no way to communicate the warning back to the caller. Best to drop it than for it to randomly show up along with another unrelated error such as an invalid account.

Copy link
Contributor

@guscarreon guscarreon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@guscarreon guscarreon merged commit dc9d246 into prebid:master Jun 8, 2020
@SyntaxNode SyntaxNode deleted the ccpa_video_bug branch July 2, 2020 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants