Skip to content

config.get returns a reference, instead of a copy #505

@fgheorghe

Description

@fgheorghe

Not sure if this is a bug or not, but the 'get' method call for a config value which is an object returns a reference rather than a copy.

This means that any changes to the returned config value, would update the config value - this behaviour not being expected for a READ method and is inconsistent with get calls for non object values.

What is the current behavior?

let value = config.get('test') -> where test is an object.
value.testKey = 'test'
console.log(config.get('test')) -> the config 'test' value has been updated with a new key: 'testKey'.

What is the expected behavior?

If a config value is an object, a copy of it should be returned, such that value.testKey does not affect subsequent calls to .get(). Instead of the user making a copy using Object.assign or something else, this is what I would expect .get to do.

Lib version:

^1.26.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions