play-rconf / play-rconf-http

Retrieves configuration hosted behind a simple HTTP server
MIT License
1 stars 0 forks source link

Unexpected exception thrown when the remote config file contains "+=" #5

Closed jeberdson closed 3 years ago

jeberdson commented 4 years ago

Hi @thibaultmeyer ,

An exception is thrown if the remote config file contains "+=".

I have a configuration as written below,

play.modules.enabled += "play.modules.swagger.SwaggerModule"

In this configuration, the "+=" is present. So play-rconf-http is unable to read the configuration.

It is throwing UnexpectedException.

Error Logs:

play.api.UnexpectedException: Unexpected exception[Parse: String: 2: Expecting a value but got wrong token: 'newline' (JSON does not allow unescaped newline in quoted strings, use a backslash escape) (if you intended 'newline' (JSON does not allow unescaped newline in quoted strings, use a backslash escape) to be part of a key or string value, try enclosing the key or value in double quotes, or you may be able to rename the file .properties rather than .conf)] at play.core.server.DevServerStart$$anon$1.reload(DevServerStart.scala:214) at play.core.server.DevServerStart$$anon$1.get(DevServerStart.scala:144) at play.core.server.AkkaHttpServer.handleRequest(AkkaHttpServer.scala:304) at play.core.server.AkkaHttpServer.$anonfun$createServerBinding$1(AkkaHttpServer.scala:189) at akka.stream.impl.fusing.MapAsync$$anon$30.onPush(Ops.scala:1262) at akka.stream.impl.fusing.GraphInterpreter.processPush(GraphInterpreter.scala:523) at akka.stream.impl.fusing.GraphInterpreter.execute(GraphInterpreter.scala:409) at akka.stream.impl.fusing.GraphInterpreterShell.runBatch(ActorGraphInterpreter.scala:599) at akka.stream.impl.fusing.GraphInterpreterShell$AsyncInput.execute(ActorGraphInterpreter.scala:480) at akka.stream.impl.fusing.GraphInterpreterShell.processEvent(ActorGraphInterpreter.scala:574) at akka.stream.impl.fusing.ActorGraphInterpreter.akka$stream$impl$fusing$ActorGraphInterpreter$$processEvent(ActorGraphInterpreter.scala:742) at akka.stream.impl.fusing.ActorGraphInterpreter$$anonfun$receive$1.applyOrElse(ActorGraphInterpreter.scala:757) at akka.actor.Actor.aroundReceive(Actor.scala:539) at akka.actor.Actor.aroundReceive$(Actor.scala:537) at akka.stream.impl.fusing.ActorGraphInterpreter.aroundReceive(ActorGraphInterpreter.scala:664) at akka.actor.ActorCell.receiveMessage(ActorCell.scala:610) at akka.actor.ActorCell.invoke(ActorCell.scala:579) at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:268) at akka.dispatch.Mailbox.run(Mailbox.scala:229) at akka.dispatch.Mailbox.exec(Mailbox.scala:241) at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) Caused by: com.typesafe.config.ConfigException$Parse: String: 2: Expecting a value but got wrong token: 'newline' (JSON does not allow unescaped newline in quoted strings, use a backslash escape) (if you intended 'newline' (JSON does not allow unescaped newline in quoted strings, use a backslash escape) to be part of a key or string value, try enclosing the key or value in double quotes, or you may be able to rename the file .properties rather than .conf) at com.typesafe.config.impl.ConfigDocumentParser$ParseContext.parseError(ConfigDocumentParser.java:201) at com.typesafe.config.impl.ConfigDocumentParser$ParseContext.parseError(ConfigDocumentParser.java:197) at com.typesafe.config.impl.ConfigDocumentParser$ParseContext.parseValue(ConfigDocumentParser.java:251) at com.typesafe.config.impl.ConfigDocumentParser$ParseContext.parseObject(ConfigDocumentParser.java:475) at com.typesafe.config.impl.ConfigDocumentParser$ParseContext.parse(ConfigDocumentParser.java:648) at com.typesafe.config.impl.ConfigDocumentParser.parse(ConfigDocumentParser.java:14) at com.typesafe.config.impl.Parseable.rawParseValue(Parseable.java:260) at com.typesafe.config.impl.Parseable.rawParseValue(Parseable.java:248) at com.typesafe.config.impl.Parseable.parseValue(Parseable.java:180) at com.typesafe.config.impl.Parseable.parseValue(Parseable.java:174) at com.typesafe.config.impl.Parseable.parse(Parseable.java:299) at com.typesafe.config.ConfigFactory.parseString(ConfigFactory.java:1001) at com.typesafe.config.ConfigFactory.parseString(ConfigFactory.java:1011) at io.playrconf.ApplicationLoaderScala.processAllProviders(ApplicationLoaderScala.scala:160) at io.playrconf.ApplicationLoaderScala.builder(ApplicationLoaderScala.scala:68) at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:22) at play.core.server.DevServerStart$$anon$1.$anonfun$reload$3(DevServerStart.scala:193) at play.utils.Threads$.withContextClassLoader(Threads.scala:22) at play.core.server.DevServerStart$$anon$1.reload(DevServerStart.scala:185) ... 23 common frames omitted

jeberdson commented 4 years ago

Hi @thibaultmeyer , Can you please address this issue?

thibaultmeyer commented 4 years ago

Hello,

i will have a look tonight about this issue

thibaultmeyer commented 4 years ago

Hello,

By nature and to be consistent with other providers, it is not possible to have access to the root configuration file in the http-provider. So it's not possible to make "+=" on the "play.modules.enabled" variable. Instead, you have to redefine your "play.modules.enabled" key entirely.

Sample

play.modules.enabled = [
  "play.modules.swagger.SwaggerModule",
  "module_1",
  "module_2",
  "module_3",
  "module_n",
]