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

BugOrBroken exception when replacing a value with a substitution #356

Open
dm3 opened this issue Sep 25, 2015 · 1 comment
Open

BugOrBroken exception when replacing a value with a substitution #356

dm3 opened this issue Sep 25, 2015 · 1 comment

Comments

@dm3
Copy link

dm3 commented Sep 25, 2015

Given the config below, we want to make sure that app-test.component entry doesn't get merged with the app.component entry. To achieve this we use the reset-hack, resetting the app-test.component to a value of a different type and reassigning to the correct value:

test {
    component {
        type = test
        properties {
           url = test
        }
    }
}

app {
   component {
       type = app
       properties {
          host = prod
       }
   }
}

app-prod = ${app} {
    component.value = app-prod
}

app-test = ${app} {
    component = reset, component = ${test.component}
}

loading the above config results in:

om.typesafe.config.ConfigException$BugOrBroken: SimpleConfigObject.replaceChild did not find SimpleConfigObject({"component":"reset","component":${test.component}}) in SimpleConfigObject({"app":{"component":{"properties":{"host":"prod"},"type":"app"}},"app-prod":${app}{"component":{"value":"app-prod"}},"app-test":${app}{"component":"reset","component":${test.component}}})

The config loads fine if no substitution is performed on the app-test.component assignment after reset.

@havocp
Copy link
Collaborator

havocp commented Sep 25, 2015

Thanks for the report! It fails here as you say with this test case:

    @Test
    def issue356(): Unit = {
        val s = """
test {
    component {
        type = test
        properties {
           url = test
        }
    }
}

app {
   component {
       type = app
       properties {
          host = prod
       }
   }
}

app-prod = ${app} {
    component.value = app-prod
}

app-test = ${app} {
    component = reset, component = ${test.component}
}
"""
        ConfigFactory.parseString(s).resolve()
    }

I can make it work by doing this, so you may have a workaround available:

tmp = {
    component = reset, component = ${test.component}
}

app-test = ${app} ${tmp}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants