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

OpenX: accept incoming string fields to support Prebid.js 9 #3668

Merged
merged 6 commits into from
Jul 24, 2024

Conversation

laurb9
Copy link
Contributor

@laurb9 laurb9 commented May 7, 2024

  1. accept incoming imp[].ext.customFloor as string or float, emit float in imp[].bidfloor
  2. accept incoming imp[].ext.unit as string or integer, emit string in imp[].tagid
  3. enable gzip compression

1,2 are to support the Prebid.js 9 changes introduced in prebid/Prebid.js#11458

Corresponding PBS-Java change: prebid/prebid-server-java#3178

Copy link

github-actions bot commented May 7, 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, 67c1018

openx

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/openx/openx.go:34:	MakeRequests		100.0%
github.com/prebid/prebid-server/v2/adapters/openx/openx.go:72:	makeRequest		75.0%
github.com/prebid/prebid-server/v2/adapters/openx/openx.go:118:	preprocess		85.3%
github.com/prebid/prebid-server/v2/adapters/openx/openx.go:187:	MakeBids		87.0%
github.com/prebid/prebid-server/v2/adapters/openx/openx.go:246:	getMediaTypeForImp	85.7%
github.com/prebid/prebid-server/v2/adapters/openx/openx.go:260:	Builder			100.0%
total:								(statements)		86.6%

Copy link

github-actions bot commented May 9, 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, 370ff75

openx

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/openx/openx.go:34:	MakeRequests		100.0%
github.com/prebid/prebid-server/v2/adapters/openx/openx.go:72:	makeRequest		75.0%
github.com/prebid/prebid-server/v2/adapters/openx/openx.go:118:	preprocess		85.3%
github.com/prebid/prebid-server/v2/adapters/openx/openx.go:187:	MakeBids		87.0%
github.com/prebid/prebid-server/v2/adapters/openx/openx.go:246:	getMediaTypeForImp	85.7%
github.com/prebid/prebid-server/v2/adapters/openx/openx.go:260:	Builder			100.0%
total:								(statements)		86.6%

