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

Add alternatebiddercodes in Prebid request ext #2339

Conversation

pm-nilesh-chate
Copy link
Contributor

w.r.t #2174 (comment)

This changes would make alternatebiddercodes from PBS config formally part of Prebid ORTB extensions.

  • Incoming ORTB would contain:
ext.prebid.alternatebiddercodes.enabled: true/false
ext.prebid.alternatebiddercodes.bidders.BIDDER.enabled: true/false
ext.prebid.alternatebiddercodes.bidders.BIDDER.allowedbiddercodes: [array, of, strings]
  • This would override the account-level config
  • If the request doesn't specify these values, then PBS-core would merge the account config into these values
  • Before sending to each adapter, PBS-core would need to remove entries that don't belong to that bidder. i.e. they would only receive ext.prebid.alternatebiddercodes.adapters.ME
  • Everything else is up to the adapter. They can ignore or use at will.

Ex. s2s config on page and incoming PBS request

pbjs.setConfig({
    s2sConfig: {
        extPrebid: {
            "alternatebiddercodes": {
                "enabled": true,
                "bidders": {
                    "pubmatic": {
                        "enabled": true,
                        "allowedbiddercodes": [
                            "groupm"
                        ]
                    }
                }
            }
        }
    }
});
{
   ...
   "ext": {
       "prebid": {
           "alternatebiddercodes": {
                "enabled": true,
                "bidders": {
                    "pubmatic": {
                        "enabled": true,
                        "allowedbiddercodes": [
                            "groupm"
                        ]
                    }
                }
            }
       }
   }
}

More details at #2174

extCopy.Prebid.AlternateBidderCodes = nil

