question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ProductHint with allowUnknownKeys=false misbehaves

See original GitHub issue

ProductHint with allowUnknownKeys=false misbehaves with pureconfig.loadConfig and pureconfig.loadConfigOrThrow.

I made a demo project to show the issue. Here is the relevant section. This code does not reference application.conf and should not try to pull in reference.conf.

implicit val hint: ProductHint[PureConfigFun] = ProductHint[PureConfigFun](allowUnknownKeys = false)
pureconfig.loadConfigOrThrow[PureConfigFun](Paths.get("pure.conf"))

Here is the error:

pureconfig.error.ConfigReaderException: Cannot convert configuration to a value of class PureConfigFun. Failures are:
  Other failures:
    -  UnknownKey(path,None)
    -  UnknownKey(file,None)
    -  UnknownKey(java,None)
    -  UnknownKey(os,None)
    -  UnknownKey(line,None)
    -  UnknownKey(user,None)
    -  UnknownKey(sun,None)
    -  UnknownKey(akka,None)
    -  UnknownKey(awt,None)

My app does not contain application.conf. Based on the error message, it looks like PureConfig compares against reference.conf, instead of just looking at pure.conf.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:20

github_iconTop GitHub Comments

1reaction
melriefcommented, Feb 26, 2017

For the UnknownKeys errors, the issue is that the default fieldMapping is KebabCase. See the doc. But the keys in your configuration are CamelCase. To configure to use CamelCase as field mapping, change the hint to

implicit val hint: ProductHint[PureConfigFun] =
  ProductHint[PureConfigFun](
    allowUnknownKeys = false,
    fieldMapping = ConfigFieldMapping(CamelCase, CamelCase)
  )

And everything should work

sbt "runMain PureConfigTest2"
[info] Loading global plugins from /home/mariop/.sbt/0.13/plugins
[info] Loading project definition from /home/mariop/prog/pure-config-test/project
[info] Set current project to pure-config-test (in build file:/home/mariop/prog/pure-config-test/)
PureConfigFun(ConsoleConfig(true),FeedConfig(Port(9090)),ReplConfig(~),SpeciesDefaults(0,100,25,20),SshServer(localhost,/home/mariop,true,None,,Port(1101),repl))
[success] Total time: 16 s, completed Feb 26, 2017 6:18:56 PM
0reactions
melriefcommented, Mar 2, 2017

@mslinn I’m closing this as resolved

Read more comments on GitHub >

github_iconTop Results From Across the Web

Product Hunt – The best new products in tech.
Product Hunt is a curation of the best new products, every day. Discover the latest mobile apps, websites, and technology products that everyone's...
Read more >
Assembly - Product Information, Latest Updates, and Reviews ...
Assembly is a free employee engagement, recognition, and rewards platform (free for unlimited users). Raise the bar on recognition and help instill your ......
Read more >
Product Hunt Launch Guide
Others in the community can upvote, comment, and share those products as they ... Comments and conversation also allow makers to gather feedback,...
Read more >
Instagreen - Product Information, Latest Updates, and ...
Create a fake, eco-unfriendly online life. Follow for updates. Visit website. More. upvotes. 166. followers.
Read more >
cdnjs/dexie.min.js.map at master · cdnjs/cdnjs · GitHub
n // Continue to next key but don't include this one.\n return false;\n } else {\n // cursor.key not yet at set[i]. Forward...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found