Root-level 'user' property is a strange object
See original GitHub issueTake the following code:
package com.example
import java.nio.file.Paths
import pureconfig._
import pureconfig.generic.auto._
case class MyConf(user:String, password:String)
object MyConfLoad {
def main(args:Array[String]):Unit = {
val loadedConfig = loadConfigOrThrow[MyConf](Paths.get("conf/my-conf.conf"))
println(loadedConfig.user)
}
}
… and the following config file:
# conf/my-conf.conf
user = "foo"
password = "bar"
In 0.11.1 this causes:
Exception in thread "main" pureconfig.error.ConfigReaderException: Cannot convert configuration to a com.example.MyConf. Failures are:
at 'user':
- Expected type STRING. Found OBJECT instead.
at pureconfig.package$.getResultOrThrow(package.scala:139)
at pureconfig.package$.loadConfigOrThrow(package.scala:172)
at com.example.MyConfLoad$.main(MyConf.scala:12)
at com.example.MyConfLoad.main(MyConf.scala)
In earlier versions (e.g. 0.8.0) it causes:
{"country":"US","dir":"/Users/me/projects/myproj","home":"/Users/me","language":"en","name":"me","timezone":"America/New_York"}
Something odd is happening with the ‘user’ property. However, if I switch it to ‘username’ it works fine. Also, if you add it to a sub-object of the root object it works fine.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Vue Computed property not updating - Strange behavior of ...
You cannot add root-level reactive properties to an existing component instance: Docs. You don't get any error, because the code is valid ...
Read more >v-model with uninitialized property · Issue #3732 · vuejs/vue
This is an intended change in 2.0 - v-model no longer creates non-existent properties for you, the basic idea is that all root-level...
Read more >WPF TreeListControl node expansion strange behavior
I am working on an MVVM application and have a tree list control that is bound to objects that contain an IsExpanded boolean...
Read more >A Complete Guide to Custom Properties | CSS-Tricks
The behavior of ! important inside the values of custom properties is quite unusual. Stefan Judis documents it well, but the gist is:...
Read more >Bookshelf v7.5: Integration Object User Properties
User Property Allowable Values Level
Association Y,N C
MVG Y,N C
Picklist Y,N F
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@deusaquilus,
You’re getting bitten by the default behavior of typesafe config, which is the library underlying pureconfig. You’ll notice in that documentation that the highest priority source for configuration is “system properties” which includes environment variables. Your shell almost certainly creates a
USER
env variable.To work around that you can manually load only the files you care about. Doing that will be much easier in the next version of pureconfig. Currently it’s kind of a hassle. I’d be happy to help you through it if you need a hand.
TL;DR: It’s a feature, not a bug. 😉
Starting at v0.12.0 (released today) you should use
ConfigSource
objects to mix and match the files or resources you want to load 🙂 See the docs here!Closing this as the behavior reported is expected according to Typesafe Config’s defaults.