-
Notifications
You must be signed in to change notification settings - Fork 769
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
TheMediaGrid: support native mediaType #2377
Conversation
adapters/grid/grid.go
Outdated
@@ -75,6 +77,22 @@ type KeywordsPublisherItem struct { | |||
Segments []KeywordSegment `json:"segments"` | |||
} | |||
|
|||
type GridNative 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.
This struct has no usages
adapters/grid/grid.go
Outdated
Ext json.RawMessage `json:"ext,omitempty"` | ||
} | ||
|
||
type NativeImp 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.
This struct has no usages
adapters/grid/grid.go
Outdated
Native json.RawMessage `json:"native,omitempty"` | ||
} | ||
|
||
type NativeGridRequest 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.
This struct has no usages. Please delete them
@@ -312,6 +359,9 @@ func (a *GridAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapte | |||
request.Imp = validImps | |||
|
|||
reqJSON, err := json.Marshal(request) | |||
|
|||
fixedReqJSON, err := fixNative(reqJSON) |
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 do not ignore error from the previous statement
if err := json.Unmarshal([]byte(request), &parsedRequest); err == nil { | ||
native["request_native"] = parsedRequest | ||
} else { | ||
native["request_native"] = 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 you want to set native.request back even if err!=nil
. What data other than json do you expect here?
Here you want to replace imp.native.request
to imp.native.request_native
, that is not a part of openRTB, right?
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.
That's right, but even if we got errors when trying to parse json , we still want to get native.request to be able to see what the value is
var gridReq map[string]interface{} | ||
var parsedRequest map[string]interface{} | ||
|
||
if err := json.Unmarshal(req, &gridReq); 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.
Right before executing this function you reqJSON, err := json.Marshal(request)
. Do you think it will be easier to pass openrtb2.BidRequest
here instead of req json.RawMessage
?
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 guess it would be easier to operate on abstract json since we need to change its structure
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 it now, ok!
Thank you for the updates. file grid.go Line 302 is not covered by unit tests and the way to do this - is to add test similar to "simple-native.json" and set req.imp[].native.request to string like "hello". It will throw the Unmarshal error and L304 will be executed. |
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
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 for addressing comments, LGTM
* origin/master: (316 commits) Fix alt bidder code test broken by imp wrapper commit (prebid#2405) ImpWrapper (prebid#2375) Update sspBC adapter to v5.7 (prebid#2394) Change errors to warnings (prebid#2385) TheMediaGrid: support native mediaType (prebid#2377) Huaweiadsadapter gdpr (prebid#2345) Add alternatebiddercodes in Prebid request ext (prebid#2339) Changed FS bidder names to mixed case (prebid#2390) Load bidders names from file system in lowercase (prebid#2388) consumable adapter: add schain and coppa support (prebid#2361) Adapter aliases: moved adapter related configs to bidder.yaml files (prebid#2353) pubmatic adapter: add param prebiddealpriority (prebid#2281) Yieldlab Adapter: Add support for ad unit sizes (prebid#2364) GDPR: add enforce_algo config flag and convert enforce_purpose to bool (prebid#2330) Resolves CVE-2022-27664 (prebid#2376) AMP Endpoint: support parameters consentType and gdprApplies (prebid#2338) Dianomi - added usync for redirect (prebid#2368) Create issue_prioritization.yml (prebid#2372) Update yaml files for gzip supported bidders (prebid#2365) Adnuntius Adapter: Set no cookies as a parameter (prebid#2352) ...
doc update PR - prebid/prebid.github.io#4017