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

Per Impression TID Generation and Source TID Logic Updated #2412

Merged
merged 6 commits into from
Jan 12, 2023

Conversation

ccorbo
Copy link
Contributor

@ccorbo ccorbo commented Oct 7, 2022

This PR is to update the logic SourceTID logic when enabled to fill source tid. This is related to #2381.

Logic is outlined in this issue: #2381 (comment)

Changes in this PR:

  • Logic update in validateAndFillSourceTid to support the logic outlined above
  • Changes to ImpWrapper to support accessing and setting tid in imp.ext
  • Unit tests added to support the above changes

@bsardo bsardo self-requested a review October 10, 2022 17:34
@bsardo bsardo self-assigned this Oct 10, 2022
@SyntaxNode SyntaxNode self-requested a review October 12, 2022 21:32
@SyntaxNode SyntaxNode self-assigned this Oct 12, 2022
Copy link
Collaborator

@bsardo bsardo left a comment

Choose a reason for hiding this comment

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

I opened up a comment on the corresponding feature request issue to verify the requirements:
#2381 (comment)

endpoints/openrtb2/auction.go Show resolved Hide resolved
endpoints/openrtb2/auction.go Outdated Show resolved Hide resolved
req.Source.TID = req.ID
if rawUUID, err := uuid.NewV4(); err == nil {
ie.SetTid(rawUUID.String())
impWrapper.RebuildImp()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe we should be rebuilding the imps here but I need to confirm. By doing so we would ensure that after the validation phase the imps on the request accurately reflect any changes made to exts on the wrapper.

endpoints/openrtb2/auction_test.go Outdated Show resolved Hide resolved
openrtb_ext/request_wrapper.go Show resolved Hide resolved
openrtb_ext/request_wrapper.go Outdated Show resolved Hide resolved
openrtb_ext/request_wrapper.go Outdated Show resolved Hide resolved
openrtb_ext/request_wrapper_test.go Show resolved Hide resolved
Copy link
Collaborator

@bsardo bsardo left a comment

Choose a reason for hiding this comment

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

The updates look good. I'm waiting for confirmation on the requirements before approving and I'll look into my comment about RebuildImp.

@bsardo
Copy link
Collaborator

bsardo commented Oct 19, 2022

Also just for future reference, if you could avoid force pushing after the PR has been reviewed that would be ideal. We prefer you just push another commit with your changes as this helps the reviewers save a lot of time since they often only need to review the delta. And if conflicts arise they can be resolved by merging with master instead of rebasing with a force push 🙂. Thanks again for your contribution; I'll be on the lookout for confirmation on the requirements.

@ccorbo
Copy link
Contributor Author

ccorbo commented Oct 19, 2022

Thank you for the review and sounds good! I'll make sure to merge instead of rebasing next time when merging master.

@bsardo
Copy link
Collaborator

bsardo commented Nov 7, 2022

@ccorbo I noticed you pushed up a bunch of commits, which I assume are in accordance with the new requirements. Is this ready for review?

@ccorbo
Copy link
Contributor Author

ccorbo commented Nov 7, 2022

@ccorbo I noticed you pushed up a bunch of commits, which I assume are in accordance with the new requirements. Is this ready for review?

@bsardo Yes this is ready for review, thanks in advance!

req.Source.TID = rawUUID.String()
}

if generateRequestID && (isAmp || hasStoredBidRequest) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We may want to put this if statement in an else from the if above, so that we don't call rawUUID.String() twice.

Actually we probably want to put it all into one, so we don't call uuid.NewV4() when we don't have to, and potentially error out when we don't even have to generate a random UUID for the request.

	if  req.Source.TID == "" || req.Source.TID == "{{UUID}}" || ( generateRequestID && (isAmp || hasStoredBidRequest) ) {
	    rawUUID, err := uuid.NewV4()
	    if err != nil {
		return errors.New("error creating a random UUID for source.tid")
	    }
	    req.Source.TID = rawUUID.String()
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for the review, updated

if err != nil {
return errors.New("imp.ext.tid missing in the imp and error creating a random UID")
}
if ie.GetTid() == "" || ie.GetTid() == "{{UUID}}" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't we also check that req.Source.Tid was originally empty before setting imp.ext.tid as per the spec in this PR? Probably need to set a boolean to indicate if this was empty before the code above is executed, or move this above setting req.Source.Tid.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry my PR summary was outdated, now updated. The logic comes from Bret's comment on this issue if you want to cross reference. We went away from tying source.tid to imp.ext.tid

#2381 (comment)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Okay, if we are adhering to what prebid.js is already doing, then I am okay. There is a bit of tension between allowing publishers to send in IDs while also leveraging stored requests for config management vs. dealing with IDs that were inadvertently put into a stored request rendering them static.

@hhhjort
Copy link
Collaborator

hhhjort commented Nov 28, 2022

Seems like something odd happened with the merge from master. Github is showing all the new code from master as new code, not recognizing it as code that already exists in master.

@ccorbo ccorbo changed the base branch from master to 0.69.0 November 28, 2022 21:10
@ccorbo ccorbo changed the base branch from 0.69.0 to master November 28, 2022 21:10
@ccorbo
Copy link
Contributor Author

ccorbo commented Nov 28, 2022

Seems like something odd happened with the merge from master. Github is showing all the new code from master as new code, not recognizing it as code that already exists in master.

weird, might of been because I mixed rebasing and merging, anyway rebased and its showing the correct diff now

hhhjort
hhhjort previously approved these changes Nov 29, 2022
Copy link
Collaborator

@hhhjort hhhjort left a comment

Choose a reason for hiding this comment

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

LGTM

@bsardo bsardo assigned AlexBVolcy and unassigned bsardo Dec 8, 2022
AlexBVolcy
AlexBVolcy previously approved these changes Dec 9, 2022
@bsardo
Copy link
Collaborator

bsardo commented Jan 9, 2023

@ccorbo would you mind merging with master to resolve the conflicts when you get a moment? Thanks!

@ccorbo
Copy link
Contributor Author

ccorbo commented Jan 9, 2023

@ccorbo would you mind merging with master to resolve the conflicts when you get a moment? Thanks!

Thanks for the ping @bsardo, merged master and conflicts are resolved

hhhjort
hhhjort previously approved these changes Jan 10, 2023
Copy link
Contributor

@AlexBVolcy AlexBVolcy left a comment

Choose a reason for hiding this comment

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

Looks good! Just one small test coverage comment

Comment on lines +1304 to +1305
if hasTid {
if err := json.Unmarshal(tidJson, &e.tid); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a test where if hasTid is true? I noticed that the code block where it is true isn't covered by tests. I'm not looking for the unmarshal return err line (line 1306) to be covered, but line 1305 should be covered, just to show that hasTid being true is being tested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, just added test coverage around this block

Copy link
Contributor

@AlexBVolcy AlexBVolcy left a comment

Choose a reason for hiding this comment

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

LGTM

@bsardo bsardo merged commit 82c03b0 into prebid:master Jan 12, 2023
shunj-nb pushed a commit to ParticleMedia/prebid-server that referenced this pull request Jan 31, 2023
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.

5 participants