WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@Heihuang
Copy link

Adding iqiyi prebid server adapter

@github-actions
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, 9d4c906

iqiyi

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:21:	Builder			80.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:33:	buildEndpointURL	100.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:38:	MakeRequests		83.9%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:96:	MakeBids		86.7%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:130:	getMediaTypeForImp	80.0%
total:								(statements)		84.5%

@github-actions
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, c36b02c

iqiyi

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:21:	Builder			80.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:33:	buildEndpointURL	100.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:38:	MakeRequests		83.9%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:96:	MakeBids		86.7%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:130:	getMediaTypeForImp	80.0%
total:								(statements)		84.5%

@github-actions
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, cf8485b

iqiyi

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:21:	pickCurrency		60.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:33:	Builder			80.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:45:	buildEndpointURL	100.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:50:	MakeRequests		83.9%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:108:	MakeBids		87.5%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:143:	getMediaTypeForImp	80.0%
total:								(statements)		82.8%

@github-actions
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, a937b11

iqiyi

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:21:	pickCurrency		100.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:33:	Builder			85.7%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:49:	buildEndpointURL	100.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:54:	MakeRequests		96.8%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:112:	MakeBids		100.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:147:	getMediaTypeForImp	100.0%
total:								(statements)		97.0%

@github-actions
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, 3346579

iqiyi

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:21:	pickCurrency		100.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:33:	Builder			100.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:49:	buildEndpointURL	100.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:54:	MakeRequests		94.3%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:114:	MakeBids		100.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:149:	getMediaTypeForImp	100.0%
total:								(statements)		97.1%

remove go.mod and go.sum files

add go.mod go.sum

format json file
@github-actions
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, e254d40

iqiyi

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:21:	pickCurrency		100.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:33:	Builder			100.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:49:	buildEndpointURL	100.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:54:	MakeRequests		100.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:114:	MakeBids		100.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:149:	getMediaTypeForImp	100.0%
total:								(statements)		100.0%

@bsardo bsardo added the adapter label Nov 18, 2025
@github-actions
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, 9e70614

iqiyi

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:21:	pickCurrency		100.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:33:	Builder			100.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:49:	buildEndpointURL	100.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:54:	MakeRequests		100.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:114:	MakeBids		100.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:149:	getMediaTypeForImp	100.0%
total:								(statements)		100.0%

@bsardo
Copy link
Collaborator

bsardo commented Nov 20, 2025

@Heihuang your tests are failing due to formatting issues. Please run go fmt.

@github-actions
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, 9c8c4cb

iqiyi

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:21:	pickCurrency		100.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:33:	Builder			100.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:49:	buildEndpointURL	100.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:54:	MakeRequests		100.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:114:	MakeBids		100.0%
github.com/prebid/prebid-server/v3/adapters/iqiyi/iqiyi.go:149:	getMediaTypeForImp	100.0%
total:								(statements)		100.0%

@postindustria-code
Copy link
Contributor

I send a request via postman:

{
    "id": "some-random-id",
    "test": 1,
    "imp": [
        {
            "id": "adunit-1",
            "banner": {
                "format": [
                    {
                        "w": 300,
                        "h": 200
                    },
                    {
                        "w": 300,
                        "h": 250
                    }
                ]
            },
            "ext": {
                "prebid": {
                    "bidder": {
                        "iqiyi": {
                            "accountid": "123456"
                        }
                    }
                }
            }
        }
    ],
    "device": {
        // data
    },
    "regs": {
        // data
    },
    "user": {
        // data
    },
    "site": {
        "domain": "dailyleap.com",
        "publisher": {
            "domain": "dailyleap.com",
            "id": "p-bid-account-y9eg0fEH"
        },
        "page": "https://www.dailyleap.com/12-fun-workouts-to-try-if-you-hate-the-gym-but-want-to-get-fit/",
        "ref": "https://www.dailyleap.com/"
    },
    "ext": {
        "prebid": {
            "auctiontimestamp": 1733226735069,
            "targeting": {
                "includewinners": true,
                "includebidderkeys": false
            },
            "cache": {
                "bids": {
                    "returnCreative": true
                },
                "vastxml": {
                    "returnCreative": true
                }
            },
            "schains": [
                {
                    "bidders": [
                        "iqiyi"
                    ],
                    "schain": {
                        "ver": "1.0",
                        "complete": 1,
                        "nodes": [
                            {
                                "asi": "adapex.io",
                                "sid": "s4103",
                                "hp": 1
                            }
                        ]
                    }
                }
            ],
            "channel": {
                "name": "pbjs",
                "version": "v9.20.0"
            },
            "aliases": {
                "adtelligents2s": "adtelligent"
            },
            "floors": {
                "enabled": false,
                "floorMin": 0.1,
                "floorMinCur": "USD"
            },
            "createtids": false
        },
        "tmaxmax": 2000
    },
    "cur": [
        "USD"
    ],
    "tmax": 1500
}

And I got the response with this error:

{
...
        "errors": {
            "iqiyi": [
                {
                    "code": 14,
                    "message":"expect { or n, but found �"
                }
            ]
        },
        ...
        }

endpoint *template.Template
}

func pickCurrency(req *openrtb2.BidRequest, resp *openrtb2.BidResponse) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't say that this would be a critic comment, perhaps a better name for the function would be selectCurrency or something like that

return nil, errs
}

reqJson, err := json.Marshal(request)
Copy link
Contributor

Choose a reason for hiding this comment

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

The same, it is not critical issue, but the better name would be reqJSON


var iqiyiExt openrtb_ext.ExtImpIqiyi
if err := jsonutil.Unmarshal(bidderExt.Bidder, &iqiyiExt); err != nil {
errs = append(errs, &errortypes.BadInput{Message: "bad Iqiyi bidder ext"})
Copy link
Contributor

Choose a reason for hiding this comment

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

Both unmarshal operations on lines 63 and 69 use the same error message. Differentiate them

imp := &request.Imp[i]
if imp.Banner != nil {
b := *imp.Banner
if (b.W == nil || b.H == nil || *b.W == 0 || *b.H == 0) && len(b.Format) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

*b.W == 0 and *b.H == 0 are hardcoded values. Extract to named constants:

const (
defaultBannerFormatIndex = 0
)

}
}
if imp.BidFloorCur == "" && imp.BidFloor > 0 {
imp.BidFloorCur = "USD"
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Comment not only for this line.
    For block for as a whole:
    At this point you are modifying the original Imp, I think it would be better to change the code to the following:
    for i := range request.Imp {
        // Copy the entire Imp object
        impCopy := request.Imp[i]
        
        if impCopy.Banner != nil {
            bannerCopy := *impCopy.Banner
            if (bannerCopy.W == nil || bannerCopy.H == nil || *bannerCopy.W == 0 || *bannerCopy.H == 0) && len(bannerCopy.Format) > 0 {
                first := bannerCopy.Format[0]
                bannerCopy.W = &first.W
                bannerCopy.H = &first.H
            }
            impCopy.Banner = &bannerCopy
        }
        
        if impCopy.BidFloorCur == "" && impCopy.BidFloor > 0 {
            impCopy.BidFloorCur = "USD"
        }
        
        requestCopy.Imp[i] = impCopy
    }
  1. "USD" is hardcoded value. Extract to named constants:
const (
    defaultBidFloorCurrency = "USD"
)


func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
var errs []error
if len(request.Imp) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Prebid Server's core exchange logic already validates that requests have at least one valid impression before calling adapter's MakeRequests.
The exchange will never pass a request with zero impressions to an adapter

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.

3 participants