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

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

Closed
leonardlabat opened this issue Mar 9, 2020 · 1 comment
Assignees
Labels

Comments

@leonardlabat
Copy link
Contributor

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 added a commit to criteo-forks/Prebid.js that referenced this issue Mar 9, 2020
Use a deepmerge function to merge both globa level config & bidder specific config
@leonardlabat leonardlabat mentioned this issue Mar 9, 2020
1 task
@snapwich snapwich self-assigned this Mar 10, 2020
@stale
Copy link

stale bot commented Mar 24, 2020

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 stale bot added the stale label Mar 24, 2020
leonardlabat added a commit to criteo-forks/Prebid.js that referenced this issue Mar 26, 2020
Use a deepmerge function to merge both globa level config & bidder specific config
leonardlabat added a commit to criteo-forks/Prebid.js that referenced this issue Mar 27, 2020
@stale stale bot closed this as completed Mar 31, 2020
leonardlabat added a commit to criteo-forks/Prebid.js that referenced this issue Apr 15, 2020
msm0504 pushed a commit that referenced this issue Apr 15, 2020
iggyfisk pushed a commit to happypancake/Prebid.js that referenced this issue Jun 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants