Skip to content

Variable substitution fails unexpectedly with overloaded values using resolveWith() #855

Description

@achohbee

An unexpected error occurs with the following code:

// This FAILS!
Config conf = ConfigFactory.parseString("{ \"one\": \"first\", \"one\": ${variable}}")
        .resolveWith(ConfigFactory.parseString("{ \"variable\": \"second\"}"));

The expected behavior is that the value of "one" will be ${variable}, which will resolve to "second". Instead, the following exception is thrown:

com.typesafe.config.ConfigException$BugOrBroken: replace in parent not possible ConfigDelayedMerge("first",${variable}) with Quoted("first") in ResolveSource(root=SimpleConfigObject({"variable":"second"}), pathFromRoot=null)

The following code blocks work as expected, so this is definitely an edge case that involves both an overloaded value AND resolving against another config:

// This works
Config conf = ConfigFactory.parseString("{ \"one\": \"first\", \"one\": ${variable}, \"variable\": \"second\"}")
        .resolve();
// This works
Config conf = ConfigFactory.parseString("{ \"one\": ${variable}}")
        .resolveWith(ConfigFactory.parseString("{ \"variable\": \"second\"}"));

Bug is observed running with artifact com.typesafe:config:1.4.9.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions