tmtsoftware / icd

ICD - Interface Control Document Management
Other
12 stars 5 forks source link

Unhandled exception when ingesting un-quoted string #51

Open edwardchapin opened 6 years ago

edwardchapin commented 6 years ago

When ingesting a publish-model.conf with the following description string,

description = The beam-splitter stage has an unacceptable position error, datum may be lost.

I get the following exception:

java.lang.NullPointerException
    at com.typesafe.config.ConfigException.<init>(ConfigException.java:23)
    at com.typesafe.config.ConfigException$BadPath.<init>(ConfigException.java:198)
    at com.typesafe.config.ConfigException$BadPath.<init>(ConfigException.java:204)
    at com.typesafe.config.impl.PathParser.parsePathExpression(PathParser.java:170)
    at com.typesafe.config.impl.PathParser.parsePathNodeExpression(PathParser.java:85)
    at com.typesafe.config.impl.PathParser.parsePathNodeExpression(PathParser.java:79)
    at com.typesafe.config.impl.ConfigDocumentParser$ParseContext.parseKey(ConfigDocumentParser.java:282)
    at com.typesafe.config.impl.ConfigDocumentParser$ParseContext.parseObject(ConfigDocumentParser.java:448)
    at com.typesafe.config.impl.ConfigDocumentParser$ParseContext.parseValue(ConfigDocumentParser.java:247)
    at com.typesafe.config.impl.ConfigDocumentParser$ParseContext.consolidateValues(ConfigDocumentParser.java:152)
    at com.typesafe.config.impl.ConfigDocumentParser$ParseContext.parseArray(ConfigDocumentParser.java:593)
    at com.typesafe.config.impl.ConfigDocumentParser$ParseContext.parseValue(ConfigDocumentParser.java:249)
    at com.typesafe.config.impl.ConfigDocumentParser$ParseContext.consolidateValues(ConfigDocumentParser.java:152)
    at com.typesafe.config.impl.ConfigDocumentParser$ParseContext.parseObject(ConfigDocumentParser.java:471)
    at com.typesafe.config.impl.ConfigDocumentParser$ParseContext.parseValue(ConfigDocumentParser.java:247)
    at com.typesafe.config.impl.ConfigDocumentParser$ParseContext.parseObject(ConfigDocumentParser.java:456)
    at com.typesafe.config.impl.ConfigDocumentParser$ParseContext.parse(ConfigDocumentParser.java:646)
    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.parseFile(ConfigFactory.java:688)
    at com.typesafe.config.ConfigFactory.parseFile(ConfigFactory.java:702)
    at csw.services.icd.IcdValidator$.$anonfun$validate$1(IcdValidator.scala:90)
    at scala.collection.immutable.List.map(List.scala:287)
    at csw.services.icd.IcdValidator$.validate(IcdValidator.scala:85)
    at csw.services.icd.IcdValidator$.$anonfun$validateRecursive$1(IcdValidator.scala:72)
    at scala.collection.immutable.List.flatMap(List.scala:335)
    at csw.services.icd.IcdValidator$.validateRecursive(IcdValidator.scala:72)
    at csw.services.icd.db.IcdDb.ingest(IcdDb.scala:251)
    at csw.services.icd.db.IcdDb$.$anonfun$run$1(IcdDb.scala:111)
    at scala.Option.map(Option.scala:146)
    at csw.services.icd.db.IcdDb$.run(IcdDb.scala:111)
    at csw.services.icd.db.IcdDb$.delayedEndpoint$csw$services$icd$db$IcdDb$1(IcdDb.scala:98)
    at csw.services.icd.db.IcdDb$delayedInit$body.apply(IcdDb.scala:20)
    at scala.Function0.apply$mcV$sp(Function0.scala:34)
    at scala.Function0.apply$mcV$sp$(Function0.scala:34)
    at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
    at scala.App.$anonfun$main$1$adapted(App.scala:76)
    at scala.collection.immutable.List.foreach(List.scala:389)
    at scala.App.main(App.scala:76)
    at scala.App.main$(App.scala:74)
    at csw.services.icd.db.IcdDb$.main(IcdDb.scala:20)
    at csw.services.icd.db.IcdDb.main(IcdDb.scala)

Through trial-and-error I was able to get the file to ingest by quoting the string:

description = "The beam-splitter stage has an unacceptable position error, datum may be lost."

Since the raised exception offers no hints (e.g., line number in the input file, or an indication of unexpected input for the value of the field), it could be quite difficult to track down the problem. Furthermore, if you ingest a large number of files (e.g., an entire subsystem), there isn't even an indication of which file caused the exception.

At a minimum, please indicate which file is the source of an exception raised during ingestion. Also, if possible in this case, provide more information to the user regarding the cause of the exception.

abrighton commented 6 years ago

I checked in a fix that will at least print the file name in this case. Normally a much better error message should be printed by the Config class, however due to a bug that was reported but then closed without fixing (see https://github.com/lightbend/config/issues/367) a null pointer exception is thrown. I added a comment to the issue. Hopefully someone will notice and fix it. The problem is caused by the comma in the string, which is interpreted as a special char.

edwardchapin commented 6 years ago

Thanks - that's a very helpful fix.

Perhaps a compromise is to add a "Known Issues" section to README.md, to give users a sense of the kinds of problems they might expect.

abrighton commented 6 years ago

I added "Known Issues" section to the top level README.md file.