-
Notifications
You must be signed in to change notification settings - Fork 832
Remove invalid user EIDs and UIDs from bid request #3891
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
0f955e9
Remove invalid user EIDs and UIDs from bid request
Pubmatic-Supriya-Patil 9352604
Merge branch 'master' of github.com:Pubmatic-Supriya-Patil/prebid-ser…
Pubmatic-Supriya-Patil 541cbed
Merge branch 'master' of github.com:Pubmatic-Supriya-Patil/prebid-ser…
Pubmatic-Supriya-Patil 22e6b21
Removed redundant check for uid.id validation
Pubmatic-Supriya-Patil db31c94
Merge branch 'master' of github.com:Pubmatic-Supriya-Patil/prebid-ser…
Pubmatic-Supriya-Patil 0f45f16
Merge branch 'master' of github.com:Pubmatic-Supriya-Patil/prebid-ser…
Pubmatic-Supriya-Patil 5514eae
Refactor EID validation to issue warnings for missing source field in…
Pubmatic-Supriya-Patil 74d9c26
Remove validation for empty UIDs in user EIDs
Pubmatic-Supriya-Patil 5d56a61
Merge branch 'prebid:master' into Fix_3859
Pubmatic-Supriya-Patil 5c45e53
Merge branch 'prebid:master' into Fix_3859
Pubmatic-Supriya-Patil 4dcd6c9
Update EID validation to remove entries with empty UIDs and add new t…
Pubmatic-Supriya-Patil 675bd31
Merge branch 'Fix_3859' of github.com:Pubmatic-Supriya-Patil/prebid-s…
Pubmatic-Supriya-Patil f6eea3c
Move user-eids-uids-empty.json to valid-whole folder
Pubmatic-Supriya-Patil ff59f36
Merge branch 'prebid:master' into Fix_3859
Pubmatic-Supriya-Patil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1277,23 +1277,64 @@ func (deps *endpointDeps) validateUser(req *openrtb_ext.RequestWrapper, aliases | |
} | ||
|
||
// Check Universal User ID | ||
for eidIndex, eid := range req.User.EIDs { | ||
if len(req.User.EIDs) > 0 { | ||
|
||
validEids, eidErrors := validateEIDs(req.User.EIDs) | ||
|
||
if len(eidErrors) > 0 { | ||
errL = append(errL, eidErrors...) | ||
} | ||
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. 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? |
||
req.User.EIDs = validEids | ||
} | ||
|
||
return errL | ||
} | ||
|
||
func validateEIDs(eids []openrtb2.EID) ([]openrtb2.EID, []error) { | ||
var errorsList []error | ||
validEIDs := make([]openrtb2.EID, 0, len(eids)) | ||
|
||
for eidIndex, eid := range eids { | ||
if eid.Source == "" { | ||
return append(errL, fmt.Errorf("request.user.eids[%d] missing required field: \"source\"", eidIndex)) | ||
errorsList = append(errorsList, &errortypes.Warning{ | ||
Message: fmt.Sprintf("request.user.eids[%d] removed due to missing source", eidIndex), | ||
WarningCode: errortypes.InvalidUserEIDsWarningCode, | ||
}) | ||
continue | ||
} | ||
validUIDs, uidErrors := validateUIDs(eid.UIDs, eidIndex) | ||
errorsList = append(errorsList, uidErrors...) | ||
|
||
if len(eid.UIDs) == 0 { | ||
return append(errL, fmt.Errorf("request.user.eids[%d].uids must contain at least one element or be undefined", eidIndex)) | ||
if len(validUIDs) > 0 { | ||
eid.UIDs = validUIDs | ||
validEIDs = append(validEIDs, eid) | ||
} else { | ||
errorsList = append(errorsList, &errortypes.Warning{ | ||
Message: fmt.Sprintf("request.user.eids[%d] (source: %s) removed due to empty uids", eidIndex, eid.Source), | ||
WarningCode: errortypes.InvalidUserEIDsWarningCode, | ||
}) | ||
} | ||
} | ||
|
||
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)) | ||
} | ||
return validEIDs, errorsList | ||
} | ||
|
||
func validateUIDs(uids []openrtb2.UID, eidIndex int) ([]openrtb2.UID, []error) { | ||
var validUIDs []openrtb2.UID | ||
var uidErrors []error | ||
|
||
for uidIndex, uid := range uids { | ||
if uid.ID != "" { | ||
validUIDs = append(validUIDs, uid) | ||
} else { | ||
uidErrors = append(uidErrors, &errortypes.Warning{ | ||
Message: fmt.Sprintf("request.user.eids[%d].uids[%d] removed due to empty ids", eidIndex, uidIndex), | ||
WarningCode: errortypes.InvalidUserUIDsWarningCode, | ||
}) | ||
} | ||
} | ||
|
||
return errL | ||
return validUIDs, uidErrors | ||
} | ||
|
||
func validateRegs(req *openrtb_ext.RequestWrapper, gpp gpplib.GppContainer) []error { | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.