//fill request.ext.prebid.alternatebiddercode to have data only of the current bidder
if unpackedExt.Prebid.AlternateBidderCodes != nil && len(unpackedExt.Prebid.AlternateBidderCodes.Bidders) != 0 {
Copy link
Contributor Author

@pm-nilesh-chate pm-nilesh-chate Aug 10, 2022

Choose a reason for hiding this comment

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

Do we want to pass openrtb_ext.ExtAlternateBidderCodes{Enabled: true/false} to the bidders that are not present in the list req.ext?.

i.e.

if unpackedExt.Prebid.AlternateBidderCodes != nil && len(unpackedExt.Prebid.AlternateBidderCodes.Bidders) != 0 {
	extCopy.Prebid.AlternateBidderCodes = &openrtb_ext.ExtAlternateBidderCodes{
		Enabled: unpackedExt.Prebid.AlternateBidderCodes.Enabled,
	}
	if bidderCodes, ok := unpackedExt.Prebid.AlternateBidderCodes.Bidders[bidder]; ok {
		extCopy.Prebid.AlternateBidderCodes.Bidders = map[string]openrtb_ext.ExtAdapterAlternateBidderCodes{
			bidder: bidderCodes,
		}
	}
}

Current changes do not pass it as I don't find any use case for the same.

@pm-nilesh-chate pm-nilesh-chate force-pushed the feature-2174-read-alternatebiddercodes-from-request-ext-3 branch from 06ae526 to 171b9b1 Compare August 10, 2022 15:53
@pm-nilesh-chate pm-nilesh-chate marked this pull request as ready for review August 10, 2022 16:11
@bsardo bsardo self-requested a review August 10, 2022 17:31
@bsardo bsardo self-assigned this Aug 10, 2022
@VeronikaSolovei9
Copy link
Contributor

Code looks good, local testing looks good too.

CookieSync CookieSync `mapstructure:"cookie_sync" json:"cookie_sync"`
Events Events `mapstructure:"events" json:"events"` // Don't enable this feature. It is still under developmment - https://github.com/prebid/prebid-server/issues/1725
TruncateTargetAttribute *int `mapstructure:"truncate_target_attr" json:"truncate_target_attr"`
AlternateBidderCodes *AlternateBidderCodes `mapstructure:"alternatebiddercodes" json:"alternatebiddercodes"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are we changing this to a pointer? I thought we wanted an empty object if alternatebiddercodes didn't exist in the fetched account so that Enabled is set to its default value of false which would make this an opt-in feature. Do we need to detect presence when determining whether to use the account config values?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted the change. Yes, I did it to detect the presence of account config values but I guess we don't need it.

btw, we would need the AlternateBidderCodes in the request.ext to be pointer to detect its presence and to choose between request and account values.

exchange/utils.go Outdated Show resolved Hide resolved
exchange/utils.go Outdated Show resolved Hide resolved
@@ -245,6 +245,8 @@ func (e *exchange) HoldAuction(ctx context.Context, r AuctionRequest, debugLog *
}
}

setExtAlternateBidderCodes(requestExt, r.Account.AlternateBidderCodes)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This function appears to merge the alternate bidder codes account config with the request resulting in a modified request ext which seems a little odd to me. Perhaps it would be better if this function created a new instance of AlternateBidderCodes so requestExt is left unmodified. I'm not seeing the value in modifying it and I think this can lead to confusion.

I do see that you're making use of the alternate bidder codes set on the requestExt in CleanOpenRTBRequests and that function has a lot of parameters but I suggest you add another parameter there to pass this new AlternateBidderCodes object in and we can worry about getting the number of parameters down in a future refactor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, moved setExtAlternateBidderCodes's code into CleanOpenRTBRequests's buildRequestExtForBidder.

It looks messy now, too many scenarios, although tried to cover all them in unit tests.


// getExtAlternateBidderCodes map config.account.alternatebiddercodes to ext.prebid.alternatebiddercodes
func setExtAlternateBidderCodes(requestExt *openrtb_ext.ExtRequest, cfgABC *config.AlternateBidderCodes) {
if requestExt == nil || requestExt.Prebid.AlternateBidderCodes != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If requestExt is nil, shouldn't we still consider any alternate bidder codes defined in the account config?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

missed this one. Updated the code in buildRequestExtForBidder and added unit test for the same.

exchange/exchange.go Outdated Show resolved Hide resolved
Comment on lines +44 to +51
"alternatebiddercodes": {
"enabled": true,
"bidders": {
"pubmatic": {
"enabled": true,
"allowedbiddercodes": ["groupm"]
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm thinking that maybe we should include an expectRequest object under outgoingRequests for each of the two bidders so we can verify the appropriate alternate bidder code "groupm" was added to the pubmatic bid request but not to the appnexus bid request. Otherwise, this test is just verifying that the alternatebiddercodes object in the original request is well-formed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, also I could not test end to end flow at one place where we could validate outgoing and incoming request as these json file based tests mock requestBid function which has alternatebiddercodes validation.

Hence, I wrote TestOverrideConfigAlternateBidderCodesWithRequestValues to cover the validation of alternatebiddercodes coming as response from adapters and added unit tests in all the possible functions that could change request.ext.prebid. alternatebiddercodes to cover the request to adapters part. Ex. setExtAlternateBidderCodes and CleanOpenRTBRequests (now clubbed).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added expectRequest

@pm-nilesh-chate
Copy link
Contributor Author

Hi @bsardo, I've address the comments. Could you review the same.

@@ -48,6 +49,7 @@ func cleanOpenRTBRequests(ctx context.Context,
gdprPermsBuilder gdpr.PermissionsBuilder,
tcf2ConfigBuilder gdpr.TCF2ConfigBuilder,
hostSChainNode *openrtb2.SupplyChainNode,
cfgABC config.AlternateBidderCodes,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is the account config alternate bidder codes right? We could actually remove this parameter here and just grab it off of the parameter auctionReq AuctionRequest which has the account on it. Sorry about that. I didn't realize it was available in this function already until just now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 287 to 291
alternateBidderCodes = &openrtb_ext.ExtAlternateBidderCodes{
Bidders: map[string]openrtb_ext.ExtAdapterAlternateBidderCodes{
bidder: bidderCodes,
},
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this should be:

alternateBidderCodes.Bidders = map[string]openrtb_ext.ExtAdapterAlternateBidderCodes{
	bidder: bidderCodes,
}

alternateBidderCodes was created just above with Enabled appropriately set.

If you agree, we may need another test case in TestCleanOpenRTBRequestsFilterBidderRequestExt because this wasn't caught.

I think maybe the test case is something like:

{
	desc:     "Nil request ext, alternatebiddercodes config enabled with bidder code for only one bidder",
	inExt:    nil,
	inCfgABC: config.AlternateBidderCodes{
		Enabled: true,
		Bidders: map[string]openrtb_ext.ExtAdapterAlternateBidderCodes{
			"pubmatic": {
				Enabled: true,
				AllowedBidderCodes: []string{"groupm"},
			},
		},
	},
	wantExt: []json.RawMessage{
		json.RawMessage(`{"prebid":{"alternatebiddercodes":{"enabled":true,"bidders":null}}}`),
		json.RawMessage(`{"prebid":{"alternatebiddercodes":{"enabled":true,"bidders":{"pubmatic":{"enabled":true,"allowedbiddercodes":["groupm"]}}}}}`),
	},
	wantError: false,
},

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done. Added similar test case for buildRequestExtForBidder()

Comment on lines 294 to 301
// default case where alternatebiddercode is either not defined in account config or defined with default values,
// do not fill alternatebiddercode in such scenario to keep the request payload as is (regression)
if reflect.DeepEqual(openrtb_ext.ExtAlternateBidderCodes{}, *alternateBidderCodes) {
if len(requestExt) == 0 || requestExtParsed == nil {
return json.RawMessage(``), nil
}
alternateBidderCodes = nil
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We generally try to avoid using the reflect package. Is there an alternative?
What if we change this to:

if alternateBidderCodes.Enabled == false && alternateBidderCodes.Bidders == nil {
	alternateBidderCodes = nil
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

if len(requestExt) == 0 || requestExtParsed == nil {
return json.RawMessage(``), nil
func buildRequestExtForBidder(bidder string, requestExt json.RawMessage, requestExtParsed *openrtb_ext.ExtRequest, bidderParamsInReqExt map[string]json.RawMessage, cfgABC config.AlternateBidderCodes) (json.RawMessage, error) {
// Resolve alternatebiddercode for current bidder
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if we extract the logic you have here that sets alternateBidderCodes into its own function for readability?
The logic here could just be something like:

// Resolve alternatebiddercode for current bidder
var reqABC *openrtb_ext.ExtAlternateBidderCodes
if len(requestExt) != 0 && requestExtParsed != nil && requestExtParsed.Prebid.AlternateBidderCodes != nil {
	reqABC = requestExtParsed.Prebid.AlternateBidderCodes
}
alternateBidderCodes := buildRequestExtAlternateBidderCodes(bidder, cfgABC, reqABC)

if (len(requestExt) == 0 || requestExtParsed == nil) && alternateBidderCodes == nil {
	return json.RawMessage(``), nil
}

And then most of this logic is then extracted into a function with a signature like func buildRequestExtAlternateBidderCodes(bidder string, accABC config.AlternateBidderCodes, reqABC *openrtb_ext.ExtAlternateBidderCodes) (*openrtb_ext.ExtAlternateBidderCodes) {

Thoughts? You shouldn't need any new unit tests since this new function would just be a private method and you're already adequately testing the caller.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@pm-nilesh-chate
Copy link
Contributor Author

@bsardo I've address the comments. Could you review the same.

Thank you for the critical inputs. A good learning for my future PRs :)

Copy link
Contributor

@VeronikaSolovei9 VeronikaSolovei9 left a comment

Choose a reason for hiding this comment

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

Code looks so much better and easier to understand now. LGTM

return &openrtb_ext.ExtAlternateBidderCodes{
Enabled: reqABC.Enabled,
Bidders: map[string]openrtb_ext.ExtAdapterAlternateBidderCodes{
bidder: reqABC.Bidders[bidder],
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the bidder isn't defined in the request config, I think this will create a map with the bidder name as the key and the value as an empty instance of ExtAdapterAlternateBidderCodes rather than nil. I think we want it to be nil, in which case we would want to check if the key exists before making this assignment just like you do on lines 339-343.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done. Also added a test case for this scenario

Comment on lines 290 to 294
//This will be used validate bids
alternateBidderCodes := openrtb_ext.ExtAlternateBidderCodes(r.Account.AlternateBidderCodes)
if requestExt != nil && requestExt.Prebid.AlternateBidderCodes != nil {
alternateBidderCodes = *requestExt.Prebid.AlternateBidderCodes
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

It feels like this logic is in an odd place which has me wondering if it is even needed. With the current design where we pass alternateBidderCodes into getAllBids it makes sense. Ideally though I think we should be able use the alternate bidder codes attached to each bidder request when validating the bidders in the bid responses. Thoughts? Perhaps this is something for a future PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this to make sure PBS-Core data is used to validate the adapter's response instead of relying on the data from adapter's request which could be altered by the adapter code.

Comment on lines +3359 to +3401
json.RawMessage(`{"prebid":{"alternatebiddercodes":{"enabled":true,"bidders":null}}}`),
json.RawMessage(`{"prebid":{"alternatebiddercodes":{"enabled":true,"bidders":null}}}`),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see a few instances where prebid.alternatebiddercodes.bidders is null. Perhaps this should be omitted if null, in which case we would add the omitempty tag to the ExtAlternateBidderCodes.Bidders field. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added omit empty to all the alternatebiddercodes fields.

The only downside I see here is that the SSPs would not know whether these fields were omitted by the user or by the PBS. One will have to refer the incoming payload to PBS to verify the same. I don't see any harm though.

@pm-nilesh-chate pm-nilesh-chate force-pushed the feature-2174-read-alternatebiddercodes-from-request-ext-3 branch from cb28687 to 07a3091 Compare September 8, 2022 03:52
@pm-nilesh-chate
Copy link
Contributor Author

Addressed the review comments. Had to rebase and force push to fix the master merge test failures.

@bsardo Could you please review the latest changes.

Thanks

@abhinavsinha001
Copy link

What is the holdup here can we get these changes merged?
We want to start using this functionality.

@bsardo
Copy link
Collaborator

bsardo commented Sep 14, 2022

@abhinavsinha001 I'm waiting for a response on this #2174 (comment)

@abhinavsinha001
Copy link

Thanks @bsardo for pointing to the comment.
@bretg can you please help unblock here.

Copy link
Collaborator

@bsardo bsardo left a comment

Choose a reason for hiding this comment

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

Thanks for your patience @pm-nilesh-chate. Please see my comments. I ran a bunch of manual tests with my suggested changes to make sure they were in line with my requirements analysis outlined in my comment in exchange/utils.go. Let me know if you want to discuss.


type ExtAdapterAlternateBidderCodes struct {
Enabled bool `mapstructure:"enabled" json:"enabled"`
AllowedBidderCodes []string `mapstructure:"allowedbiddercodes" json:"allowedbiddercodes,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

On second thought, I think we should remove this omitempty tag going back to the way you originally had it. By removing it, if allowedbiddercodes is absent for the bidder in the original request, it will be set to null on the bidder request. This outcome will be different from when allowedbiddercodes is set to an empty list on the original request which is good; we need to maintain that distinction because they have different meanings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, removed omitempty tag.

// ExtAlternateBidderCodes defines list of alternate bidder codes allowed by adatpers. This overrides host level configs.
type ExtAlternateBidderCodes struct {
Enabled bool `mapstructure:"enabled" json:"enabled"`
Bidders map[string]ExtAdapterAlternateBidderCodes `mapstructure:"bidders" json:"bidders,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

I also think we should remove this omitempty tag even though I don't see a behavioral issue similar to that of having omitempty on allowedbiddercodes. Removing this will just make things more consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, removed omitempty tag.

}
extMap["prebid"] = prebidJson

return json.Marshal(extMap)
}

func buildRequestExtAlternateBidderCodes(bidder string, accABC config.AlternateBidderCodes, reqABC *openrtb_ext.ExtAlternateBidderCodes) *openrtb_ext.ExtAlternateBidderCodes {
Copy link
Collaborator

Choose a reason for hiding this comment

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

After looking more closely at the requirements, I believe we should aim for the following behavior:

  • If alternatebiddercodes is not defined in the account or on the request, the field should be omitted from all bidder requests.
  • If alternatebiddercodes is defined either in the account or on the request but its enabled is not set, the alternatebiddercodes field should be added to the bidder request with the default value of false.
  • The alternatebiddercodes object set on a bidder request should only contain its own bidder object in the bidders field and it should match the bidder object in the account/request it was sourced from. Note an undefined map or slice in the original request or account will appear as null in a bidder request (we will need to get rid of omitempty), so that we can distinguish between an empty array/map and an undefined array/map.

Given the above, I'd like to suggest a couple of things here:

  1. In config/accounts.go, can we make the field AlternateBidderCodes in the Account struct of type *AlternateBidderCodes?
  2. Let's get rid of the if block on line 348 that sets alternateBidderCodes = nil.
  3. I think this function ultimately looks like this:
        if reqABC != nil {
		alternateBidderCodes := &openrtb_ext.ExtAlternateBidderCodes{
			Enabled: reqABC.Enabled,
		}
		if bidderCodes, ok := reqABC.Bidders[bidder]; ok {
			alternateBidderCodes.Bidders = map[string]openrtb_ext.ExtAdapterAlternateBidderCodes{
				bidder: bidderCodes,
			}
		}
		return alternateBidderCodes
	}

	if accABC != nil {
		alternateBidderCodes := &openrtb_ext.ExtAlternateBidderCodes{
			Enabled: accABC.Enabled,
		}
		if bidderCodes, ok := accABC.Bidders[bidder]; ok {
			alternateBidderCodes.Bidders = map[string]openrtb_ext.ExtAdapterAlternateBidderCodes{
				bidder: bidderCodes,
			}
		}
		return alternateBidderCodes
	}
	return nil

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done. made accABC pointer to detect its presence.

adapterBids, adapterExtra, anyBidsReturned = e.getAllBids(auctionCtx, bidderRequests, bidAdjustmentFactors, conversions, accountDebugAllow, r.GlobalPrivacyControlHeader, debugLog.DebugOverride, r.Account.AlternateBidderCodes, requestExt.Prebid.Experiment)

//This will be used validate bids
alternateBidderCodes := openrtb_ext.ExtAlternateBidderCodes(r.Account.AlternateBidderCodes)
Copy link
Collaborator

Choose a reason for hiding this comment

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

See my related comment in exchange/utils.go that asks for the account field to be converted to a pointer.
Should this be something like this now:

var alternateBidderCodes openrtb_ext.ExtAlternateBidderCodes
if r.Account.AlternateBidderCodes != nil {
    alternateBidderCodes = openrtb_ext.ExtAlternateBidderCodes(*r.Account.AlternateBidderCodes)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

}
}

if !alternateBidderCodes.Enabled && alternateBidderCodes.Bidders == nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm wondering now if we should delete this if block. If we remove it, ext.prebid.alternatebiddercodes in the bidder request will contain exactly what's pertinent to the bidder in the account config with the lone exception being that enabled flags will be set to the default value false if not defined. This is the same behavior as if ext.prebid.alternatebiddercodes were to be populated on the bidder request with information pulled from the original request, assuming we remove the couple of omitempty tags I pointed out in my other comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed. removed this code.

@pm-nilesh-chate
Copy link
Contributor Author

Hi @bsardo, I've addressed the comments. Please review the same. Fyi, last commit (master merge) is to address Trivy's check.

bsardo
bsardo previously approved these changes Sep 27, 2022
Copy link
Collaborator

@bsardo bsardo left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -18,20 +16,22 @@ const (
IntegrationTypeWeb IntegrationType = "web"
)

type AlternateBidderCodes openrtb_ext.ExtAlternateBidderCodes
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: What is the purpose of this type alias? The two reasons in Go to use a type alias is to provide a more descriptive name or to attach methods. Neither seem to apply. Perhaps it can be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

btw, I did it to keep config's and extension's alternatebiddercodes distinguishable for reading.

Ex:

Original

func buildRequestExtAlternateBidderCodes(bidder string, accABC *config.AlternateBidderCodes, reqABC *openrtb_ext.ExtAlternateBidderCodes) *openrtb_ext.ExtAlternateBidderCodes {

Current (Both accABC and reqABC have same type now)

func buildRequestExtAlternateBidderCodes(bidder string, accABC *openrtb_ext.ExtAlternateBidderCodes, reqABC *openrtb_ext.ExtAlternateBidderCodes) *openrtb_ext.ExtAlternateBidderCodes {


func (bidderCodes *ExtAlternateBidderCodes) IsValidBidderCode(bidder, alternateBidder string) (bool, error) {
const ErrAlternateBidderNotDefined = "alternateBidderCodes not defined for adapter %q, rejecting bids for %q"
const ErrAlternateBidderDisabled = "alternateBidderCodes disabled for %q, rejecting bids for %q"
Copy link
Contributor

Choose a reason for hiding this comment

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

The naming convention errSomeName is usually for when the value is an error type. This is an error message and the separation of the fields from the Errorf calls is a bit hard to follow IMHO. Consider extracting each to their own simple builder method, like:

func alternateBidderNotDefinedError(bidder, alternateBidder string) error {
  return fmt.Errorf("alternateBidderCodes not defined for adapter %q, rejecting bids for %q", bidder, alternateBidder)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

exchange/exchange.go Outdated Show resolved Hide resolved
Copy link
Contributor

@VeronikaSolovei9 VeronikaSolovei9 left a comment

Choose a reason for hiding this comment

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

LGTM

@bsardo bsardo merged commit b78eb18 into prebid:master Oct 5, 2022
@pm-nilesh-chate pm-nilesh-chate deleted the feature-2174-read-alternatebiddercodes-from-request-ext-3 branch October 8, 2022 04:04
gwi-mmuths added a commit to gwinteractive/prebid-server that referenced this pull request Oct 10, 2022
* origin/master: (316 commits)
  Fix alt bidder code test broken by imp wrapper commit (prebid#2405)
  ImpWrapper (prebid#2375)
  Update sspBC adapter to v5.7 (prebid#2394)
  Change errors to warnings (prebid#2385)
  TheMediaGrid: support native mediaType (prebid#2377)
  Huaweiadsadapter gdpr (prebid#2345)
  Add alternatebiddercodes in Prebid request ext (prebid#2339)
  Changed FS bidder names to mixed case (prebid#2390)
  Load bidders names from file system in lowercase (prebid#2388)
  consumable adapter: add schain and coppa support (prebid#2361)
  Adapter aliases: moved adapter related configs to bidder.yaml files (prebid#2353)
  pubmatic adapter: add param prebiddealpriority (prebid#2281)
  Yieldlab Adapter: Add support for ad unit sizes (prebid#2364)
  GDPR: add enforce_algo config flag and convert enforce_purpose to bool (prebid#2330)
  Resolves CVE-2022-27664 (prebid#2376)
  AMP Endpoint: support parameters consentType and gdprApplies (prebid#2338)
  Dianomi - added usync for redirect (prebid#2368)
  Create issue_prioritization.yml (prebid#2372)
  Update yaml files for gzip supported bidders (prebid#2365)
  Adnuntius Adapter: Set no cookies as a parameter (prebid#2352)
  ...
shunj-nb pushed a commit to ParticleMedia/prebid-server that referenced this pull request Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants