-
Notifications
You must be signed in to change notification settings - Fork 748
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
sovrn: Add video support #2232
sovrn: Add video support #2232
Conversation
sort bids by price so multiple sovrn tags in a unit can function properly
sovrn adapter unit tests
adapters/sovrn/sovrn.go
Outdated
} | ||
|
||
return imp.TagID, nil | ||
return response, nil | ||
} | ||
|
||
func getTagid(sovrnExt openrtb_ext.ExtImpSovrn) string { |
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 curious what is the purpose of this function? I know this is not in scope of this PR, but do you think you need it?
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 have inherited this code from someone who is no longer at Sovrn. But it appears that our original work with Prebid Server used a spelling on our tagid parameter that we quickly decided was wrong. 😄
So the old version is deprecated, but not removed yet. Not sure how we will go forward with the actual removal, but we will figure that out.
.devcontainer/devcontainer.json
Outdated
@@ -10,6 +10,7 @@ | |||
// Options | |||
"INSTALL_NODE": "false", | |||
"NODE_VERSION": "lts/*", | |||
"TEST": "false" |
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 remove this line, you probably pushed it accidentally.
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.
Fixed.
if video != nil { | ||
if video.MIMEs == nil || | ||
video.MinDuration == 0 || | ||
video.MaxDuration == 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.
Please review this logic again. For video endpoint there is a possibility to have only maxDuration when requireExactDuration
if false or not specified. In this case the entire request will be rejected.
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'll need to review this with product. I'll let you know how that conversation goes.
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.
@cpabst Were you able to check about this with your team?
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.
He has been very busy. 😄
I'd like to keep it this way, and look at this idea as a future enhancement. I see others doing it the same way.
} | ||
if request.Imp[0].Video != nil { | ||
bidType = openrtb_ext.BidTypeVideo | ||
} |
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.
In case you return bid type in bid.ext we recommend to use this approach:
prebid-server/adapters/algorix/algorix.go
Line 190 in c93a036
func getBidType(bid openrtb2.Bid, imps []openrtb2.Imp) (openrtb_ext.BidType, error) { |
It will also help to determine bid type correctly in case if req.imp is multi typed.
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 do not support multi-typed imps yet.
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 may not support it, but request may have it. In your code you take imp type from request and match it with response: request.Imp[impIdx]
imp.TagID = getTagid(sovrnExt) | ||
|
||
if imp.BidFloor == 0 && sovrnExt.BidFloor > 0 { | ||
imp.BidFloor = sovrnExt.BidFloor |
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 add coverage for this branch?
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.
Done. Fixed a bunch of other tests as well.
adapters/sovrn/sovrn.go
Outdated
errs = append(errs, &errortypes.BadInput{ | ||
Message: "Missing required video parameter", | ||
}) | ||
return nil, errs |
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.
Are you sure you wanna throw away the entire request only if a single video imp isn't valid? You could just continue
here and process the imps that are valid.
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.
Good point. Thanks.
} | ||
} | ||
if request.Imp[0].Video != nil { | ||
bidType = openrtb_ext.BidTypeVideo |
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 mentioned by @VeronikaSolovei9, this can return the wrong bid type in case where the imp is a multi-format imp. But also, since you're only looking at the first imp in the request, this might also return the wrong bid types if not all imps in the request are of same type. For example, say the first imp in the request is of type video but the second one is of type banner, then you'll be returning wrong bid type for the bid corresponding to the second imp.
We highly recommend using bid.Ext.MediaType
to send back this information to Prebid Server.
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 solving this presently with using the Bid.impid value to set bid type. We will look into using the recommended value in the future.
@@ -20,7 +20,8 @@ | |||
"bidder": { | |||
"tagid": "123456" | |||
} | |||
} | |||
}, |
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.
Wondering why was imp.tagid
added to this and a few other test requests in this PR? Won't it be added by your adapter code based on what you have in your tagid bidder param?
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.
Yep. Figured that out today. Those all should be fixed now.
} | ||
] | ||
}, | ||
"bidfloor": 4.2, |
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 test name indicates that this test case is where there's only custom bid floor present, which as I understand is the one in the bidder ext. In that case shouldn't this be not present in the original request? This will then be filled by your adapter
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.
Yes, you are correct. This has been fixed.
"format": [ | ||
{ | ||
"w": 300, | ||
"h": 250 |
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.
Consider the imp order reversed in this test case where the first imp is a video imp and the second one is the banner imp, in that case the bid type in the response will be incorrectly set to video
.. Now also consider the imps in the same order as you have in this test, if your bidder service were to send back a bid for the video imp as well, in this case the video bid would have the bid type incorrectly set to banner
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 believe this has been solved by using the response Bid.impid
value.
@mansinahar @VeronikaSolovei9 I have made quite a few updates based on these comments. This PR is ready for another review. |
adapters/sovrn/sovrn.go
Outdated
continue | ||
} | ||
|
||
imp.TagID = getTagid(sovrnExt) |
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've already gotten the tagId
value from the getTagid
function on L63 so this line should be just:
imp.TagID = tagId
Also, can you please rename the getTagid
function to getTagId
?
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.
Both done
return nil, errs | ||
} | ||
|
||
reqJSON, err := json.Marshal(request) |
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 point, this request can have both valid and invalid imps because on L92 you're just reassigning the valid imps to the same place in the imps array of the request. You'd actually have to remove the invalid ones as you find them in the for loop so that you're only left with the valid ones or a much easier way would be to just create a new validImps
array and keep appending each valid imp you find to that array and then outside the for loop, you can just replace request.Imp
with that new validImps
array before JSON marshalling
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.
Good point. Done.
adapters/sovrn/sovrn.go
Outdated
@@ -75,71 +116,54 @@ func addHeaderIfNonEmpty(headers http.Header, headerName string, headerValue str | |||
} | |||
} | |||
|
|||
func (s *SovrnAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { | |||
if response.StatusCode == http.StatusNoContent { | |||
func (s *SovrnAdapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { |
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: The names requestData
and responseData
don't really convey the proper context here IMHO. How about using, bidderRequest
and bidderResponse
, respectively?
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.
Sure. 😄
adapters/sovrn/sovrn.go
Outdated
} | ||
} | ||
|
||
return -1 // hopefully this never happens |
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 be returning an error if this does happen.. This would mean that for some reason your bidder bid for an imp that doesn't match an ID with the imps in the request. By returning an explicit error, it will be much easier to debug and fix the issue rather than silently just setting the bid type to banner
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 see your point. I believe I have fixed this correctly now. Please let me know if you feel otherwise.
adapters/sovrn/sovrn.go
Outdated
} | ||
} | ||
|
||
return -1 // hopefully this never happens | ||
return -1, &errortypes.BadInput{ | ||
Message: fmt.Sprintf("Could not find imp ID '%s' in bid, dropping bid", impId), |
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.
Could you please rephrase this as something like:
Imp ID %s in bid didn't match with any imp in the original request
The above indicates we're trying to find the imp ID in a list of bids whereas the other way round is true. We're trying to match the impID in the bid with the list of imps in the request
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.
Works for me. Done.
{ | ||
"mockBidRequest": { | ||
"id": "test-request-id", | ||
"imp": [ |
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.
Is this test case testing anything different from the full video test case you have above?
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 one just has the required parameters, and the other one has all parameters. I like that it shows the minimum viable request, but don't feel strongly if you'd like it to go.
} | ||
} | ||
}, | ||
"mockResponse": { |
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 consider adding a response for video as well in this test case. This will allow this test case to verify that responses with multiple bids for various imps are processed correctly and will also verify the getBidType logic to make sure it matches bids to imps properly based on the imp ID
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.
Good point. Done.
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.
Good point. Done.
|
||
impIdx, impIdErr := getImpIdx(bid.ImpID, request) | ||
if impIdErr != nil { | ||
errs = append(errs, impIdErr) |
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 this error condition
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.
Done.
@cpabst Thanks for addressing the comments. This is looking to be in good shape now. Just have a couple minor comments. |
No description provided.