-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
getConfig() is returning reference to the config object #7238
Comments
Thank you for opening this issue -- we are planning on discussing in the PMC meeting this week, as this would be a breaking change we will be strategizing on how to achieve the desired behavior. |
Just noting that many publisher may rely on this behavior |
@jrosendahl please fix behavior identified on line86 of your bidder |
Discussion in prebid committee seems to indicate we should make a readConfig function now that is a deep clone, regardless of future deprecation decisions. |
This work is in queue |
This was discussed in the publisher committee today; some publishers may be relying on this. The sense of the group was to create a new function, allow people to migrate to it, and very slowly add warnings to and eventually deprecate getConfig |
Can we close this issue? |
Closing this ticket as work is completed in #7237 |
Type of issue
Description
When adapters retrieve the config object by calling
config.getConfig()
, they are also able to manipulate the underlying object.This is because the
_getConfig()
function usesObject.assign()
when returning the configuration.Since
Object. assign()
copies an object's reference value, we can get scenarios where one adapter updates the config and another adapter is affected.For example:
Step 1: Config set by
setConfig()
on the pageStep 2: Another adapter updates the config by first calling
config.getConfig()
Step 3: Downstream adapters now retrieve the manipulated config object
Currently, the Sovrn adapter retrieves the
fpd
by callingconfig.getConfig(‘ortb2’)
, and using thatfpd
object to update ortb2.user.ext for their request.https://github.com/prebid/Prebid.js/blob/master/modules/sovrnBidAdapter.js#L86-L118
In the case where Sovrn is loaded before Index Exchange, the IX adapter will see the changes made by Sovrn
Test Page
Steps to Reproduce
pbjs.setConfig()
pbjs.getConfig('ortb2')
in consoleeids
&tpid
being added to the configuration by the sovrn adapter.Expected results
The
_getConfig()
should return adeepClone
of the config object and not allow individual adapters to manipulate theconfig
object.Actual results
The
_getConfig()
function usesObject.assign()
to return the stored config object, allowing adapter to manipulate data used by other downstream adapters.Platform details
Chrome: Version 91.0.4472.164 (Official Build) (x86_64)
Mac OS: Catalina; Version: 10.15.7
prebidJS: 5.6.0-pre
Other information
Potential solution: PR #7237
The text was updated successfully, but these errors were encountered: