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

Load bidders names from file system in lowercase #2388

Merged
merged 2 commits into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion config/bidderinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ func LoadBidderInfo(path string) (BidderInfos, error) {

bidderName := strings.Split(fileName, ".")
if len(bidderName) == 2 && bidderName[1] == "yaml" {
infos[(bidderName[0])] = info
// store all bidder names loaded from file system in lowercase
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: Please expand on the comment to include this is mention the conversion to lower case is to match the same behavior of config.BidderInfos .

infos[(strings.ToLower(bidderName[0]))] = info
}
}
return infos, nil
Expand Down
3 changes: 2 additions & 1 deletion config/bidderinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ endpointCompression: "GZIP"
`

func TestLoadBidderInfoFromDisk(t *testing.T) {
bidder := "someBidder"
// should appear in result in lowercase
bidder := "somebidder"
trueValue := true

adapterConfigs := make(map[string]Adapter)
Expand Down
9 changes: 1 addition & 8 deletions exchange/adapter_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,13 @@ func buildBidders(infos config.BidderInfos, builders map[openrtb_ext.BidderName]
bidders := make(map[openrtb_ext.BidderName]adapters.Bidder)
var errs []error

for bidder := range infos {
for bidder, info := range infos {
bidderName, bidderNameFound := openrtb_ext.NormalizeBidderName(bidder)
if !bidderNameFound {
errs = append(errs, fmt.Errorf("%v: unknown bidder", bidder))
continue
}

info, infoFound := infos[string(bidderName)]
if !infoFound {
errs = append(errs, fmt.Errorf("%v: bidder info not found", bidder))
continue
}

builder, builderFound := builders[bidderName]
if !builderFound {
errs = append(errs, fmt.Errorf("%v: builder not registered", bidder))
Expand All @@ -59,7 +53,6 @@ func buildBidders(infos config.BidderInfos, builders map[openrtb_ext.BidderName]
bidders[bidderName] = adapters.BuildInfoAwareBidder(bidderInstance, info)
}
}

return bidders, errs
}

Expand Down
9 changes: 0 additions & 9 deletions exchange/adapter_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func TestBuildAdapters(t *testing.T) {
description: "Invalid - Builder Errors",
bidderInfos: map[string]config.BidderInfo{"unknown": {}, "appNexus": {}},
expectedErrors: []error{
errors.New("appNexus: bidder info not found"),
errors.New("unknown: unknown bidder"),
},
},
Expand Down Expand Up @@ -101,14 +100,6 @@ func TestBuildBidders(t *testing.T) {
errors.New("unknown: unknown bidder"),
},
},
{
description: "Invalid - No Bidder Info",
bidderInfos: map[string]config.BidderInfo{"appNexus": {}},
builders: map[openrtb_ext.BidderName]adapters.Builder{openrtb_ext.BidderAppnexus: appnexusBuilder},
expectedErrors: []error{
errors.New("appNexus: bidder info not found"),
},
},
{
description: "Invalid - No Builder",
bidderInfos: map[string]config.BidderInfo{"appnexus": infoEnabled},
Expand Down
2 changes: 1 addition & 1 deletion exchange/exchange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestNewExchange(t *testing.T) {
e := NewExchange(adapters, nil, cfg, map[string]usersync.Syncer{}, &metricsConf.NilMetricsEngine{}, biddersInfo, gdprPermsBuilder, tcf2ConfigBuilder, currencyConverter, nilCategoryFetcher{}, &adscert.NilSigner{}).(*exchange)
for _, bidderName := range knownAdapters {
if _, ok := e.adapterMap[bidderName]; !ok {
if biddersInfo[string(bidderName)].IsEnabled() {
if biddersInfo[strings.ToLower(string(bidderName))].IsEnabled() {
t.Errorf("NewExchange produced an Exchange without bidder %s", bidderName)
}
}
Expand Down