@@ -7,7 +7,7 @@
"banner": {},
"ext": {
"bidder": {
"unit": "banner-unit-1",
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this test case previously invalid? Doesn't look like it adhered to the unit json schema pattern.

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 don't recall if these were valid at some point in the past, but they are not now.

@@ -7,7 +7,7 @@
"banner": {},
"ext": {
"bidder": {
"unit": "banner-unit-1",
"unit": "111",
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious, why "111" instead of "1"? Is there a test involved with the length of the unit 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.

No functional reason, just think it's easier to find and replace if needed.

@@ -56,7 +59,8 @@ var invalidParams = []string{
`{"unit": "123", "delDomain": "foo.b"}`,
`{"unit": "123", "delDomain": "foo.barr"}`,
`{"unit": "123", "delDomain": ".bar"}`,
`{"unit": "123", "delDomain": "foo.bar", "customFloor": "0.1"}`,
`{"unit": "123", "delDomain": "foo.bar", "customFloor": ""}`,
`{"unit": "123", "delDomain": "foo.bar", "customFloor": "-0.1"}`,
`{"unit": "123", "delDomain": "foo.bar", "customFloor": -0.1}`,
`{"unit": "123", "delDomain": "foo.bar", "customParams": "foo: bar"}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

I recommend adding customFloor tests invalid test cases as "1." and "1.0x" to add more test coverage of the regex.

Copy link

github-actions bot commented May 9, 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, 028d8db

openx

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/openx/openx.go:34:	MakeRequests		100.0%
github.com/prebid/prebid-server/v2/adapters/openx/openx.go:72:	makeRequest		75.0%
github.com/prebid/prebid-server/v2/adapters/openx/openx.go:118:	preprocess		85.3%
github.com/prebid/prebid-server/v2/adapters/openx/openx.go:187:	MakeBids		87.0%
github.com/prebid/prebid-server/v2/adapters/openx/openx.go:246:	getMediaTypeForImp	85.7%
github.com/prebid/prebid-server/v2/adapters/openx/openx.go:260:	Builder			100.0%
total:								(statements)		86.6%

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, 21d557e

openx

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/openx/openx.go:34:	MakeRequests		100.0%
github.com/prebid/prebid-server/v2/adapters/openx/openx.go:72:	makeRequest		75.0%
github.com/prebid/prebid-server/v2/adapters/openx/openx.go:118:	preprocess		85.3%
github.com/prebid/prebid-server/v2/adapters/openx/openx.go:187:	MakeBids		87.0%
github.com/prebid/prebid-server/v2/adapters/openx/openx.go:246:	getMediaTypeForImp	85.7%
github.com/prebid/prebid-server/v2/adapters/openx/openx.go:260:	Builder			100.0%
total:								(statements)		86.6%

@laurb9
Copy link
Contributor Author

laurb9 commented Jun 4, 2024

Please let me know if there is anything else we should do

Comment on lines 43 to 49
"openx": {
"unit": "539439964",
"delDomain": "se-demo-d.openx.net",
"customFloor": 0.1,
"customFloor": "0.5",
"customParams": {"foo": "bar"}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@laurb9 why was this file changed? Adapter change should be limited to Adapter package

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file contains an OpenX adapter request, and we thought it would be best if it were updated to the most recent request format.

Copy link
Contributor

Choose a reason for hiding this comment

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

could move this to openx specific exemplary test folder

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 can undo this particular line change if it blocks the review, but moving it to the openx test folder does not add any new use cases there. Removing samples from openrtb2/sample-requests is outside the scope of this PR, aside from that openrtb2/sample-requests contains requests for other adapters as well, so the file looks consistent with the intended purpose of that directory, not as an adapter-specific request, but an usage example for certain pbs configurations.

"description": "The minimum CPM price in USD.",
"minimum": 0
Copy link
Contributor

@onkarvhanumante onkarvhanumante Jun 11, 2024

Choose a reason for hiding this comment

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

should add/update json tests

  • to have request where unit is string
  • to have request where unit is number
  • to have request where customFloor is string
  • to have request where customFloor is number

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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, 2a84206

openx

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/openx/openx.go:34:	MakeRequests		100.0%
github.com/prebid/prebid-server/v2/adapters/openx/openx.go:72:	makeRequest		75.0%
github.com/prebid/prebid-server/v2/adapters/openx/openx.go:118:	preprocess		85.3%
github.com/prebid/prebid-server/v2/adapters/openx/openx.go:187:	MakeBids		87.0%
github.com/prebid/prebid-server/v2/adapters/openx/openx.go:246:	getMediaTypeForImp	85.7%
github.com/prebid/prebid-server/v2/adapters/openx/openx.go:260:	Builder			100.0%
total:								(statements)		86.6%

@laurb9 laurb9 requested a review from onkarvhanumante June 18, 2024 18:08
@onkarvhanumante
Copy link
Contributor

Comment on lines +7 to +10
Unit json.Number `json:"unit"`
Platform string `json:"platform"`
DelDomain string `json:"delDomain"`
CustomFloor float64 `json:"customFloor"`
CustomFloor json.Number `json:"customFloor"`
Copy link
Contributor

Choose a reason for hiding this comment

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

@laurb9
could use StringInt data type for Unit, CustomFloor

type StringInt int
func (st *StringInt) UnmarshalJSON(b []byte) error {
if len(b) == 0 {
return nil
}
if b[0] == '"' {
b = b[1 : len(b)-1]
}
if len(b) == 0 {
return nil
}
i, err := jsonparser.ParseInt(b)
if err != nil {
return err
}
*st = StringInt(i)
return nil
}

Copy link
Contributor Author

@laurb9 laurb9 Jul 2, 2024

Choose a reason for hiding this comment

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

@laurb9 could use StringInt data type for Unit, CustomFloor

CustomFloor is a string|float emitted as float and Unit is a string|int emitted as a string.
I believe neither can make use of StringInt which is a int|string serialized to int.

Copy link
Contributor

@onkarvhanumante onkarvhanumante left a comment

Choose a reason for hiding this comment

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

@laurb9 laurb9 requested a review from onkarvhanumante July 2, 2024 17:07
@laurb9
Copy link
Contributor Author

laurb9 commented Jul 18, 2024

Just checking if there is anything else to be done here, this PR addresses breaking changes in Prebid.js 9

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.

4 participants