Skip to content

New Adapter: UNICORN #1719

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 25 commits into from
Mar 4, 2021
Merged

Conversation

faithnh
Copy link
Contributor

@faithnh faithnh commented Feb 22, 2021

@SyntaxNode SyntaxNode self-requested a review February 22, 2021 18:16
@SyntaxNode SyntaxNode self-assigned this Feb 22, 2021
Copy link
Contributor

@SyntaxNode SyntaxNode left a comment

Choose a reason for hiding this comment

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

Thank you for reading the our new bidder docs.

SyntaxNode
SyntaxNode previously approved these changes Feb 25, 2021
Copy link
Contributor

@guscarreon guscarreon left a comment

Choose a reason for hiding this comment

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

Looks pretty good. A couple of comments before approving

return nil, []error{err}
}

request.Source.Ext = setSourceExt()
Copy link
Contributor

Choose a reason for hiding this comment

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

Prebid server core passes a shallow copy of the openrtb.BidRequest object to the MakeRequest() function which makes pointer fields like Source to be red flags because they point to shared memory.

 14 type BidRequest struct {
 15
          .
          .
185
186     // Attribute:
187     //   source
188     // Type:
189     //   object
190     // Description:
191     //   A Sorce object (Section 3.2.2) that provides data about the
192     //   inventory source and which entity makes the final decision.
193     Source *Source `json:"source,omitempty"`
          .
          .
211 }
~/go/pkg/mod/github.com/mxm!cherry/[email protected]+incompatible/bid_request.go [RO]

Please create a new Source object copy locally and assign to the bidRequest. Notice that, depending on its initial configuration, prebid server core may or may not initialize bidRequest.Source field if it comes with a nil value (see endpoints/openrtb2/auction.go's line 311). In summary, we could do something like:

67     err := modifyImps(request, requestInfo)
68     if err != nil {
69         return nil, []error{err}
70     }
71
72 -   request.Source.Ext = setSourceExt()
   +   if request.Source != nil {
   +       modifiableSource = *request.Source
   +   } else {
   +       modifiableSource = &openrtb.Source{}
   +   }
   +   modifiableSource.Ext = setSourceExt()
   +   request.Source = modifiableSource
73
74     request.Ext, err = setExt(request)
75     if err != nil {
76         return nil, []error{err}
77     }
adapters/unicorn/unicorn.go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed it. Thank you so much!

c27da8b

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed again because there is have copying source problem.

fb58a7e

return headers
}

func modifyImps(request *openrtb.BidRequest, requestInfo *adapters.ExtraRequestInfo) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

The second parameter requestInfo *adapters.ExtraRequestInfo seems to not be used by this function at all. Do we need it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Certainly, requestInfo *adapters.ExtraRequestInfo is not used. Fixed it. Thank you!

c27da8b

Copy link
Contributor

@guscarreon guscarreon left a comment

Choose a reason for hiding this comment

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

@faithnh thank you for addressing the feedback. Your adapter looks pretty solid

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.

3 participants