Skip to content
This repository has been archived by the owner on Dec 22, 2022. It is now read-only.

Commit

Permalink
Required some size to exist on banner requests (prebid#646)
Browse files Browse the repository at this point in the history
* Required some size to exist on banner requests.

* Added more tests. Fixed the code a bit.
  • Loading branch information
dbemiller authored Oct 12, 2018
1 parent 6d380ed commit b7815a9
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 4 deletions.
5 changes: 5 additions & 0 deletions endpoints/openrtb2/auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,11 @@ func validateBanner(banner *openrtb.Banner, impIndex int) error {
return fmt.Errorf("request.imp[%d].banner uses unsupported property: \"hmax\". Use the \"format\" array instead.", impIndex)
}

hasRootSize := banner.H != nil && banner.W != nil && *banner.H > 0 && *banner.W > 0
if !hasRootSize && len(banner.Format) == 0 {
return fmt.Errorf("request.imp[%d].banner has no sizes. Define \"w\" and \"h\", or include \"format\" elements.", impIndex)
}

for fmtIndex, format := range banner.Format {
if err := validateFormat(&format, impIndex, fmtIndex); err != nil {
return err
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"message": "Invalid request: request.imp[0].banner has no sizes. Define \"w\" and \"h\", or include \"format\" elements.\n",
"requestPayload": {
"id":"req-id",
"site": {
"id": "some-site"
},
"imp": [
{
"id":"imp-id",
"banner":{
"h": 300
},
"ext": {
"appnexus": {
"placementId": 10433394
}
}
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"message": "Invalid request: request.imp[0].banner has no sizes. Define \"w\" and \"h\", or include \"format\" elements.\n",
"requestPayload": {
"id":"req-id",
"site": {
"id": "some-site"
},
"imp": [
{
"id":"imp-id",
"banner":{
"h": 0,
"w": 250
},
"ext": {
"appnexus": {
"placementId": 10433394
}
}
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"message": "Invalid request: request.imp[0].banner has no sizes. Define \"w\" and \"h\", or include \"format\" elements.\n",
"requestPayload": {
"id":"req-id",
"site": {
"id": "some-site"
},
"imp": [
{
"id":"imp-id",
"banner":{
"w": 50
},
"ext": {
"appnexus": {
"placementId": 10433394
}
}
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"message": "Invalid request: request.imp[0].banner has no sizes. Define \"w\" and \"h\", or include \"format\" elements.\n",
"requestPayload": {
"id":"req-id",
"site": {
"id": "some-site"
},
"imp": [
{
"id": "imp-id",
"banner": {
"h": 300,
"w": 0
},
"ext": {
"appnexus": {
"placementId": 10433394
}
}
}
]
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
{
"message": "Invalid request: request.imp[0].ext is required\n",
"message": "Invalid request: request.imp[0].banner has no sizes. Define \"w\" and \"h\", or include \"format\" elements.\n",
"requestPayload": {
"id":"req-id",
"site": {
"id": "some-site"
},
"imp": [
{
"id":"imp-id",
"banner":{
"format":[]
"id": "imp-id",
"banner": {
"format": []
},
"ext": {
"appnexus": {
"placementId": 10433394
}
}
}
]
Expand Down

0 comments on commit b7815a9

Please sign in to comment.