Prebid.js icon indicating copy to clipboard operation
Prebid.js copied to clipboard

Issue when accessing same config key declared both in global config and bidder specific config

Open leonardlabat opened this issue 6 years ago • 1 comments

Type of issue

Bug

Description

When using config API, keys that are present both at global level and at bidder specific level are not properly deeply merged. This may happen particularly for standardize first party data, as it may involve config with several depth level.

Steps to reproduce

// global config
pbjs.setConfig({
   fpd: {
       context: {
           keywords: ["power tools"],
        }
    }
});
 
// bidder specific config
pbjs.setBidderConfig({
   bidders: ['criteo'],
   config: {
       fpd: {
           context: {
               data: {
                  category: "tools"
               }
            }
      }
   }
});

Expected results

When using config.getConfig('fpd.context'), I'd expect to get the following :

keywords: ["power tools"],
data: {
	category: "tools"
}

Actual results

I'm getting the following :

data: {
	category: "tools"
}

Other information

This is due to the following line in config.js :

memo[topic] = Object.assign({}, config[topic], currBidderConfig[topic]);

Object.assign does not properly merge objects on all their depths. I'd suggest to replace this line by a function that will properly do a deep merge. PR to come in a few minutes

leonardlabat avatar Mar 09 '20 10:03 leonardlabat

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 24 '20 17:03 stale[bot]