-
Notifications
You must be signed in to change notification settings - Fork 759
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
Remove invalid user EIDs and UIDs from bid request #3891
base: master
Are you sure you want to change the base?
Remove invalid user EIDs and UIDs from bid request #3891
Conversation
@@ -35,6 +35,8 @@ const ( | |||
InvalidBidResponseDSAWarningCode | |||
SecCookieDeprecationLenWarningCode | |||
SecBrowsingTopicsWarningCode | |||
InvalidUserEIDsWarningCode | |||
InvalidUserUIDsWarningCode |
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.
Do these new warning codes match with PBS-Java? We try to keep in sync.
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.
Can you please help me to get those error codes. Do we have any document or PR to check new warning codes match with PBS-Java.
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.
As per prebid-server-java/pull/3465, I understand that the same 999 warning code is being used when removing eids arrays. In the Prebid Server Go repository, 999 corresponds to UnknownErrorCode in the error codes reference. Are we intending to use UnknownErrorCode here as well?
In this PR, I introduced InvalidUserEIDsWarningCode (10013) and InvalidUserUIDsWarningCode (10014). If we are okay with a generic error code, we could use UnknownErrorCode (999). However, please confirm whether we want separate error codes for InvalidUserEIDs and InvalidUserUIDs, or if using 999 would suffice.
Kindly provide your input on this.
@@ -1,42 +0,0 @@ | |||
{ |
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.
Instead of removing these tests cases, please modify them to prove the new behavior.
@@ -1296,8 +1296,14 @@ func (deps *endpointDeps) validateUser(req *openrtb_ext.RequestWrapper, aliases | |||
// Check Universal User ID | |||
eids := userExt.GetEid() | |||
if eids != nil { | |||
eidsValue := *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; Please remove the leading empty line.
|
||
if len(eidErrors) > 0 { | ||
errL = append(errL, eidErrors...) | ||
} |
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.
Likely fine to keep this logic here for now. We want to separate validation from fixing in the future. We can refactor this new logic along with the rest later. Thoughts @bsardo?
endpoints/openrtb2/auction.go
Outdated
validEIDs = append(validEIDs, eid) | ||
} else { | ||
errorsList = append(errorsList, &errortypes.Warning{ | ||
Message: fmt.Sprintf("Removed EID with empty UIDs (source: %s)", eid.Source), |
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.
Please keep with the established error message format. Perhaps something like:
request.user.ext.eids[0] (source: %s) contains only empty uids and is removed from the request
endpoints/openrtb2/auction_test.go
Outdated
expectedErrorMessages []string | ||
}{ | ||
{ | ||
name: "Valid EID with non-empty UID", |
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.
Go test names cannot contain spaces so they are replaced with a dash character. This makes it hard to locate the failing test based on its name. Recommend using simpler test names like:
one-eid-one-uid-valid
one-eid-one-uid-empty
many-mixed
one-eid-many-uid-empty
The parent test name is within scope so it's easy to locate in source. Please apply this guidance to other tests added in this PR.
endpoints/openrtb2/auction_test.go
Outdated
t.Run(tc.name, func(t *testing.T) { | ||
validEIDs, errorsList := validateEIDs(tc.input) | ||
|
||
if len(validEIDs) != len(tc.expected) { |
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.
Please use testify assert statements where possible. This can be written as follows which will compare the contents instead of just the array lengths, yielding more concrete tests.
assert.ElementsMatch(e, tc.expected, validEIDs)
expectedValidUIDs: nil, | ||
expectedErrors: nil, | ||
}, | ||
} |
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.
Please add a test case for a nil input.
Hi @Pubmatic-Supriya-Patil, can you please merge with master (no rebase) and resolve conflicts? Thanks! |
Thank you for contributing this feature Please address the comments and we will re-review. |
…ver into Fix_3859
HI @bsardo I have updated branch and addressed review comments. |
endpoints/openrtb2/auction.go
Outdated
uidErrors = append(uidErrors, &errortypes.Warning{ | ||
Message: fmt.Sprintf("request.user.eids.uids[%d] contains empty ids and is removed from the request", uidIndex), | ||
WarningCode: errortypes.InvalidUserUIDsWarningCode, |
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 used the example of user.EIDs from the issue description:
"eids": [
{
"source": "uidapi.com",
"uids": [
{"id": ""},
{"id": "AgAACYa0cG2jcVcM42xG"}
]
},
{
"source": "liveramp.com",
"uids": [
{"id": "AgAACYa0cG2jcVcM42xG"}
]
},
{
"source": "yahoo.com",
"uids": [
{"id": ""},
{"id": ""}
]
}
]
As a result I received a list of errors that looked like this:
request.user.eids.uids[0] contains empty ids and is removed from the request
request.user.eids.uids[0] contains empty ids and is removed from the request
request.user.eids.uids[1] contains empty ids and is removed from the request
request.user.eids[2] (source: yahoo.com) contains only empty uids and is removed from the request
In order to avoid confusion and duplicates may you please pass eidIndex to validateUIDs
:
Lines 1311 and 1312:
for eidIndex, eid := range eids {
validUIDs, uidErrors := validateUIDs(eid.UIDs, eidIndex)
and then add eidIndex to error message like this:
Line 1338:
Message: fmt.Sprintf("request.user.eids[%d].uids[%d] contains empty ids and is removed from the request", eidIndex, uidIndex),
This will give error list with no duplicate error messages:
request.user.eids[0].uids[0] contains empty ids and is removed from the request
request.user.eids[2].uids[0] contains empty ids and is removed from the request
request.user.eids[2].uids[1] contains empty ids and is removed from the request
request.user.eids[2] (source: yahoo.com) contains only empty uids and is removed from the request
endpoints/openrtb2/auction.go
Outdated
for uidIndex, uid := range eid.UIDs { | ||
if uid.ID == "" { | ||
return append(errL, fmt.Errorf("request.user.eids[%d].uids[%d] missing required field: \"id\"", eidIndex, uidIndex)) | ||
} |
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.
At this time we will not have empty eid.ID
, correct? there is a check for this already in line 1334.
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.
Also do we need to set "clean" EIDs back to req.User.EIDs
?
Something like req.User.EIDs = validEids
after the for loop?
Please correct me if I'm wrong. We don't want to fail the entire request if there is at least one invalid EID, correct? Or do we want to drop invalid ones and continue the execution?
If we want to continue the execution - please add this fix and json tests where we validate "clean" user.EIDs and error messages.
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.
Can we remove if len(eid.UIDs) == 0 { validation also from validateUser function. This is also not possible because validateEids wil return error for emtpy uids. Please provide your suggestions @VeronikaSolovei9
…ver into Fix_3859
@Pubmatic-Supriya-Patil : Please respond to this comments. |
This PR solves issue #3859