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

Adding type to native markup for Prebid mobile #1081

Merged
merged 4 commits into from
Oct 29, 2019
Merged

Conversation

jaiminpanchal27
Copy link
Contributor

This PR implements #1041

exchange/bidder.go Show resolved Hide resolved
exchange/bidder.go Outdated Show resolved Hide resolved
exchange/bidder.go Outdated Show resolved Hide resolved
exchange/bidder.go Outdated Show resolved Hide resolved
exchange/bidder.go Outdated Show resolved Hide resolved
exchange/bidder.go Outdated Show resolved Hide resolved
@jaiminpanchal27
Copy link
Contributor Author

@SyntaxNode Thanks for feedback. I pushed an update

exchange/bidder.go Outdated Show resolved Hide resolved
SyntaxNode
SyntaxNode previously approved these changes Oct 18, 2019
if err != nil {
errs = append(errs, err)
}
bidResponse.Bids[i].Bid.AdM = string(markup)
Copy link
Collaborator

Choose a reason for hiding this comment

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

If there were errors in the marshalling, do we still want to we still want to try overwriting the AdM with whatever json.Marshal() managed to spit out?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point. markup very well may be nil, of which string(markup) would succeed and result in an empty 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.

Agreed. Updated

Copy link
Contributor

@anwzhang anwzhang left a comment

Choose a reason for hiding this comment

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

Looks like no need to have PBM to pass in anything to request types?

@jaiminpanchal27
Copy link
Contributor Author

@anwzhang Correct. If request.App flag is only set when the request is from mobile device, we are all set

errs = append(errs, err)
}
var nativePayload nativeRequests.Request
if err := json.Unmarshal(json.RawMessage((*nativeImp).Request), &nativePayload); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We have a potential panic here. If getNativeImpByImpID() fails to find the imp, then nativeImp is nil. Trying to access nil.Request will then panic, as you cannot dereference a nil. You should probably abort above if nativeImp is nil. I don't think we need to abort here on Unmarshal errors as the worst that should happen is we fail asset lookups and don't do anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

"impid": "my-imp-id",
"price": 10,
"adid": "1234",
"adm": "{\"assets\":[{\"id\":1,\"img\":{\"type\":3,\"url\":\"http://vcdn.adnxs.com/p/creative-image/f8/7f/0f/13/f87f0f13-230c-4f05-8087-db9216e393de.jpg\",\"w\":989,\"h\":742,\"ext\":{\"appnexus\":{\"prevent_crop\":0}}}},{\"title\":{\"text\":\"This is a Prebid Native Creative\"}},{\"id\":2,\"data\":{\"type\":1,\"value\":\"Prebid.org\"}},{\"id\":3,\"data\":{\"type\":2,\"value\":\"This is a Prebid Native Creative. There are many like it, but this one is mine.\"}}],\"link\":{\"url\":\"http://some-url.com\"},\"imptrackers\":[\"http://someimptracker.com\"],\"jstracker\":\"some-js-tracker\"}",
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the mock response, don't you want the adapter to return native markup without types being set, so you can verify the code does actually set the types?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I misunderstood the exchange_test.go Now I moved my test to bidder_test.go

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.

See my inline comments

@jaiminpanchal27
Copy link
Contributor Author

@hhhjort Pushed an update. Addressed all your feedback

@SyntaxNode SyntaxNode merged commit 4357bb5 into master Oct 29, 2019
katsuo5 pushed a commit to flux-dev-team/prebid-server-1 that referenced this pull request Dec 1, 2020
katsuo5 pushed a commit to flux-dev-team/prebid-server-1 that referenced this pull request Dec 2, 2020
katsuo5 pushed a commit to flux-dev-team/prebid-server-1 that referenced this pull request Dec 4, 2020
@SyntaxNode SyntaxNode deleted the native-types branch March 13, 2023 13:52
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