-
Notifications
You must be signed in to change notification settings - Fork 693
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
Unruly r1 consolidated adapter #1997
Unruly r1 consolidated adapter #1997
Conversation
…rt the new consolidated adapter changes
* remove S2S param * remove usersync since we do this on our server side now
* change the siteid type to be int instead of string
Please resolve merge conflicts on file |
# Conflicts: # usersync/usersyncers/syncer.go
I believe I resolved the conflicts. |
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.
Left some comments below
@@ -1,6 +1,5 @@ | |||
package openrtb_ext | |||
|
|||
type ExtImpUnruly struct { | |||
UUID string `json:"uuid"` | |||
SiteID string `json:"siteid"` | |||
SiteID int `json:"siteid"` |
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.
Has the param list been updated in the docs PR?
https://github.com/prebid/prebid.github.io/blob/master/dev-docs/bidders/unruly.md
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 it is updated.
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.
thank you
adapters/unruly/unruly.go
Outdated
@@ -13,136 +13,136 @@ import ( | |||
) | |||
|
|||
type UnrulyAdapter struct { |
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 please rename to simply adapter
? If not, could we avoid capitalization? There's no need to export this particular strucrture.
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
adapters/unruly/unruly.go
Outdated
for i := 0; i < numRequests; i++ { | ||
imp := req.Imp[i] | ||
var bidderExt adapters.ExtImpBidder | ||
err := json.Unmarshal(imp.Ext, &bidderExt) | ||
if err != 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.
Can we contract the Unmarshal
call error checks in lines 59-60 and 68-69?
58 var bidderExt adapters.ExtImpBidder
59 - err := json.Unmarshal(imp.Ext, &bidderExt)
60 - if err != nil {
+ if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil {
61 err = &errortypes.BadInput{
62 Message: fmt.Sprintf("ext data not provided in imp id=%s. Abort all Request", imp.ID),
63 }
64 errors = append(errors, err)
65 return nil, "", errors
66 }
adapters/unruly/unruly.go
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
adapters/unruly/unruly.go
Outdated
} | ||
|
||
var errs []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.
I notice that the errs
array doesn't get populated in the rest of the function. Is it still needed? Should we return an empty error array in line 132 instead?
132 - return bidResponse, errs
+ return bidResponse, []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.
changed both this to return the errors from the changes from the next comment
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.
Thanks
mediaType = openrtb_ext.BidTypeBanner | ||
} else if imp.Video != nil { | ||
mediaType = 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.
Should we code a bit more defensively and return an error in case a given impId
doesn't match with any of the imp.ID
s in the array or if a given imp comes with both a imp.Banner == nil
and imp.Video == nil
? Maybe the error that getMediaTypeForImp
returns could end up in MakeBids
' unused errs
array.
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, I hope this is what you meant.
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 did. Thank you
@opeledtremor Just a friendly ping about the comments above. |
adapters/unruly/unruly.go
Outdated
} | ||
var unrulyExt openrtb_ext.ExtImpUnruly | ||
//err = json.Unmarshal(bidderExt.Bidder, &unrulyExt) | ||
//if err != 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.
I believe these commented lines are a left-over
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.
removed
adapters/unruly/unruly.go
Outdated
} | ||
|
||
var errs []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.
Thanks
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.
It looks pretty good. I have two last minor nitpicks and after those get resolved, I think I'll be ready to approve.
adapters/unruly/unruly.go
Outdated
for _, sb := range bidResp.SeatBid { | ||
for i := range sb.Bid { | ||
bidType, err := getMediaTypeForImpWithId(sb.Bid[i].ImpID, internalRequest.Imp) | ||
var bla, err = getMediaTypeForImp(sb.Bid[i].ImpID, internalRequest.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.
Nitpick: Can we rename bla
to bidType
or something more descriptive?
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
adapters/unruly/unruly.go
Outdated
unrulyExtCopy, err := json.Marshal(&unrulyExt) | ||
if err != nil { | ||
errors = append(errors, err) | ||
return nil, "", errors | ||
} |
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.
If you want a copy of the unrulyExt as JSON, why marshal what was just unmarshaled? At this point, you've verified unrulyExt
is valid since it was successfully unmarshaled and it was not mutated so couldn't you just make a copy of bidderExt.Bidder
instead and avoid the additional marshal call? Or are you leaning on the marshal call here to remove data other than siteid
?
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 we are leaning on the marshal call here to remove data other than siteid
adapters/unruly/unruly.go
Outdated
if uri == "" { | ||
uri = fmt.Sprintf("%s", a.endPoint) | ||
} |
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.
It seems like this should be outside of the for
loop.
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.
removed since we removed the uri according to the next comment
adapters/unruly/unruly.go
Outdated
if err != nil { | ||
return nil, []error{err} | ||
var uri string | ||
request, uri, errs = a.preProcess(request, 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.
It looks like you could simplify the preProcess
method by eliminating the url
return value and just looking at a.endpoint
here by changing line 38 in this function from to if a.endpoint != ""
and then changing line 44 to Uri: a.endpoint
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
adapters/unruly/unruly.go
Outdated
} else { | ||
errs = append(errs, fmt.Errorf("impId doesn't match with any of 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.
It looks like this else
statement could execute multiple times and if imp.ID == impId
is never true, the error slice will contain this same error once for every imp in the original 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.
changed it to be only 1 error with all the non matching imps
return imp, nil | ||
} | ||
func getMediaTypeForImp(impId string, imps []openrtb2.Imp) (openrtb_ext.BidType, []error) { | ||
var errs []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.
This function never returns 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.
fixed
return openrtb_ext.BidTypeVideo, nil | ||
} | ||
func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { | ||
if response.StatusCode == http.StatusNoContent { |
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 for when the status code is 204.
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
return "", &errortypes.BadInput{ | ||
Message: fmt.Sprintf("Failed to find impression \"%s\" ", impID), | ||
|
||
if response.StatusCode == http.StatusBadRequest { |
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 for when the status code is 400.
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
return &errortypes.BadServerResponse{ | ||
Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode), | ||
} | ||
return nil, []error{&errortypes.BadServerResponse{ |
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 with another error code so that the BadServerResponse
is returned.
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.
added another BadServerResponse for the 401 response
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 is looking good; I have just a few more comments on getMediaTypeForImp
.
adapters/unruly/unruly.go
Outdated
} else { | ||
errs = append(errs, fmt.Errorf("bid responses mediaType didn't match supported mediaTypes")) | ||
} | ||
return mediaType, 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.
Shouldn't this be return mediaType, errs
so the "didn't match supported mediaTypes" error is returned?
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
adapters/unruly/unruly.go
Outdated
func (a *UnrulyAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { | ||
if err := CheckResponse(response); err != nil { | ||
return nil, []error{err} | ||
if len(noMatchingImps) > 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.
Given that you always return if the imp is found, I don't think you need this conditional check as it appears the only way you would reach this part of the function is if the bid response imp ID was not found in the bid 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.
If I understood you correctly it's done (removed the condition)
adapters/unruly/unruly.go
Outdated
if err := CheckResponse(response); err != nil { | ||
return nil, []error{err} | ||
if len(noMatchingImps) > 0 { | ||
errs = append(errs, fmt.Errorf("the following imps id's %v didn't match impId %s", noMatchingImps, 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.
Perhaps this error should be a little more generic and not include a variable name like impId
in it. How about something like: "Bid response imp ID %s not found in bid request containing imps %v\n"?
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
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.
LGTM
This is a consolidated adapter between the Unruly adapter and the RhythmOne Adapter.
Now the unruly adapter use the new endpoint and has the same support as the RhythmOne Adapter with the relevant params.