Skip to content

Commit

Permalink
Aliases: Better Error Message For Disabled Bidder (#1751)
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxNode authored Mar 17, 2021
1 parent 549d4b2 commit 5b1a919
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
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"
}

0 comments on commit 5b1a919

Please sign in to comment.