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

Adapter aliases: moved adapter related configs to bidder.yaml files #2353

Merged
merged 24 commits into from
Sep 20, 2022

Conversation

VeronikaSolovei9
Copy link
Contributor

@VeronikaSolovei9 VeronikaSolovei9 commented Aug 18, 2022

  • all adapter related configs are moved to static/bidder-info/{bidder}.yaml files.
  • Apapter struct now carries only adapter needed data
  • all adapter related configs are removed from config.go
  • bidder list now loads from the file system

Docs update PR: prebid/prebid.github.io#4008

@VeronikaSolovei9 VeronikaSolovei9 marked this pull request as draft August 18, 2022 03:12
@VeronikaSolovei9 VeronikaSolovei9 marked this pull request as ready for review August 24, 2022 06:41
@bsardo bsardo self-requested a review August 24, 2022 17:47
@bsardo bsardo self-assigned this Aug 24, 2022
@bsardo bsardo requested a review from hhhjort August 24, 2022 17:47
@bsardo bsardo requested review from AlexBVolcy and removed request for bsardo August 24, 2022 17:48
@bsardo bsardo assigned AlexBVolcy and unassigned bsardo Aug 24, 2022
func (s *SyncerEndpoint) Override(original *SyncerEndpoint) *SyncerEndpoint {
if s == nil && original == nil {
return nil
func ProcessBidderInfos(path string, confBidderInfos BidderInfos) (BidderInfos, []error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: Could you re-name confBidderInfos to configBidderInfos


for _, bidderConfig := range bidderConfigs {
if bidderConfig.IsDir() {
continue //or throw an error?
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you decided if you are going to not throw an error here? If so, could you remove the comment?

// ToGVLVendorIDMap transforms a BidderInfos object to a map of bidder names to GVL id. Disabled
// bidders are omitted from the result.
func (infos BidderInfos) ToGVLVendorIDMap() map[openrtb_ext.BidderName]uint16 {
m := make(map[openrtb_ext.BidderName]uint16, len(infos))
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: Is there a more descriptive name we can use for this variable other than m. I understand if you'd prefer to keep it this way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is moved from another place, I didn't change content. Renamed for future convenience.


if s.RedirectURL != "" {
copy.RedirectURL = s.RedirectURL
// vlidateBidderInfos validates bidder endpoint, info and syncer data
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: Spelling error in comment (vlidate)

@AlexBVolcy
Copy link
Contributor

Also just wanted to comment highlighting the merge conflicts with bidderinfo., bidderinfo_test.go, adapter_util_test.go

vsolovei added 3 commits August 24, 2022 19:59
# Conflicts:
#	config/bidderinfo.go
#	config/bidderinfo_test.go
#	exchange/adapter_util_test.go
Copy link
Contributor

@AlexBVolcy AlexBVolcy left a comment

Choose a reason for hiding this comment

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

Very minor comments

}

bidderName := strings.Split(fileName, ".yaml")
infos[(bidderName[0])] = info
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it guaranteed that there will be data present at index 0 here? Just want to check

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point. Added check if file is a yaml file and array len.

Comment on lines 334 to 336
for _, v := range bidderInfo.Syncer.Supports {
if !strings.EqualFold(v, "iframe") && !strings.EqualFold(v, "redirect") {
return fmt.Errorf("syncer could not be created, invalid supported endpoint: %s", v)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this variable v be more descriptive? I understand if you want to leave it the way it is, but I tend to like a little more from variable names

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed

vsolovei added 2 commits August 31, 2022 11:53
# Conflicts:
#	config/config.go
#	static/bidder-info/yssp.yaml
@AlexBVolcy
Copy link
Contributor

This looks good! I want to confirm that exchange about bidderInfos and viper is resolved before approving!

# Conflicts:
#	static/bidder-info/adkernel.yaml
#	static/bidder-info/invibes.yaml
#	static/bidder-info/triplelift.yaml
hhhjort
hhhjort previously approved these changes Sep 9, 2022
Copy link
Collaborator

@hhhjort hhhjort left a comment

Choose a reason for hiding this comment

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

LGTM

AlexBVolcy
AlexBVolcy previously approved these changes Sep 12, 2022
infos[bidder] = info
func validatePlatformInfo(info *PlatformInfo) error {
if len(info.MediaTypes) == 0 {
return errors.New("mediaTypes should be an array with at least one string element")
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: There is no need to include the wording "should be an array". Of course it's an array. Consider changing to an error along the line of "at least one meda type needs to be specified".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Modified

}

type infoReaderFromDisk struct {
path string
func applyBidderInfoConfigOverrides(configBidderInfos BidderInfos, fsBidderInfos BidderInfos) (BidderInfos, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is no longer necessary. We can let Viper take care of this work. You need to only give Viper the bidder infos before calling unmarshal and it will take care of the overrides:

func New(v *viper.Viper, bidderInfos BidderInfos) (*Configuration, error) {
	var c Configuration
	c.BidderInfos = bidderInfos

	if err := v.Unmarshal(&c); err != nil {
		return nil, fmt.Errorf("viper failed to unmarshal app config: %v", err)
	}
	
	...

This breaks is the legacy user sync url, which we can either choose to remove as part of this work or we alert applyBidderInfoConfigOverrides to only apply the legacy user sync url override.

This also removes our ability to disallow certain parts of the config to be changed, like the maintainer or media types. The later can cause a problem if it's less restrictive.

I think we can either:

  1. Let Viper handle everything and remove the override code. This allows hosts to "shoot themselves in the foot", but there's nothing stop them from editing the bidder info files directly?
  2. Keep control of overrides and create a new BidderInfoOverride with less fields and leave the override code.

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.

This is what you showed me on our very first discussion about the approach to support env variables.
We also had a discussion about it with Hans: #2353 (comment)

If I set c.BidderInfos = bidderInfos and have env variable for at least one field for a bidder (for example endpoint) - it overrides the entire object for this bidder and sets "endpoint" only. Other data from yaml file is not present for this bidder after config umnarshalling.

I think we need to control overrides. I removed capabilities from overrides, we can discuss what other fields should be removed. But I also think this is not obvious why some of the fields can be overridden and some not. Please advice.

v.BindEnv(adapterCfgPrefix+".xapi.username", "")
v.BindEnv(adapterCfgPrefix+".xapi.password", "")
v.BindEnv(adapterCfgPrefix+".xapi.tracker", "")
v.BindEnv(adapterCfgPrefix+".endpointCompression", "")
Copy link
Contributor

Choose a reason for hiding this comment

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

There be in danger in allowing unrestricted overrides of capabilities.app.mediaTypes and capabilities.site.mediaTypes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed support of the capabilities override


assert.Equal(t, "platform_id_override", cfg.BidderInfos["bidder1"].PlatformID)
assert.Equal(t, "app_secret_override", cfg.BidderInfos["bidder1"].AppSecret)
assert.Equal(t, "GZIP", cfg.BidderInfos["bidder1"].EndpointCompression)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO we don't need to test all of the env variables, just a few is fine to provide viper binding works ok. This seems a little too verbose IMHO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed some of checks

@@ -0,0 +1,3 @@
maintainer:
email: 123
gvlVendorID: "42"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need do add this? Unit tests should cover this already.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed. Just wanted to test it with actual yaml file.

@@ -267,7 +267,7 @@ func isAllowVastForBidder(bidder string, bidderInfos *config.BidderInfos, allowU
// check if bidder is configured
if b, ok := (*bidderInfos)[bidder]; bidderInfos != nil && ok {
// check if bidder is enabled
return b.Enabled && b.ModifyingVastXmlAllowed
return !b.Disabled && b.ModifyingVastXmlAllowed
Copy link
Contributor

Choose a reason for hiding this comment

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

I recommend adding a helper method to bidder info so we can call .IsEnabled() instead of negating the disabled field. The later is harder to read and easier to miss.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, modified

@VeronikaSolovei9 VeronikaSolovei9 dismissed stale reviews from AlexBVolcy and hhhjort via 13c2142 September 13, 2022 05:58
@@ -315,7 +319,7 @@ func validateCapabilities(info *CapabilitiesInfo, bidderName string) error {

func validatePlatformInfo(info *PlatformInfo) error {
if len(info.MediaTypes) == 0 {
return errors.New("mediaTypes should be an array with at least one string element")
return errors.New("at least one meda type needs to be specified")
Copy link
Collaborator

Choose a reason for hiding this comment

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

media has a typo 'meda'

# Conflicts:
#	config/config_test.go
AlexBVolcy
AlexBVolcy previously approved these changes Sep 15, 2022
Copy link
Contributor

@AlexBVolcy AlexBVolcy left a comment

Choose a reason for hiding this comment

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

LGTM

@hhhjort hhhjort merged commit fb564dd into master Sep 20, 2022
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
…rebid#2353)

* Adapter aliases: moved adapter related configs to bidder.yaml files

* Moved adapter configs from config.go to bidder.yaml files

* Removed ymal mappers

* Clean up

* Initial unit tests fix

* Merge with latest master

* Unit tests clean up

* Added pbs.json or pbs.yaml config support

* Fixes and unit tests, added ssyncer merge functions back

* Merge fixes

* Returned back adapter config set up using env variables

* Unit tests fixes

* Added test for adapter config overrides from environment variables

* Minor improvements

* Added more tests fro env variables, fixed mapstructures from bidder info

* Code review refactoring

* Code review refactoring and merge conflicts fixes

* Typo fix

Co-authored-by: vsolovei <[email protected]>
@SyntaxNode SyntaxNode deleted the adapter_aliases_config branch March 13, 2023 13:55
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