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

New Adapter: Mediasquare #3994

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

mediasquare-alexandre
Copy link
Contributor

@mediasquare-alexandre mediasquare-alexandre commented Oct 18, 2024

Summary
This PR introduces the Mediasquare bidder adapter for Prebid Server. It supports the following mediatypes:

  • Banner
  • Video
  • Native

Endpoint: "https://pbs-front.mediasquare.fr/msq_prebid"
Endpoint Compression: gzip
GVL Vendor ID: 791

Test Status
Unit tests: All tests passed.

Maintainer Contact
emails:

About us
https://www.mediasquare.fr/

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, f49cc00

mediasquare

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/mediasquare/mediasquare.go:19:	Builder			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/mediasquare.go:25:	MakeRequests		95.8%
github.com/prebid/prebid-server/v2/adapters/mediasquare/mediasquare.go:73:	makeRequest		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/mediasquare.go:94:	MakeBids		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:16:		setContent		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:27:		getValue		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:45:		setContent		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:56:		value			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:67:		getValue		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/structs.go:185:		initMsqParams		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/structs.go:205:		setContent		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/structs.go:279:		getContent		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:24:		mType			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:36:		bidType			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:48:		extBid			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:59:		loadExtBid		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:78:		extBidPrebidMeta	100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:88:		ptrInt8ToBool		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:96:		intToPtrInt		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:102:		errorWritter		100.0%
total:										(statements)		99.4%

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, 355ddb0

mediasquare

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/mediasquare/mediasquare.go:19:	Builder			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/mediasquare.go:25:	MakeRequests		95.8%
github.com/prebid/prebid-server/v2/adapters/mediasquare/mediasquare.go:73:	makeRequest		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/mediasquare.go:94:	MakeBids		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:16:		setContent		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:27:		getValue		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:45:		setContent		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:56:		value			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:67:		getValue		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/structs.go:185:		initMsqParams		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/structs.go:205:		setContent		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/structs.go:279:		getContent		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:24:		mType			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:36:		bidType			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:48:		extBid			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:59:		loadExtBid		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:78:		extBidPrebidMeta	100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:88:		ptrInt8ToBool		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:96:		intToPtrInt		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:102:		errorWritter		100.0%
total:										(statements)		99.4%

@mediasquare-alexandre mediasquare-alexandre changed the title New Adapter Mediasquare New Adapter: Mediasquare Oct 24, 2024
@przemkaczmarek przemkaczmarek self-assigned this Oct 30, 2024
@przemkaczmarek przemkaczmarek self-requested a review October 30, 2024 11:55
gvlVendorID: 791
modifyingVastXmlAllowed: true
maintainer:
email: "[email protected]"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I sent email, please response.

Copy link
Collaborator

Choose a reason for hiding this comment

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

email confirmed:
image

Copy link
Contributor

Choose a reason for hiding this comment

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

Unresolving this discussion to ask a question.
We generally prefer to have a corporate email, not personal.
Please refer to "medianet.yaml", "mediafuse.yaml", "appnexus.yaml".
Is this possible you can update it?

Copy link
Contributor

@VeronikaSolovei9 VeronikaSolovei9 Jan 22, 2025

Choose a reason for hiding this comment

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

Just found in the description: [email protected]
This will work better, please update, assuming this is a working email.

@@ -0,0 +1,12 @@
endpoint: "http://pbs-front.mediasquare.fr/msq_prebid"
Copy link
Collaborator

Choose a reason for hiding this comment

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

image

503 response, please fix

@przemkaczmarek
Copy link
Collaborator

@mediasquare-alexandre Hi, I’m wondering why these tests were written in this way. In most adapters, we approach it by having a TestJsonSamples class, where we write JSON files to check our scenarios, like simple-banner.json, bad_media_type, etc. Additionally, we add a params_test class to verify validParams and invalidParams.
Were you aware of this pattern?
@bsardo we should decide if we accept these new adapters in this form.

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, c7221a2

mediasquare

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/mediasquare/mediasquare.go:19:	Builder			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/mediasquare.go:25:	MakeRequests		95.8%
github.com/prebid/prebid-server/v2/adapters/mediasquare/mediasquare.go:73:	makeRequest		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/mediasquare.go:94:	MakeBids		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:16:		setContent		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:27:		getValue		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:45:		setContent		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:56:		value			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/parsers.go:67:		getValue		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/structs.go:185:		initMsqParams		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/structs.go:205:		setContent		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/structs.go:279:		getContent		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:24:		mType			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:36:		bidType			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:48:		extBid			100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:59:		loadExtBid		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:78:		extBidPrebidMeta	100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:88:		ptrInt8ToBool		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:96:		intToPtrInt		100.0%
github.com/prebid/prebid-server/v2/adapters/mediasquare/utils.go:102:		errorWritter		100.0%
total:										(statements)		99.4%

@mediasquare-alexandre
Copy link
Contributor Author

mediasquare-alexandre commented Oct 30, 2024

@mediasquare-alexandre Hi, I’m wondering why these tests were written in this way. In most adapters, we approach it by having a TestJsonSamples class, where we write JSON files to check our scenarios, like simple-banner.json, bad_media_type, etc. Additionally, we add a params_test class to verify validParams and invalidParams. Were you aware of this pattern? @bsardo we should decide if we accept these new adapters in this form.

Hi Guys, honestly when I started doing my tests I remembered my PR 2 years ago here where most of my reviewers asked me to increase the code-coverage as much as possible. #2215
So I took a look on the package which has been authorized in my last PR and adjust the code as much as possible to increase the cover-rate. Just hope I didn't do bad by doing so for you guys @przemkaczmarek @bsardo
I'm waiting for your reply, I have already fixed the problem you put to light @przemkaczmarek

Copy link

github-actions bot commented Nov 3, 2024

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, 747bff3

mediasquare

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:19:	Builder			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:25:	MakeRequests		95.8%
github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:73:	makeRequest		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:94:	MakeBids		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:16:		setContent		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:27:		getValue		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:45:		setContent		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:56:		value			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:67:		getValue		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/structs.go:185:		initMsqParams		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/structs.go:205:		setContent		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/structs.go:279:		getContent		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:24:		mType			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:36:		bidType			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:48:		extBid			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:59:		loadExtBid		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:78:		extBidPrebidMeta	100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:88:		ptrInt8ToBool		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:96:		intToPtrInt		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:102:		errorWritter		100.0%
total:										(statements)		99.4%

Copy link

github-actions bot commented Nov 3, 2024

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, 8de23e9

mediasquare

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:19:	Builder			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:25:	MakeRequests		95.8%
github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:73:	makeRequest		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:94:	MakeBids		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:16:		setContent		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:27:		getValue		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:45:		setContent		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:56:		value			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:67:		getValue		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/structs.go:185:		initMsqParams		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/structs.go:205:		setContent		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/structs.go:279:		getContent		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:24:		mType			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:36:		bidType			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:48:		extBid			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:59:		loadExtBid		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:78:		extBidPrebidMeta	100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:88:		ptrInt8ToBool		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:96:		intToPtrInt		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:102:		errorWritter		100.0%
total:										(statements)		99.4%

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, 0a0e2b2

mediasquare

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:19:	Builder			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:25:	MakeRequests		95.8%
github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:73:	makeRequest		66.7%
github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:95:	MakeBids		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:16:		setContent		60.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:27:		getValue		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:45:		setContent		60.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:56:		value			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:67:		getValue		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/structs.go:185:		initMsqParams		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/structs.go:205:		setContent		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/structs.go:279:		getContent		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:25:		mType			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:37:		bidType			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:49:		extBid			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:60:		loadExtBid		90.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:79:		extBidPrebidMeta	100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:89:		ptrInt8ToBool		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:97:		intToPtrInt		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:103:		errorWritter		100.0%
total:										(statements)		94.5%

@mediasquare-alexandre
Copy link
Contributor Author

Hi Guys, @przemkaczmarek @bsardo
Code-Tests has been rewrote using your adapterstest.RunJSONBidderTest methods.
Hope everything is ok, waiting for earing from you guys.
I'm up if any update is needed.

}

msqParams := initMsqParams(request)
msqParams.Test = (request.Test == int8(1))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I haven't seen this behavior before. Is this added because the msqParams.Test field is required by the MediaSquare backend to recognize the request as a test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is.

@przemkaczmarek
Copy link
Collaborator

@mediasquare-alexandre It's great that you decided to add the adapterstest.RunJSONBidderTest methods.
Next, you should write JSON files like this:
image

Comment on lines 21 to 26
// MakeRequests : case request is empty.
resp, errs := bidder.MakeRequests(nil, nil)
expectingErrors := []error{errorWritter("<MakeRequests> request", nil, true)}
assert.Equal(t, []*adapters.RequestData(nil), resp, "resp, was supposed to be empty result.")
assert.Equal(t, expectingErrors, errs, "errs, was supposed to be :", expectingErrors)

Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be tested in JSON files.

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 initially would have if it was possible,

// MakeRequests : case request is empty.
resp, errs := bidder.MakeRequests(nil, nil)

Here is a screen-shot of the following test :
nil-imp

Cordially

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 have had, let this test be :
image
Tell me if you want me to take it back, it will reduce the coverage by 2% or so... But it is not critical.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It is ok to have unit tests, however, all code coverage should be achieved using the JSON test framework via TestJsonSamples wherever possible.
Please see Adapter Code Tests.

@przemkaczmarek
Copy link
Collaborator

@mediasquare-alexandre This still doesn't meet our standards, e.g., there's no params_test.go file where you would test validParams and invalidParams (for your required owner and code).
I’m not sure if anyone has informed you how this should look, but please check our page: https://docs.prebid.org/prebid-server/developers/add-new-bidder-go.html.
There, you’ll find all the information on how a new adapter should look, including all the required tests.

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, 01c1674

mediasquare

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:19:	Builder			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:25:	MakeRequests		95.8%
github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:73:	makeRequest		66.7%
github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:95:	MakeBids		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:16:		setContent		60.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:27:		getValue		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:45:		setContent		60.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:56:		value			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:67:		getValue		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/structs.go:185:		initMsqParams		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/structs.go:205:		setContent		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/structs.go:279:		getContent		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:25:		mType			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:37:		bidType			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:49:		extBid			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:60:		loadExtBid		90.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:79:		extBidPrebidMeta	100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:89:		ptrInt8ToBool		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:97:		intToPtrInt		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:103:		errorWritter		100.0%
total:										(statements)		94.5%

@mediasquare-alexandre
Copy link
Contributor Author

@przemkaczmarek I tried to use your naming for tests-files, but I'm not sure the names I put on are ok... The documentation only show that files have to be formated as json in supplemental & examplary, so it doesn't help me neither on this subject.
Sincerly-yours,

@matthieularere-msq
Copy link

Hello,
Is there anything we can do to help the validation process for this PR ?
Thanks

return requestData, errs
}

func (a *adapter) makeRequest(request *openrtb2.BidRequest, msqParams *msqParameters) (requestData *adapters.RequestData, err error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why You have two makeRequest func()?
parsers.go structs.go utils.go these files should not exists.
please check one more time instruction how to build a adapter in Go.
https://docs.prebid.org/prebid-server/developers/add-new-bidder-go.html

Copy link

@matthieularere-msq matthieularere-msq Jan 21, 2025

Choose a reason for hiding this comment

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

I guess you mean why we do have a makeRequest and a MakeRequests as we can't have twice a same function otherwise it would not compile ? If so, for the very same reasons other bidders do it (mgid, openx, taboola, improvedigital and many more), to split the MakeRequests func and make it easier to read. Is that an issue ? Is there any restriction in the amount of functions and their spelling ?

Can you elaborate on the the reason(s) why the files parsers.go, structs.go and utils.go should not exists ? If you referer to the file check list from https://docs.prebid.org/prebid-server/developers/add-new-bidder-go.html#file-checklist then my understanding is that this section is about the files that are mandatory not about the only files that we are allowed to create. For instance, appnexus adapter also has files iab_categories.go and models.go in its adapter. The reason why we have these files is to split business logic from the main mediasquare adapter file. If what you want to mean is that we should just merge the content of these files inside mediasquare.go please confirm, though it seems to us that it make this file less readable.

Copy link
Contributor

Choose a reason for hiding this comment

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

I will confirm with the team, but I think it's totally ok to have extra files (within the adapter directory) to make code more readable and structured. This adapter accepts and returns it's own format, not OpenRTB format. Having all the structures and converters in the mediasquare.go will make it difficult to understand and navigate.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agreed. For simple adapters a single file should suffice. However, in this case, the adapter is rather complex so I do appreciate and prefer the code organization across multiple files.

@bsardo bsardo assigned VeronikaSolovei9 and unassigned hhhjort Jan 21, 2025
Comment on lines 24 to 27
Gdpr struct {
ConsentRequired bool `json:"consent_required"`
ConsentString string `json:"consent_string"`
} `json:"gdpr"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this structure is duplicated.
Function initMsqParams declares the same struct.
May you please create a type and reuse it?

var msqResp msqResponse
if err := jsonutil.Unmarshal(response.Body, &msqResp); err != nil {
errs = []error{&errortypes.BadServerResponse{
Message: fmt.Sprintf("<MakeBids> Unexprected status code: %d. Bad server response: %s.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo in UnexpRected

}}
}
return bidderResponse, errs
}
Copy link
Contributor

@VeronikaSolovei9 VeronikaSolovei9 Jan 22, 2025

Choose a reason for hiding this comment

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

Would you consider to clean up error handling using CheckResponseStatusCodeForErrors and IsResponseStatusCodeNoContent functions? Please refer to "app nexus.go"->MakeBids.

I also noticed an interesting thing. When I run the request to mediasquare and bids are not returned - you still return http 200 with error message. This is not typical behavior. If bids are not returned we usually get http 204. If this is something you cannot change, please consider to add a check for empty responses after jsonutil.Unmarshal(response.Body, &msqResp) so we can exit earlier.

Comment on lines 217 to 219
currentVideoBytes, _ := jsonutil.Marshal(currentImp.Video)
jsonutil.Unmarshal(currentVideoBytes, &video)
jsonutil.Unmarshal(currentImp.Video.Ext, &video)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please handle errors for all Marshal and Unmarshal expressions.
In case of production errors it will help us to understand where they come from.

return mediaTypeList["native"]
default:
return mediaTypeList["banner"]
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: remove mediaTypeList and return openrtb type:

// mType: Returns the openrtb2.MarkupType from an msqResponseBids.
func (msqBids *msqResponseBids) mType() openrtb2.MarkupType {
	switch {
	case msqBids.Video != nil:
		return openrtb2.MarkupVideo
	case msqBids.Native != nil:
		return openrtb2.MarkupNative
	default:
		return openrtb2.MarkupBanner
	}
}

Comment on lines 97 to 100
func intToPtrInt(i int) *int {
val := int(i)
return &val
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be replaced with ptrutil.ToPtr( )

}

// errorWritter: Returns a Custom error message.
func errorWritter(referer string, err error, isEmpty bool) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: errorWritter -> single t

@bsardo bsardo self-assigned this Jan 22, 2025
@bsardo
Copy link
Collaborator

bsardo commented Jan 24, 2025

Hi Guys, @przemkaczmarek @bsardo Code-Tests has been rewrote using your adapterstest.RunJSONBidderTest methods. Hope everything is ok, waiting for earing from you guys. I'm up if any update is needed.

Hi @mediasquare-alexandre thanks for taking the initiative and moving to using the JSON test framework to achieve code coverage. This is required.

return requestData, errs
}

func (a *adapter) makeRequest(request *openrtb2.BidRequest, msqParams *msqParameters) (requestData *adapters.RequestData, err error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Agreed. For simple adapters a single file should suffice. However, in this case, the adapter is rather complex so I do appreciate and prefer the code organization across multiple files.

Comment on lines 21 to 26
// MakeRequests : case request is empty.
resp, errs := bidder.MakeRequests(nil, nil)
expectingErrors := []error{errorWritter("<MakeRequests> request", nil, true)}
assert.Equal(t, []*adapters.RequestData(nil), resp, "resp, was supposed to be empty result.")
assert.Equal(t, expectingErrors, errs, "errs, was supposed to be :", expectingErrors)

Copy link
Collaborator

Choose a reason for hiding this comment

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

It is ok to have unit tests, however, all code coverage should be achieved using the JSON test framework via TestJsonSamples wherever possible.
Please see Adapter Code Tests.

gvlVendorID: 791
modifyingVastXmlAllowed: true
maintainer:
email: "[email protected]"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maintainer email addresses should not be a specific user account but rather a corporate account. Please provide another address, perhaps [email protected], as defined in the PR description.

Copy link

github-actions bot commented Feb 3, 2025

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, 71d2d6d

mediasquare

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:19:	Builder			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:25:	MakeRequests		95.8%
github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:73:	makeRequest		66.7%
github.com/prebid/prebid-server/v3/adapters/mediasquare/mediasquare.go:95:	MakeBids		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:16:		setContent		60.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:27:		getValue		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:45:		setContent		60.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:56:		value			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/parsers.go:67:		getValue		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/structs.go:120:		initMsqParams		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/structs.go:137:		setContent		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/structs.go:195:		getContent		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:18:		mType			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:30:		bidType			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:42:		extBid			100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:53:		loadExtBid		90.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:72:		extBidPrebidMeta	100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:82:		ptrInt8ToBool		100.0%
github.com/prebid/prebid-server/v3/adapters/mediasquare/utils.go:90:		errorWriter		100.0%
total:										(statements)		94.2%

@mediasquare-alexandre
Copy link
Contributor Author

Hi @VeronikaSolovei9 @bsardo I do think I fixed all your tips.
If there is anything else, do not hesitate to ring the bells ;)
Cordially.

Copy link
Contributor

@VeronikaSolovei9 VeronikaSolovei9 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 addressing comments! Approved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants