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

Aliases: Better Error Message For Disabled Bidder #1751

Merged
merged 1 commit into from
Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 9 additions & 4 deletions endpoints/openrtb2/auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -915,12 +915,17 @@ func (deps *endpointDeps) parseBidExt(ext json.RawMessage) (*openrtb_ext.ExtRequ
}

func (deps *endpointDeps) validateAliases(aliases map[string]string) error {
for thisAlias, coreBidder := range aliases {
for alias, coreBidder := range aliases {
if _, isCoreBidderDisabled := deps.disabledBidders[coreBidder]; isCoreBidderDisabled {
return fmt.Errorf("request.ext.prebid.aliases.%s refers to disabled bidder: %s", alias, coreBidder)
}

if _, isCoreBidder := deps.bidderMap[coreBidder]; !isCoreBidder {
return fmt.Errorf("request.ext.prebid.aliases.%s refers to unknown bidder: %s", thisAlias, coreBidder)
return fmt.Errorf("request.ext.prebid.aliases.%s refers to unknown bidder: %s", alias, coreBidder)
}
if thisAlias == coreBidder {
return fmt.Errorf("request.ext.prebid.aliases.%s defines a no-op alias. Choose a different alias, or remove this entry.", thisAlias)

if alias == coreBidder {
return fmt.Errorf("request.ext.prebid.aliases.%s defines a no-op alias. Choose a different alias, or remove this entry.", alias)
}
}
return nil
Expand Down
8 changes: 4 additions & 4 deletions endpoints/openrtb2/auction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type testConfigValues struct {
AliasJSON string `json:"aliases"`
BlacklistedAccounts []string `json:"blacklistedAccts"`
BlacklistedApps []string `json:"blacklistedApps"`
AdapterList []string `json:"disabledAdapters"`
DisabledAdapters []string `json:"disabledAdapters"`
}

func TestJsonSampleRequests(t *testing.T) {
Expand Down Expand Up @@ -229,9 +229,9 @@ func (tc *testConfigValues) getBlackListedAccountMap() map[string]bool {
func (tc *testConfigValues) getAdaptersConfigMap() map[string]config.Adapter {
var adaptersConfig map[string]config.Adapter

if len(tc.AdapterList) > 0 {
adaptersConfig = make(map[string]config.Adapter, len(tc.AdapterList))
for _, adapterName := range tc.AdapterList {
if len(tc.DisabledAdapters) > 0 {
adaptersConfig = make(map[string]config.Adapter, len(tc.DisabledAdapters))
for _, adapterName := range tc.DisabledAdapters {
adaptersConfig[adapterName] = config.Adapter{Disabled: true}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"description": "Request comes with an alias to a disabled bidder, we should throw error",
"config": {
"disabledAdapters": ["appnexus", "rubicon"]
"disabledAdapters": ["appnexus"]
},
"mockBidRequest": {
"id": "some-request-id",
Expand Down Expand Up @@ -32,5 +32,5 @@
}
},
"expectedReturnCode": 400,
"expectedErrorMessage": "Invalid request: request.ext.prebid.aliases.test1 refers to unknown bidder: appnexus\n"
"expectedErrorMessage": "Invalid request: request.ext.prebid.aliases.test1 refers to disabled bidder: appnexus\n"
}